The restorative procedure of terminal, image and device
Technical field
The present invention relates to image processing field, particularly the restorative procedure of a kind of terminal, image and device.
Background technology
Image repair refers to has the digital picture of loss of data or damage to enter according to certain ad hoc rules in localized regionRow is repaired, and makes the integrality of its Recovery image. The image that this technology is caused by Internet Transmission in the calligraphy and painting that restores relics, reparation is residualLack, remove word and the cut in image and video and remove the aspects such as object in image and be used widely. Typical caseGround, in digital picture, due to the spot on defect sensor, camera lens, the factor such as inhomogeneous of exposing, there will be zonal lookColoured silk or brightness irregularities phenomenon, for example, in digital photograph, red eye phenomenon causes people's ocular to occur that significantly redness is inhomogeneous,Need to repair by region, make the whole ocular after repairing look like even nature.
At present, Digital Image Inpainting is broadly divided into two classes:
One class is to repair (inpainting) technology for the damaged digital picture of small scale. This technology utilization waits to repairThe marginal information in region adopts a kind ofly by slightly estimating the direction of isophote (isophote) to smart method simultaneously, and adoptsWith mechanism of transmission by Information Communication in region to be repaired, to obtain good repair efficiency. Typical digital picture is repaiiedBenefit technology is iteration theory of adjustment, and the method makes its slickness around slowly propagate into area to be repaired by iterative process repeatedlyIn, slickness is estimated to be had multiplely, and commonly Laplce (Laplace) is smooth, and the direction of propagation is generally cutting along borderLaunch to circumferencial direction. In essence, iteration theory of adjustment is a kind of patch algorithm based on partial differential equation. What user provided coversCode is specified the adorned part of input picture, and the image of input is considered as three independently passages, i.e. R, G and B by this algorithm. ForEach passage, it is by propagating and fill up area to be repaired from the extra-regional information of mask along horizontal line. EquiluminousLine direction obtains by calculating the vector that the discrete gradient vector sum 90 degree rotations in each pixel produce along reparation profile,Object is to diffuse information in having retained edge. Estimate the level and smooth variable of color, this variable by a two dimensions LaplaceTo propagate along isophote direction. After every several steps in repair process, this algorithm carries out several and spreads iteration smoothlyRepair district. The diffusion of use anisotropy, to retain border, whole reparation district.
Another kind of is image completion (completion) technology for blank map picture bulk drop-out. This class technologyComprise two kinds of methods: a kind of is recovery technique based on picture breakdown, its main thought be by picture breakdown be structure division andTexture part, wherein structure division is repaired with repairing (inpainting) algorithm, and texture part is filled with texture synthesis method; SeparatelyBe an information of filling loss with block-based Future Opportunities of Texture Synthesis, the main thought of this algorithm is, first repairs from waitingOn the border in region, choose a pixel, centered by this pixel, choose size according to the textural characteristics of image and close simultaneouslySuitable texture block, is then treating that finding the most close with it Texture Matching piece around repairing area substitutes this texture block. ?In above-mentioned textural characteristics matching method, first user specifies the region that needs reparation, the institute in algorithm pointwise traversal area to be repairedThere is pixel, outside area to be repaired, find the most similar pixel of textural characteristics for each pixel, directly the most similar with thisDot information is repaired it. Textural characteristics has different method for expressing, can be all pixel values in this pixel n*n neighborhood, or n*nGrad in neighborhood, or both combinations. The coupling of textural characteristics is based on various distance measures, as shades of colour skyBetween on Euclidean distance etc.
Undertaken by pixel due to textural characteristics coupling, constantly search in whole pictures and point texture feature to be repairedThe most similar, repair process is inwardly carried out by area outer to be repaired, and therefore amount of calculation depends on the resolution ratio of imageSize, the size of area to be repaired, the size of texture description template etc., the increase of above-mentioned each factor relevant parameter can cause amount of calculationBeing how much multiples increases. And for iteration theory of adjustment, although its do not consider from compare Yuan region, area to be repaired, be a kind of localSearching method, but will obtain reasonable result, General Requirements iterations is a lot, and its amount of calculation depends on area to be repairedSize and iterations. Therefore the increase of iterations causes the multiple of repair time to increase too.
Visible, no matter be textural characteristics matching method or iteration theory of adjustment, relate to amount of calculation very large. On the one hand, above-mentionedDigital picture restorative procedure causes repair time long, is unsuitable for the occasion lower at handling property, as mobile-terminal platform etc.; SeparatelyOn the one hand, repair taking pixel according to existing digital picture restorative procedure as unit, amount of calculation is huge, inevitably can leadCause local color inconsistent, affect overall perception.
More technical schemes about image-region restorative procedure can be US2008/0238942A1 with reference to publication numberDenomination of invention is the U.S. Patent application file of " object-based image mending ", but still does not address the above problem.
Summary of the invention
The problem that technical solution of the present invention solves is that the existing amount of calculation that digital picture is repaired is large, and repairing effectNot good.
For addressing the above problem, the embodiment of the present invention provides a kind of restorative procedure of image, comprising: add up each pixelCharacteristic parameter, to set up the histogram of image; Determine the characteristic parameter segmentation threshold in region based on described histogram; According to featureDescribed image is divided into background area and contaminated area by parameter segmentation threshold; The average of the characteristic parameter based on described contaminated area, instituteState the average of characteristic parameter of background area and variance and adjust the characteristic parameter of pixel in described contaminated area.
Alternatively, described image is gray level image, and described characteristic parameter is gray value.
Alternatively, described image is coloured image, and described characteristic parameter is luminance component or chromatic component, or brightness dividesAmount and chromatic component.
Alternatively, described characteristic parameter segmentation threshold comprises that characteristic parameter is cut apart the upper limit and characteristic parameter is cut apart lower limit, instituteState contaminated area and comprise He An contaminated area, bright contaminated area; The characteristic parameter of the pixel of described bright contaminated area is higher than described characteristic parameterCut apart the upper limit; The characteristic parameter of the pixel of described dark contaminated area is cut apart lower limit lower than described characteristic parameter.
Alternatively, the characteristic parameter of the pixel of described background area is less than or equal to characteristic parameter segmentation threshold; Described dirtDye the characteristic parameter of pixel in district higher than characteristic parameter segmentation threshold.
Alternatively, the characteristic parameter of the pixel of described background area is greater than or equal to characteristic parameter segmentation threshold; Described dirtDye the characteristic parameter of pixel in district lower than characteristic parameter segmentation threshold.
Alternatively, the average of described characteristic parameterThe variance of described characteristic parameterItsIn, the characteristic parameter that Ti is i pixel, the number that N is pixel.
Alternatively, whenTime, according toAdjust in described contaminated areaThe characteristic parameter of pixel, wherein, ToldFor the pixel of the described contaminated area characteristic parameter before adjustment; TnewFor described pollutionThe characteristic parameter of the pixel in district after adjustment;For adjusting the average of characteristic parameter of front described contaminated area pixel;For the average of the characteristic parameter of described background area pixel; σbkgFor the variance of the characteristic parameter of described background area pixel; α isThe recovery strength factor.
Alternatively, whenTime, according toAdjust in described contaminated areaThe characteristic parameter of pixel, wherein, ToldFor the pixel of the described contaminated area characteristic parameter before adjustment; TnewFor described pollutionThe characteristic parameter of the pixel in district after adjustment;For adjusting the average of characteristic parameter of front described contaminated area pixel;For the average of the characteristic parameter of described background area pixel; σbkgFor the variance of the characteristic parameter of described background area pixel; α isThe recovery strength factor.
Alternatively, described recovery strength factor-alpha represents the characteristic parameter difference degree of described contaminated area and described background area,Described recovery strength factor-alpha span is [1,3].
Correspondingly, the embodiment of the present invention also provides a kind of prosthetic device of image, comprising:
Histogram is set up unit, for adding up the characteristic parameter of each pixel, to set up the histogram of image;
Segmentation threshold determining unit, determines the feature in region for set up the histogram of setting up unit according to described histogramParameter segmentation threshold;
Region Segmentation unit, described in inciting somebody to action according to the definite characteristic parameter segmentation threshold of described segmentation threshold determining unitImage is divided into background area and contaminated area;
Characteristic parameter adjustment unit, for the average of the characteristic parameter based on described contaminated area, the feature of described background areaThe average of parameter and variance are adjusted the characteristic parameter that needs the pixel of repairing in described contaminated area.
Correspondingly, the embodiment of the present invention also provides a kind of terminal, comprises the prosthetic device of described image.
With respect to prior art, technical solution of the present invention has proposed to cut apart image-region based on statistics with histogram characteristic, profitRestorative procedure and the device of repairing the image of contaminated area with background area, have following beneficial effect:
From in pointwise traversal need reparation district and iteration theory of adjustment in textural characteristics matching method, repeatedly interative computation is different, thisBright technical scheme has been utilized statistics with histogram characteristic, and image is divided into background area and contaminated area, utilizes the feature of background areaThe statistical property of parameter is adjusted the characteristic parameter of the pixel of contaminated area, to repair contaminated area, and this reparation skill based on regionArt has greatly reduced amount of calculation, and simple and fast while realization possesses stronger adaptive ability, can be applicable to handling property lowerOccasion, as mobile-terminal platform etc.
Image repair technology based on region can avoid conventional images restorative procedure to repair and make as unit taking pixelThe local color becoming is inconsistent and affect overall perception, has ensured region global consistency, and in reserve area, natural texture is thinJoint perception.
Brief description of the drawings
Fig. 1 is the schematic flow sheet of the detailed description of the invention of the restorative procedure of a kind of image of the present invention;
Fig. 2 is the example signal that needs to repair image-region in the detailed description of the invention of restorative procedure of a kind of image of the present inventionFigure;
Fig. 3 is the statistics with histogram schematic diagram of image in the specific embodiment of the present invention;
Fig. 4 is the structural representation of the detailed description of the invention of the prosthetic device of a kind of image of the present invention;
Fig. 5 is that in the detailed description of the invention of prosthetic device of a kind of image of the present invention, the structure of characteristic parameter adjustment unit is shownIntention.
Detailed description of the invention
For the problem of prior art, inventor, through research, provides a kind of statistics with histogram characteristic based on regionAdjust the restorative procedure of the image of the characteristic parameter of contaminated area. Fig. 1 is the concrete reality of the restorative procedure of a kind of image of the present inventionExecute the schematic flow sheet of mode. Please refer to Fig. 1, the restorative procedure of image comprises described in technical solution of the present invention:
Step S1: add up the characteristic parameter of each pixel, to set up the histogram of image;
Step S2: the characteristic parameter segmentation threshold of determining region based on described histogram;
Step S3: described image is divided into background area and contaminated area according to characteristic parameter segmentation threshold;
Step S4: average and the side of the average of the characteristic parameter based on described contaminated area, the characteristic parameter of described background areaThe poor characteristic parameter that needs the pixel of repairing in described contaminated area of adjusting.
The average of described characteristic parameterThe variance of described characteristic parameterWherein, Ti isThe characteristic parameter of i pixel, the number that N is pixel. For background area, the average of described characteristic parameterThe variance of described characteristic parameterWherein, Ti is the characteristic parameter of i pixel of described background area, and N isThe number of the pixel of described background area; For contaminated area, the average of described characteristic parameterDescribed characteristic parameterVarianceWherein, Ti is the characteristic parameter of i the pixel in described contaminated area, the picture that N is described contaminated areaThe number of vegetarian refreshments.
In one embodiment, described characteristic parameter segmentation threshold comprises that characteristic parameter is cut apart the upper limit and characteristic parameter is cut apartLower limit, described contaminated area comprises He An contaminated area, bright contaminated area; The characteristic parameter of the pixel of described bright contaminated area is higher than describedCharacteristic parameter is cut apart the upper limit; The characteristic parameter of the pixel of described dark contaminated area is cut apart lower limit lower than described characteristic parameter.
In another kind of embodiment, the characteristic parameter of the pixel of described background area is cut apart threshold less than or equal to characteristic parameterValue; The characteristic parameter of the pixel of described contaminated area is higher than characteristic parameter segmentation threshold.
In another embodiment, the characteristic parameter of the pixel of described background area is cut apart threshold greater than or equal to characteristic parameterValue; The characteristic parameter of the pixel of described contaminated area is lower than characteristic parameter segmentation threshold.
Described image can be gray level image, and described characteristic parameter can be gray value. For gray level image, described stepS1 adds up the intensity profile of the whole image-region including poluted region. Grey level histogram (histogram) is gray scaleThe function of level, has the number of the pixel of every kind of gray level in its presentation graphs picture, every kind of frequency that gray scale occurs in reflection image.The abscissa of grey level histogram is gray level, and ordinate is the frequency that this gray level occurs, is the most basic statistics spy of imageLevy.
Described image can be also coloured image, and described characteristic parameter is luminance component or chromatic component, or brightnessComponent and chromatic component. Color histogram is the histogrammic special case of higher-dimension, the frequency of occurrences of its statistics color, the i.e. probability of colorDistributed intelligence. Conventionally this needs certain quantizing process, color is divided into the kind of some non-overlapping copies. Generally directly do not existIn rgb color space, add up, but after brightness is separated, the information that represents color part is added up, as at HSIThe HS subspace in space, the UV subspace of yuv space, and enter in the color space representation of other reflection human vision characteristicsOK. For coloured image, because human eye is not so good as brightness sensitivity to the perception of field color, therefore only statistics of described step S1Luminance component, more described luminance component is adjusted as Y passage to step S4 according to step S2, and Color Channel is constant; WhenSo also can be respectively by brightness Y, color component U and V adjust to step S4 according to step S1. Concrete adjustment mode will underState in embodiment and describe.
Embodiment mono-
The present embodiment describes as an example of gray level image example, please refer to Fig. 2, and Fig. 2 is the reparation side of a kind of image of the present inventionIn the detailed description of the invention of method, need to repair the example schematic of image-region. Wherein the gray area in district accounts for main portion as a settingPoint, the contaminated part of black and white region representation, carries out when image-region is repaired its gray scale to be adjusted to and backgroundRegion is close to consistent, whole region is looked like homogeneous. It should be noted that just a kind of signal of Fig. 2, actual grey, whiteThe levels such as look can change within the specific limits, and transition therebetween neither clearly, occupy the majority but totally still show as background, by dirtyDye for minority, and be distributed in background area brighter or darker two extreme.
Step S1: the first intensity profile of each pixel in the whole region of statistics including poluted region, buildThe histogram of vertical described gray level image.
Step S2: according to the statistical conditions of background area the most intensive in histogram, can determine the gray scale of poluted regionSegmentation threshold. Please refer to Fig. 3, Fig. 3 is the statistics with histogram schematic diagram of image in the specific embodiment of the present invention. Can from Fig. 3Know that the bound of Region Segmentation determines method, in figure, the gray value of described dark contaminated area central point be described image this secretly polluteThe highest gray value of district's frequency of occurrences, the gray value of background area central point is the highest gray value of this background area frequency of occurrences, brightThe gray value of contaminated area central point is the highest gray value of this bright contaminated area frequency of occurrences. From background area central point, respectivelyCan draw the upper and lower bound of whole image region segmentation toward the right and left searching minimum flex point. Concrete Digital Implementation canAdopt the digital difference of statistics with histogram to assign to, minimum flex point place difference near-zero and its value are less than left and right sides value. ThisIn embodiment, described gray scale segmentation threshold can comprise that gray scale is cut apart the upper limit and gray scale is cut apart lower limit.
Step S3: described gray level image is divided into background area and contaminated area according to gray scale segmentation threshold. In conjunction with Fig. 2 and Tu3, cut apart the upper limit and gray scale is cut apart lower limit according to the gray scale obtaining in step S2, the whole region of described gray level image can be cut apartFor background area (gray area of Fig. 2), bright contaminated area (white portion of Fig. 2) and dark contaminated area (black region of Fig. 2). DescribedBright contaminated area is that the gray value of the pixel of white portion is cut apart the upper limit higher than described gray scale; Described dark contaminated area is black regionThe gray value of pixel cut apart lower limit lower than described gray scale, described background area be gray area pixel gray value betweenDescribed gray scale cuts apart the upper limit and described gray scale is cut apart between lower limit.
It should be noted that, for gray level image, He An contaminated area, bright contaminated area is uninevitable to be existed simultaneously. Also likelyThere are following two kinds of situations, that is, the first situation, the gray value of the pixel of described background area is cut apart threshold less than or equal to gray scaleValue, the gray value of the pixel of described contaminated area is higher than gray scale segmentation threshold, and now described contaminated area only comprises bright contaminated area,There is not dark contaminated area; The second situation, the gray value of the pixel of described background area is greater than or equal to gray scale segmentation threshold, instituteState the gray value of pixel of contaminated area lower than gray scale segmentation threshold, now described contaminated area only comprises dark contaminated area, and notThere is bright contaminated area.
Step S4: the average of the gray scale based on described contaminated area, the gray value of described background area and variance are adjusted described dirtDye the gray scale of the pixel in district. Particularly:
Step S41: calculate described average and variance.
According to the computing formula of above-mentioned average and variance, can draw:
The average of the gray scale of all pixels of background areaThe side of the gray scale of all pixels of background areaPoorWherein, Gi is the gray value of i pixel of described background area, and N is described background area pixelThe number of point. The average of the gray scale of all pixels of contaminated area isWherein, Gi is described contaminated area iThe gray value of pixel, N is the number of described contaminated area pixel.
Step S42: judge the pixel that needs reparation in contaminated area.
Default recovery strength factor-alpha, described recovery strength factor-alpha characterizes with background area gray scale and differs many in the present embodimentExtreme Polluted area in large extent and scope will be repaired. Recovery strength factor-alpha depends on the described contaminated area and the institute that need reparationState the gray difference degree of background area, described recovery strength factor-alpha span is [1,3], can be for example 1.0,1.2,1.5,1.8,2.0,2.2,2.5,2.8,3.0 etc., difference is larger, and value should be larger.
WhenOrTime, judge gray scale and the institute of this pixel in described contaminated areaThe gray difference of pixel of stating background area is excessive, need to repair; WhenJudge that the gray difference of pixel in the gray scale of this pixel in described contaminated area and described background area is within the scope of tolerable,Do not need to repair.
Step S43, adjusts the gray scale that needs the pixel of repairing in described contaminated area.
WhenTime, according toAdjust in described contaminated area and need to repairMultiple pixel gray value, wherein, GoldFor the pixel of the described contaminated area gray value before adjustment; GnewFor described contaminated areaThe gray value of pixel after adjustment;For adjusting the average of gray scale of front described contaminated area;For described background areaThe average of gray scale; σbkgFor the variance of the gray scale of described background area pixel; α is the recovery strength factor default in step S42;Abs represents to ask absolute value.
WhenTime, according toAdjust in described contaminated area and need to repairThe gray value of multiple pixel, wherein, GoldFor the pixel of the described contaminated area gray value before adjustment; GnewFor described pollutionThe gray value of the pixel in district after adjustment;For adjusting the average of gray scale of front described contaminated area;For described background areaThe average of gray scale; σbkgFor the variance of the gray scale of described background area pixel; α be recovery strength default in step S42 because ofSon; Abs represents to ask absolute value.
So far, gray level image reparation completes described in the present embodiment, and whole region looks like homogeneous.
Embodiment bis-
The present embodiment describes as an example of coloured image example, because human eye is not so good as brightness sensitivity to the perception of field color,Therefore the present embodiment is only adjusted the contaminated area of image according to the statistics of luminance component.
Step S1: the first luminance component of each pixel in the whole region of statistics including poluted region, buildThe brightness histogram of vertical described coloured image.
Step S2: according to the statistical conditions of background area the most intensive in described brightness histogram, can determine contaminated districtThe Intensity segmentation threshold value in territory. In the present embodiment, described Intensity segmentation threshold value can comprise under the Intensity segmentation upper limit and Intensity segmentationLimit.
Step S3: described color images is become to background area and contaminated area according to Intensity segmentation threshold value. According to step S2The Intensity segmentation upper limit of middle acquisition and Intensity segmentation lower limit, the whole region of described luminance picture can be divided into background area, brightHe An contaminated area, contaminated area; The brightness value of the pixel of described bright contaminated area is higher than the described Intensity segmentation upper limit; Described dark pollutionThe brightness value of the pixel in district is lower than described Intensity segmentation lower limit, and the brightness value of the pixel of described background area is between described brightnessCut apart between the upper limit and described Intensity segmentation lower limit.
It should be noted that equally, for described coloured image, He An contaminated area, bright contaminated area is uninevitable to be existed simultaneously.Also likely there are following two kinds of situations, that is, the first situation, the brightness value of the pixel of described background area is less than or equal to brightDegree segmentation threshold, the brightness value of the pixel of described contaminated area is higher than Intensity segmentation threshold value, and now described contaminated area only comprises, there is not dark contaminated area in bright contaminated area; The second situation, the brightness value of the pixel of described background area divides greater than or equal to brightnessCut threshold value, the brightness value of the pixel of described contaminated area is lower than Intensity segmentation threshold value, and now described contaminated area only comprises dark dirtDye district, and do not have bright contaminated area.
Step S4: average and the variance of the brightness value based on described contaminated area and the brightness of described background area are adjusted described dirtDye the brightness of the pixel in district, particularly:
Step S41: calculate described average and variance.
According to the computing formula of above-mentioned average and variance, can draw:
The average of the brightness of all pixels of background areaThe side of the brightness of all pixels of background areaPoorWherein, Yi is the brightness value of i pixel of described background area, and N is described background area pixelNumber.
The average of the brightness of all pixels of contaminated area isWherein, Yi is i of described contaminated area pictureThe brightness value of vegetarian refreshments, N is the number of described contaminated area pixel.
Step S42: judge the pixel that needs reparation in contaminated area.
Default recovery strength factor-alpha, described recovery strength factor-alpha characterizes with background area brightness and differs many in the present embodimentExtreme Polluted area in large extent and scope will be repaired. Recovery strength factor-alpha depends on the described contaminated area and the institute that need reparationState the luminance difference degree of background area, described recovery strength factor-alpha span is [1,3], can be for example 1.0,1.2,1.5,1.8,2.0,2.2,2.5,2.8,3.0 etc., difference is larger, and value should be larger.
WhenOrTime, the brightness of judging this pixel in described contaminated area withThe luminance difference of the pixel of described background area is excessive, need to repair; WhenJudge that the luminance difference of pixel in the brightness of this pixel in described contaminated area and described background area is within the scope of tolerable,Do not need to repair.
Step S43, adjusts the brightness that needs the pixel of repairing in described contaminated area.
WhenTime, according toAdjusting needs in described contaminated area to repairPixel brightness value, wherein, YoldFor the pixel of the described contaminated area brightness value before adjustment; YnewFor the picture of described contaminated areaThe brightness value of vegetarian refreshments after adjustment;For adjusting the average of brightness of front described contaminated area pixel;For described background areaThe average of the brightness of pixel; σbkgFor the variance of the brightness of described background area pixel; α is that recovery default in step S42 is strongThe degree factor; Abs represents to ask absolute value.
WhenTime, according toAdjusting needs in described contaminated area to repairThe brightness value of pixel, wherein, YoldFor the pixel of the described contaminated area brightness value before adjustment; YnewFor described contaminated areaThe brightness value of pixel after adjustment;For adjusting the average of brightness of front described contaminated area pixel;For described backgroundThe average of the brightness of district's pixel; σbkgFor the variance of the brightness of described background area pixel; α is recovery default in step S42Intensity factor; Abs represents to ask absolute value.
So far, luminance picture reparation completes described in the present embodiment, and whole region looks like homogeneous, retain simultaneously its fromThe trickle texture variations of body, whole region therefore brightness is consistent and be no lack of natural texture perception.
Embodiment tri-
The present embodiment describes as an example of the coloured image of YUV color space example, in the present embodiment not only according to brightnessComponent is also adjusted the contaminated area of image according to the statistics of chromatic component simultaneously.
In YUV color space, luminance component Y separates with chromatic component U, V. There is no U, V if only have Y componentComponent, the figure representing so is like this exactly black and white gray-scale map. As adopting yuv space, color TV can solve with luminance component YThe compatibling problem of colour television set and black and white television set, makes black and white television set also can receive colour signal.
In the present embodiment coloured image, the restorative procedure of luminance component Y is identical with method described in embodiment bis-, and this is not superfluousState. Can be respectively adjust to step S4 according to step S1 for chromatic component U and V. Below taking chromatic component U as example detailedExplanation.
Step S1: the first chromatic component U of each pixel in the whole region of statistics including poluted region, buildsThe colourity U histogram of vertical described coloured image.
Step S2: according to the statistical conditions of background area the most intensive in described colourity U histogram, can determine contaminated districtThe colourity U segmentation threshold in territory. In the present embodiment, described colourity U segmentation threshold can comprise that colourity U is cut apart the upper limit and colourity U dividesCut off limit.
Step S3: described color images is become to background area and contaminated area according to colourity U segmentation threshold. According to step S2The colourity U of middle acquisition cuts apart the upper limit and colourity U is cut apart lower limit, the whole region of described colourity U image can be divided into background area,He An contaminated area, bright contaminated area; The colourity U value of the pixel of described bright contaminated area is cut apart the upper limit higher than described colourity U; Described darkThe colourity U value of the pixel of contaminated area is cut apart lower limit lower than described colourity U, the colourity U value of the pixel of described background area betweenDescribed colourity U cuts apart the upper limit and described colourity U is cut apart between lower limit.
It should be noted that equally, for described coloured image, He An contaminated area, bright contaminated area is uninevitable to be existed simultaneously.Also likely there are following two kinds of situations, that is, the first situation, the colourity U value of the pixel of described background area less than or equal toColourity U segmentation threshold, the colourity U value of the pixel of described contaminated area is higher than colourity U segmentation threshold, and now described contaminated area is onlyComprise bright contaminated area, do not have dark contaminated area; The second situation, the colourity U value of the pixel of described background area greater than or equal toColourity U segmentation threshold, the colourity U value of the pixel of described contaminated area is lower than colourity U segmentation threshold, and now described contaminated area is onlyComprise dark contaminated area, and do not have bright contaminated area.
Step S4: described in the average of the colourity U value based on described contaminated area and the colourity U of described background area and variance are adjustedThe colourity U of the pixel of contaminated area, particularly:
Step S41: calculate described average and variance.
According to the computing formula of above-mentioned average and variance, can draw:
The average of the colourity U of all pixels of background areaThe colourity U's of all pixels of background areaVarianceWherein, Ui is the colourity U value of i pixel of described background area, and N is described background area pictureThe number of vegetarian refreshments.
The average of the colourity U of all pixels of contaminated area isWherein, Ui is described contaminated area iThe colourity U value of pixel, N is the number of described contaminated area pixel.
Step S42: judge the pixel that needs reparation in contaminated area.
Default recovery strength factor-alpha, described recovery strength factor-alpha characterizes with background area colourity U and differs in the present embodimentExtreme Polluted area in much extent and scopes will be repaired. Recovery strength factor-alpha depend on need repair described contaminated area withThe colourity U difference degree of described background area, described recovery strength factor-alpha span is [1,3], can be for example 1.0,1.2,1.5,1.8,2.0,2.2,2.5,2.8,3.0 etc., difference is larger, and value should be larger.
WhenOrTime, the colourity U that judges this pixel in described contaminated area withThe colourity U difference of the pixel of described background area is excessive, need to repair; WhenJudge that the colourity U difference of pixel in the colourity U of this pixel in described contaminated area and described background area is in tolerable scopeIn, do not need to repair.
Step S43, adjusts the colourity U that needs the pixel of repairing in described contaminated area.
WhenTime, according toAdjust in described contaminated area and need to repairMultiple pixel colourity U value, wherein, UoldFor the pixel of the described contaminated area colourity U value before adjustment; UnewFor described pollutionThe colourity U value of the pixel in district after adjustment;For adjusting the average of colourity U of front described contaminated area pixel;For instituteState the average of the colourity U of background area pixel; σbkgFor the variance of the colourity U of described background area pixel; α is pre-in step S42If the recovery strength factor; Abs represents to ask absolute value.
WhenTime, according toAdjust in described contaminated area and need to repairThe chromatic value of multiple pixel, wherein, UoldFor the pixel of the described contaminated area chromatic value before adjustment; UnewFor described pollutionThe chromatic value of the pixel in district after adjustment;For adjusting the average of colourity of front described contaminated area pixel;For describedThe average of the colourity of background area pixel; σbkgFor the variance of the colourity U of described background area pixel; α is default in step S42The recovery strength factor; Abs represents to ask absolute value.
The reparation of colourity V and the restorative procedure of above-mentioned colourity U for described coloured image are similar, and it will not go into details.
So far, coloured image reparation completes described in the present embodiment, due to the pixel to image contamination district based on regionLuminance component and chromatic component are adjusted respectively, make the repairing effect of image better, and whole region looks like homogeneous,Retain the trickle texture variations of himself, whole region therefore colourity is consistent and be no lack of natural texture perception simultaneously.
Correspondingly, technical solution of the present invention also provides a kind of prosthetic device of image, this device taking region unit in image asRepair on basis, has improved overall perception and speed that digital picture is repaired, is suitable for the number of the lower occasion of processor performanceWord image repair demand. Below in conjunction with instantiation, the prosthetic device of image is elaborated.
Shown in Fig. 4, a kind of embodiment of the prosthetic device 1 of a kind of image of the present invention can comprise:
Histogram is set up unit 11, for adding up the characteristic parameter of each pixel, to set up the histogram of image;
Segmentation threshold determining unit 12, determines region for set up the histogram of setting up unit 11 based on described histogramCharacteristic parameter segmentation threshold;
Region Segmentation unit 13, for inciting somebody to action according to the definite characteristic parameter segmentation threshold of described segmentation threshold determining unit 12Described image is divided into background area and contaminated area;
Characteristic parameter adjustment unit 14, for the average of the characteristic parameter based on described contaminated area, the spy of described background areaLevy average and the variance of parameter and adjust the characteristic parameter that needs the pixel of repairing in described contaminated area.
As previously mentioned, described image can be gray level image, and now described characteristic parameter is gray value. Described image also canThink coloured image, described characteristic parameter is luminance component or chromatic component, or luminance component and chromatic component.
In one embodiment, described characteristic parameter segmentation threshold comprises that characteristic parameter is cut apart the upper limit and characteristic parameter is cut apartLower limit, described contaminated area comprises He An contaminated area, bright contaminated area; The characteristic parameter of the pixel of described bright contaminated area is higher than describedCharacteristic parameter is cut apart the upper limit; The characteristic parameter of the pixel of described dark contaminated area is cut apart lower limit lower than described characteristic parameter.
In another kind of embodiment, the characteristic parameter of the pixel of described background area is cut apart threshold less than or equal to characteristic parameterValue; The characteristic parameter of the pixel of described contaminated area is higher than characteristic parameter segmentation threshold.
In another embodiment, the characteristic parameter of the pixel of described background area is cut apart threshold greater than or equal to characteristic parameterValue; The characteristic parameter of the pixel of described contaminated area is lower than characteristic parameter segmentation threshold.
In one embodiment, please refer to Fig. 5, Fig. 5 is the detailed description of the invention of the prosthetic device of a kind of image of the present inventionThe structural representation of middle characteristic parameter adjustment unit, described characteristic parameter adjustment unit 14 can comprise:
Average and variance computation subunit 141, for calculating described average and variance;
Judge subelement 142, for judging contaminated area according to the result of calculation of described average and variance computation subunit 141The middle pixel that needs reparation;
Adjust subelement 143, need the characteristic parameter of the pixel of repairing for adjusting described contaminated area.
In described average and variance computation subunit 141, the average of described characteristic parameterDescribed feature ginsengThe variance of numberWherein, the characteristic parameter that Ti is i pixel, the number that N is pixel. For the back of the bodyScenic spot, the average of described characteristic parameterThe variance of described characteristic parameterWherein, described in Ti isThe characteristic parameter of i pixel of background area, the number of the pixel that N is described background area; For contaminated area, described feature ginsengThe average of numberThe variance of described characteristic parameterWherein, Ti is i of described contaminated area pixelThe characteristic parameter of point, the number of the pixel that N is described contaminated area.
In described judgement subelement 142, default recovery strength factor-alpha. Described recovery strength factor-alpha characterizes and background areaThe extreme Polluted area that characteristic parameter differs in much extent and scopes will be repaired. Recovery strength factor-alpha depends on what need were repairedThe characteristic parameter difference degree of described contaminated area and described background area, described recovery strength factor-alpha span is [1,3], exampleAs being 1.0,1.2,1.5,1.8,2.0,2.2,2.5,2.8,3.0 etc., difference is larger, and value should be larger. WhenOrTime, judge characteristic parameter and the described back of the body of this pixel in described contaminated areaThe characteristic parameter difference of the pixel at scenic spot is excessive, need to repair; When?Judge that the characteristic parameter difference of pixel in the characteristic parameter of this pixel in described contaminated area and described background area is in tolerableIn scope, do not need to repair.
For described adjustment subelement 143, in one embodiment, whenTime, described characteristic parameterAdjustment unit 14 basesAdjust the characteristic parameter of described contaminated area, wherein, ToldFor described dirtThe characteristic parameter of the pixel that dyes district before adjustment; TnewFor the pixel of the described contaminated area characteristic parameter after adjustment;For adjusting the average of characteristic parameter of front described contaminated area pixel;For the characteristic parameter of described background area pixel allValue; σbkgFor the variance of the characteristic parameter of described background area pixel; α is the described recovery strength factor; Abs represents to ask absolute value.
In one embodiment, whenTime, described characteristic parameter adjustment unit 14 basesAdjust described contaminated area characteristic parameter, wherein, ToldFor the pixel of described contaminated area is being adjustedCharacteristic parameter before whole; TnewFor the pixel of the described contaminated area characteristic parameter after adjustment;For adjusting front described pollutionThe average of the characteristic parameter of district's pixel;For the average of the characteristic parameter of described background area pixel; σbkgFor described backgroundThe variance of the characteristic parameter of district's pixel; α is the described recovery strength factor; Abs represents to ask absolute value.
Correspondingly, technical solution of the present invention also provides a kind of terminal, comprises the prosthetic device of described image. Described terminal canTo be mobile terminal, panel computer, car-mounted terminal etc.
In one embodiment, described terminal can also comprise image acquisition unit. Described image acquisition unit can beBe directly used in and gather the camera of image, can be also can with the receiving terminal of other foreign mediums or devices communicating. Described figureObtain after image as acquiring unit, original image is sent to the prosthetic device of described image, this device is with region unit in imageFor repairing on basis.
In one embodiment, described terminal can also comprise display unit. Described display unit can be for showing instituteState the image that image acquisition unit obtains, also can be for showing the image after the treating apparatus of described image is repaired.
In sum, the embodiment of the present invention proposes a kind of image repair method, device and terminal have been utilized histogram systemMeter characteristic is cut apart image-region, and repairs contaminated area based on background area. This image repair technology based on region greatly reducesAmount of calculation, simple and fast while realization, possesses stronger adaptive ability, can be applicable to the occasion that handling property is lower, asMobile-terminal platform etc.; Meanwhile, avoided conventional images restorative procedure to repair the local color causing taking pixel as unitInconsistent and affect overall perception, ensure region global consistency, natural texture details perception in reserve area.
Although the present invention with preferred embodiment openly as above, it is not for limiting the present invention, any this areaTechnical staff without departing from the spirit and scope of the present invention, can utilize the method for above-mentioned announcement and technology contents to thisBright technical scheme is made possible variation and amendment, and therefore, every content that does not depart from technical solution of the present invention, according to the present inventionTechnical spirit any simple modification, equivalent variations and modification that above embodiment is done, all belong to technical solution of the present inventionProtection domain.