Summary of the invention
For the defect existed in prior art, technical matters to be solved by this invention is to provide high, the effective image texture repair method of a kind of efficiency and system.
For solving the problems of the technologies described above, the technical solution used in the present invention is as follows:
A kind of image texture repair method, comprises the following steps:
Determine the region to be adjusted needing to carry out texture repairing in image;
Employing can make the filtering method that image brightness distribution is consistent with grain distribution carry out filtering to described region to be adjusted, obtains the filtered brightness value of each pixel in described region to be adjusted;
Fusion is weighted to the filtered brightness value of each pixel and original luminance value in described region to be adjusted, obtains the image after repairing.
Image texture repair method as above, wherein, the process of filtering comprises the following steps:
Determine sample areas, and calculate target mean and the target variance of described sample areas;
Travel through all pixels in described region to be adjusted, calculate neighboring mean value and the neighborhood variance of each pixel; The span of the described radius of neighbourhood is between 30 pixel ~ 500 pixels;
According to target mean and the target variance of described sample areas, and the original luminance value of each pixel, neighboring mean value and neighborhood variance in described region to be adjusted, calculate the filtered brightness value of each pixel in described region to be adjusted.
Image texture repair method as above, wherein, adopts the filtered brightness value of each pixel in region to be adjusted described in following formulae discovery:
Wherein, I
w(i, j) represents filtered brightness value, M
dand S
drepresent target mean and target variance respectively, I (i, j) represents at (i, j) original luminance value of place's pixel, M (i, j) and S (i, j) neighboring mean value and the neighborhood variance of (i, j) place pixel is represented respectively.
Image texture repair method as above, if described image exists dark side, then the distribution of the overall brightness of appointed area in image is first adjusted to and distributes consistent with the overall brightness of sample areas by described method.The process of described adjustment comprises the following steps:
Specifying in image and need region and the sample areas of carrying out brightness adjustment, being designated as appointed area by needing the region of carrying out brightness adjustment in image;
Calculate the histogram of described sample areas and appointed area respectively, column hisgram of going forward side by side mates, and obtains the brightness mapping relations from described appointed area to described sample areas;
Described brightness mapping relations are applied to each pixel in described appointed area.
Image texture repair method as above, wherein, the process of Weighted Fusion comprises the following steps:
Calculate the gradient modulus value of each pixel in described region to be adjusted, and calculate the Sigmoid functional value about described gradient modulus value, described Sigmoid function is as follows:
Wherein, || G (i, j) || be independent variable, represent the gradient-norm of (i, j) place pixel on image; α and β is constant, preferably, and α=-0.15, β=-10, the respectively pace of change of control Sigmoid curve and degrees of offset;
To each pixel in described region to be adjusted, carrying out with described Sigmoid functional value is weight about the Weighted Fusion of original luminance value and filtered brightness value.Fusion formula is as follows:
I′(i,j)=ζ(||G(i,j)||)×I
w(i,j)+(1-ζ(||G(i,j)||))×I(i,j)
Wherein, I ' (i, j) represents the end value merging rear (i, j) place pixel, I
w(i, j) represents the filtered brightness value of (i, j) place pixel, and I (i, j) represents the original luminance value of (i, j) place pixel.
A kind of image texture repair method, comprises the following steps:
Determine the region to be adjusted and the sample areas that need to carry out texture repairing in image;
Calculate the histogram of described sample areas;
Travel through all pixels in described region to be adjusted, each pixel is handled as follows: the histogram 1. calculating neighborhood of pixel points, 2. according to the brightness mapping relations of the histogram of described sample areas and the histogram calculation neighborhood of pixel points of neighborhood and described sample areas, the brightness mapping value of all pixels in neighborhood is 3. calculated according to described brightness mapping relations; Preferably, the span of the described radius of neighbourhood is between 20 pixel ~ 100 pixels;
After traversal terminates, one group of brightness mapping value that each pixel is tried to achieve is weighted on average, obtains the final brightness mapping value of this pixel;
Fusion is weighted to the final brightness mapping value of each pixel in described region to be adjusted and original luminance value, obtains the image after repairing.
Image texture repair method as above, wherein, the process of Weighted Fusion comprises the following steps:
Calculate the gradient modulus value of each pixel in described region to be adjusted, and calculate the Sigmoid functional value about described gradient modulus value, described Sigmoid function is as follows:
Wherein, || G (i, j) || be independent variable, represent the gradient-norm of (i, j) place pixel on image; α and β is constant, α=-0.15, β=-30, respectively the pace of change of control Sigmoid curve and degrees of offset;
To each pixel in described region to be adjusted, carrying out with described Sigmoid functional value is weight about the Weighted Fusion of original luminance value and described final brightness mapping value.Fusion formula is as follows:
I′(i,j)=ζ(||G(i,j)||)×I
w(i,j)+(1-ζ(||G(i,j)||))×(i,j)
Wherein, I ' (i, j) represents the end value merging rear (i, j) place pixel, I
w(i, j) represents the final brightness value of (i, j) place pixel during step 4., and I (i, j) represents the original luminance value of (i, j) place pixel.
A kind of image texture repair system, comprises the determining device for determining the region to be adjusted needing to carry out texture repairing in image;
The image brightness distribution filtering method consistent with grain distribution can be made to treat adjustment region carry out filtering, obtain the filter of brightness value after each pixel filtering in region to be adjusted for adopting;
The fusing device of fusion is weighted for treating the filtered brightness value of each pixel and original luminance value in adjustment region.
Image texture repair system as above, wherein, filter comprises the determining unit for determining sample areas;
For traveling through the Traversal Unit of all pixels in region to be adjusted;
For calculating target mean and the target variance of sample areas, and calculate the neighboring mean value of each pixel and the first computing unit of neighborhood variance;
For according to the target mean of sample areas and target variance, and the original luminance value of each pixel, neighboring mean value and neighborhood variance in region to be adjusted, calculate the second computing unit of the filtered brightness value of each pixel in region to be adjusted.
Image texture repair system as above, also comprises and the distribution of the overall brightness in described region to be adjusted is adjusted to the consistent brightness adjusting device that to distribute with the overall brightness of the sample areas of specifying.
Image texture repair system as above, wherein, brightness adjusting device comprises being used to specify in image and needs to carry out the region of brightness adjustment and the designating unit of sample areas, is designated as appointed area by needing the region of carrying out brightness adjustment in image;
For calculating histogrammic 3rd computing unit of sample areas and appointed area;
For mating appointed area histogram and sample areas histogram, obtain the matching unit of the brightness mapping relations from appointed area to sample areas;
For brightness mapping relations being applied to the applying unit of each pixel in appointed area.
Image texture repair system as above, wherein, fusing device comprises the gradient modulus value for calculating each pixel in described region to be adjusted, and calculates the 4th computing unit about the Sigmoid functional value of described gradient modulus value;
For treating each pixel in adjustment region, the integrated unit about the Weighted Fusion of brightness value after original luminance value and filtering that to carry out with Sigmoid functional value be weight.
A kind of image texture repair system, comprises and needs to carry out the region to be adjusted of texture repairing and the determining device of sample areas in image for determining;
For calculating sample areas histogram and histogrammic first calculation element of neighborhood of pixel points;
For traveling through the traversal device of all pixels in region to be adjusted;
For the brightness mapping relations according to described sample areas histogram and neighborhood histogram calculation neighborhood of pixel points and sample areas, all pixel intensity mapping value in neighborhood are calculated according to brightness mapping relations, and after traversal terminates, one group of brightness mapping value that each pixel is tried to achieve is weighted on average, obtains the second calculation element of the final brightness mapping value of this pixel;
Final brightness mapping value and original luminance value for treating each pixel in adjustment region are weighted the fusing device of fusion.
Image texture repair system as above, wherein, fusing device comprises the gradient modulus value for calculating each pixel in described region to be adjusted, and calculates the computing unit about the Sigmoid functional value of described gradient modulus value;
For treating each pixel in adjustment region, carrying out with Sigmoid functional value is weight about the integrated unit of the Weighted Fusion of original luminance value and described final brightness mapping value.
The method of the invention and system, the methods such as Wallis filtering, local average Histogram Matching have been incorporated into class image repair field, after image being carried out to the mode such as Wallis filtering, local average Histogram Matching and adjusting, for weight, fusion is weighted to image and original image after adjustment with Sigmoid functional value again, achieves the reparation of image texture well.And, compared with manual repair method, drastically increase the remediation efficiency of image texture.Test the speed through experiment, under Pentium double-core, 3.46G memory environment, to the image of 10000 × 10000, the processing time is substantially within 1 minute.
Embodiment
The present invention be directed to the part class problem existed in image and the solution proposed, its core concept is: after the mode such as filtering, local average Histogram Matching of carrying out image adjusts, again with Sigmoid functional value for weight is weighted fusion to image and original image after adjustment, thus realize the object of repairing image texture preferably.Below in conjunction with accompanying drawing, the specific embodiment of the present invention is described in detail.
Embodiment 1
Class is the class problem often occurred in printed matter image, even if image brightness distribution is unified, still may there is local unit and assemble line after connecting the operations such as solarization, form the problem in outstanding unsightly region.For this problem, need to carry out local directed complete set to image, consistent with the grain distribution realizing entire image.But to the image containing large structural texture, realize grain distribution consistent while, often need the structure keeping image well.Present embodiment, for above-mentioned image class problem, provides a kind of image texture repair system and method.
As shown in Figure 1, in present embodiment, image texture repair system comprises brightness adjusting device 15, determining device 11, filter 12 and fusing device 13.As shown in Figure 2, brightness adjusting device 15 comprises designating unit 151, the 3rd computing unit 152, matching unit 153 and applying unit 154.As shown in Figure 3, filter 12 comprises determining unit 121, Traversal Unit 122, first computing unit 123 and the second computing unit 124.As shown in Figure 4, fusing device 13 comprises the 4th computing unit 131 and integrated unit 132.
Brightness adjusting device 15 distributes consistent for the distribution of the overall brightness of appointed area in image being adjusted to the overall brightness of sample areas.Wherein: designating unit 151 is used to specify in image the region and sample areas that need to carry out brightness adjustment, is designated as appointed area by needing the region of carrying out brightness adjustment in image; 3rd computing unit 152 is for the histogram of the histogram and appointed area that calculate sample areas; Matching unit 153, for mating appointed area histogram and sample areas histogram, obtains the brightness mapping relations from appointed area to sample areas; Applying unit 154 is for being applied to each pixel in appointed area by brightness mapping relations.
Determining device 11 is for determining the region to be adjusted needing to carry out texture repairing in image.
Filter 12 can make the image brightness distribution filtering method consistent with grain distribution treat adjustment region to carry out filtering, obtain the filtered brightness value of each pixel in region to be adjusted for adopting.Wherein: determining unit 121 is for determining sample areas; Traversal Unit 122 is for traveling through all pixels in region to be adjusted; First computing unit 123 for calculating target mean and the target variance of sample areas, and calculates neighboring mean value and the neighborhood variance of each pixel; Second computing unit 124 is for according to the target mean of sample areas and target variance, and the original luminance value of each pixel, neighboring mean value and neighborhood variance in region to be adjusted, calculates the filtered brightness value of each pixel in region to be adjusted.
Fusing device 13 is weighted fusion for treating the filtered brightness value of each pixel and original luminance value in adjustment region.Wherein: the 4th computing unit 131 for calculating the gradient modulus value of each pixel in described region to be adjusted, and calculates the Sigmoid functional value about described gradient modulus value; Integrated unit 132 is for treating each pixel in adjustment region, and carrying out with Sigmoid functional value is weight about the Weighted Fusion of original luminance value and filtered brightness value.
As shown in Figure 5, the method adopting said system to repair image texture comprises the following steps:
(1) distribution of the overall brightness of appointed area in image is adjusted to and distributes consistent with the overall brightness of sample areas by brightness adjusting device 15.
Brightness adjustment is the solution proposed for the dark side problem in image class problem, if therefore there is not dark side in image, then this step can be omitted.Dark side has the reasons such as reflecting effect to cause due to out-of-flatness when the splicing of scintigram in batches, the scanning of original copy stock, scanning thing material itself.The dark side existed in image has the feature of bulk distribution, is therefore easy to manually choose out the image-region with consistent brightness.Based on These characteristics, in this step, the object of brightness adjustment operation is: the Luminance Distribution in the region of user in image being specified adjusts to the effect consistent with the sample areas that user provides.
As shown in Figure 6, the process of brightness adjustment comprises the following steps:
1. designating unit 151 specifies in image the region and sample areas that need to carry out brightness adjustment, is designated as appointed area by needing the region of carrying out brightness adjustment in image.
Target effect region for reference when sample areas herein refers to and carries out brightness adjustment, it can be the regional area in region to be adjusted, also can be other image-region extra-regional to be adjusted in image, can also be other image-regions outside this image, need pre-determine before treatment.
2. the 3rd computing unit 152 calculates sample areas histogram and appointed area histogram respectively, and matching unit 153 carries out Histogram Matching, obtains the brightness mapping relations from appointed area to sample areas.
3. brightness mapping relations are applied to each pixel in appointed area by applying unit 154, obtain the image that Luminance Distribution is consistent with sample areas.
(2) determining device 11 determines the region to be adjusted needing to carry out texture repairing in image.
Because class is the class problem often occurred in printed matter image, even if adopt the brightness adjustment mode in step (1) to achieve the unification of integral image Luminance Distribution, still may there is local unit and assemble line after connecting the operations such as solarization, form the problem in outstanding unsightly region.For this problem, need to carry out local directed complete set to image, consistent with the grain distribution realizing entire image.
(3) filter 12 adopts and the filtering method that image brightness distribution is consistent with grain distribution can be made to carry out filtering to described region to be adjusted, obtains the filtered brightness value of each pixel in described region to be adjusted.
For the image containing large structural texture, usually wish to realize grain distribution consistent while, keep the structure of image well.For this reason, present embodiment adopts Wallis filtering method to treat adjustment region to carry out filtering.
Wallis filtering a kind ofly highly effectively realizes the image brightness distribution filtering method consistent with grain distribution, and fundamental formular is as follows:
Wherein, I
w(i, j) represents filtered brightness value, M
dand S
drepresent target mean and target variance respectively, I (i, j) represents at (i, j) original luminance value of place's pixel, M (i, j) and S (i, j) neighboring mean value and the neighborhood variance of (i, j) place pixel is represented respectively.
According to above-mentioned formula, on the image after adjustment, each pixel neighborhood of a point has approximate consistent average M
dwith variance S
d, same average achieves the brightness uniformity of entire image, and same variance achieves the consistent of image texture distribution, and the selection of contiguous range determines the maintenance degree of picture structure.
As shown in Figure 7, concrete filtering comprises the following steps:
1. determining unit 121 determines sample areas, and the first computing unit 123 calculates average and the variance of sample areas, and the average of sample areas is called target mean, and the variance of sample areas is called target variance.
Target effect region for reference when sample areas herein refers to and carries out filtering, determined by determining unit 121 by user, can be different from the sample areas of above-mentioned brightness adjustment, but can be the regional area in region to be adjusted equally, also can be other image-region extra-regional to be adjusted in image, can also be other image-regions outside this image, need pre-determine before treatment.
2. Traversal Unit 122 travels through all pixels in region to be adjusted, and the first computing unit 123 calculates neighboring mean value and the neighborhood variance of each pixel.
The impact of selection on filter effect of the radius of neighbourhood is great, if wish that picture structure is average as far as possible, and does not need to keep picture structure, then less radius can be adopted to carry out filtering.The effective range of the general radius of neighbourhood is between 30 pixel ~ 500 pixels, and the too little meeting of radius causes the structural penalties of image serious, and radius then makes Adjustment effect not obvious too greatly.In present embodiment, the radius of neighbourhood gets 100 pixels, and namely neighborhood is the square of 201 × 201, to ensure the maintenance to picture structure.
3. the second computing unit 124 is according to the target mean of sample areas and target variance, and the original luminance value of each pixel, neighboring mean value and neighborhood variance in region to be adjusted, adopt above-mentioned Wallis Filtering Formula to calculate the filtered brightness value of each pixel in region to be adjusted.
(4) fusing device 13 is treated the filtered brightness value of each pixel and original luminance value in adjustment region and is weighted fusion.
Adopt original Wallis filtering method can realize image texture and brightness consistance distribution on the whole, but there is following two problems:
1. according to the texture feature of sample areas, may need to increase picture contrast, and to image natively existing the regional area of larger contrast, when widening contrast further, may Patch effect be occurred.
The formation of patch, because the brightness in certain block region in image and mean flow rate differ greatly, namely the region that local is very bright or dark, increases according to target average brightness this value again or subtracts and can block because exceeding brightness range and obtain the same brightness value equal with the maximum value or minimum value of brightness range.In addition, this region is the stabilized zone close with neighborhood, and thus the adjusted value of whole neighborhood is all very bright or very dark value, thus forms patch.
2. the effect of Wallis filtering be realize the brightness of image local and variance completely the same, processing procedure does not consider any structural information, thus may break the architectural feature of changing image.For this reason, be necessary to protect the stabilized zone of characterizing image structures in image, to realize the effective maintenance to picture structure.
Accordingly, the method that present embodiment adopts Wallis filtered image and original image to be weighted fusion solves above-mentioned two problems.
Because patch is a very little part in image, most end value should be the result of Wallis filtering, therefore needs to adopt the weighting function that can keep Wallis filter result as far as possible.In present embodiment, adopt the following Sigmoid weighting function about gradient-norm:
In above formula, || G (i, j) || be independent variable, represent the gradient-norm of (i, j) place pixel on image; α and β is constant, respectively the pace of change of control Sigmoid curve and degrees of offset.The value of α and β can change according to actual needs, in present embodiment, require to keep image original value at the very little place of gradient modulus value (flat site namely in image), and the region employing filter result value that other gradient modulus value are larger, therefore in order to while removing patch as far as possible, retain the result of Wallis filtering, adopt and rise quickly, have the following parameter close to null value weight near 0: α=-0.15, β=-10, the Sigmoid curve map of its correspondence as shown in Figure 8.
In present embodiment, the process of Weighted Fusion is as follows:
First the 4th computing unit 131 calculates the gradient modulus value of each pixel in region to be adjusted, then according to the Sigmoid functional value of above-mentioned formulae discovery about described gradient modulus value.The gradient modulus value calculating each pixel is herein carried out based on region to be adjusted pixel value before adjustment (i.e. original pixel value), because weight considers from the stability of image itself.
Then integrated unit 132 treats each pixel in adjustment region, and carrying out with Sigmoid functional value is weight about the Weighted Fusion of original luminance value and filtered brightness value, and its fusion formula is as follows:
I′(i,j)=ζ(||G(i,j)||)×I
w(i,j)+(1-ζ(||G(i,j)||))×I(i,j)
Wherein, the end value of (i, j) place pixel after I ' (i, j) represents image co-registration, I
w(i, j) represents the filter result value of (i, j) place pixel, and I (i, j) represents the original luminance value of (i, j) place pixel.
Embodiment 2
Some image has consistance texture, this type of image is easily after the operations such as image mosaic, sparse or the dense areas combine of local grain becomes larger region and forms the Luminance Distribution such as patch and the inconsistent class region of grain distribution, forms " hickie " phenomenon as ever-present in printed matter image by sparse texture set.Present embodiments provide for a kind of the image texture repair system of class problem and method for there is local luminance or the inconsistent distribution of texture in consistance texture image.
As shown in Figure 9, in present embodiment, image texture repair system comprises determining device 111, first calculation element 112, traversal device 113, second calculation element 114 and fusing device 115.As shown in Figure 10, fusing device 115 comprises computing unit 1151 and integrated unit 1152.
Determining device 111 is for determining the region to be adjusted and the sample areas that need to carry out texture repairing in image.First calculation element 112 is for calculating sample areas histogram and neighborhood of pixel points histogram.Traversal device 113 is for traveling through all pixels in region to be adjusted.Second calculation element 114 is for the brightness mapping relations according to sample areas histogram and neighborhood histogram calculation neighborhood of pixel points and sample areas, all pixel intensity mapping value in neighborhood are calculated according to brightness mapping relations, and after traversal terminates, one group of brightness mapping value that each pixel is tried to achieve is weighted on average, obtains the final brightness mapping value of this pixel.Fusing device 115 is weighted fusion for the final brightness mapping value and original luminance value treating each pixel in adjustment region.Wherein: computing unit 1151 for calculating the gradient modulus value of each pixel in region to be adjusted, and calculates the Sigmoid functional value about described gradient modulus value; Integrated unit 1152 is for treating each pixel in adjustment region, and carrying out with Sigmoid functional value is weight about the Weighted Fusion of original luminance value and final brightness mapping value.
As shown in figure 11, the method adopting said system to carry out image texture reparation comprises the following steps:
(1) determining device 111 determines the region to be adjusted and the sample areas that need to carry out texture repairing in image.Target effect region for reference when described sample areas refers to and carries out texture repairing, it can be the regional area in region to be adjusted, also can be other image-region extra-regional to be adjusted in image, can also be other image-regions outside this image, need pre-determine before treatment.
(2) first calculation elements 112 calculate the histogram of sample areas.
(3) travel through device 113 and travel through all pixels in region to be adjusted, each pixel is handled as follows:
1. the first calculation element 112 calculates the histogram of neighborhood of pixel points; The effective range of the general radius of neighbourhood is between 20 pixel ~ 100 pixels, and the too little meeting of radius causes Neighborhood Statistics information inaccurate and makes Adjustment effect deviation too large, and radius is too large then because neighborhood information does not have singularity and make Adjustment effect not obvious.In present embodiment, the radius of neighbourhood gets 50 pixels, and namely neighborhood is the square of 101 × 101;
2. the second calculation element 114 is according to the histogram of sample areas and the histogram calculation neighborhood of pixel points of neighborhood and the brightness mapping relations of sample areas;
3. the brightness mapping value of all pixels in neighborhood is calculated according to brightness mapping relations;
(4), after traversal terminates, the second calculation element 114 is weighted on average one group of brightness mapping value that each pixel is tried to achieve, and obtains the final brightness mapping value of this pixel.
(5) fusing device 115 is weighted fusion to the final brightness mapping value of each pixel in described region to be adjusted and original luminance value.
Because the textured inner of such image and background area are all stabilized zone, stabilized zone is without the need to adjusting again.Therefore, present embodiment adopts and ensures that stabilized zone does not adjust based on the mode of the Weighted Fusion of image and original image after the adjustment of Sigmoid function.
First, computing unit 1151 calculates the gradient modulus value of each pixel in region to be adjusted, then according to the Sigmoid functional value of above-mentioned formulae discovery about described gradient modulus value.Described Sigmoid function is as follows:
In above formula, || G (i, j) || be independent variable, represent the gradient-norm of (i, j) place pixel on image; α and β is constant, respectively the pace of change of control Sigmoid curve and degrees of offset.Have in the class image repair of consistance texture because present embodiment is applied to usually, it focuses on the adjustment to transitional region in image, compared to embodiment 1, while requiring that Sigmoid functional value comparatively fast changes with gradient modulus value, variation range is also larger, therefore, α=-0.15, β=-30.
Then, integrated unit 1152 treats each pixel in adjustment region, and carrying out with Sigmoid functional value is weight about the Weighted Fusion of original luminance value and final brightness mapping value, and its fusion formula is as follows:
I′(i,j)=ζ(||G(i,j)||)×I
w(i,j)+(1-ζ(||G(i,j)||))×I(i,j)
Wherein, the end value of (i, j) place pixel after I ' (i, j) represents image co-registration, I
w(i, j) represents the final brightness mapping value of (i, j) place pixel after step (3) process, and I (i, j) represents the original luminance value of (i, j) place pixel in image.
Obviously, those skilled in the art can carry out various change and modification to the present invention and not depart from the spirit and scope of the present invention.Such as, fusion method can adopt any fusion method meeting specific image, and Wallis function and Sigmoid function also can adopt other variants based on basic function.Like this, if these amendments of the present invention and modification belong within the scope of the claims in the present invention and equivalent technology thereof, then the present invention is also intended to comprise these change and modification.