Based on the two yardstick image de-noising methods of the rhombus template of golden section proportion
Technical field
The present invention relates to the two yardstick image de-noising methods of a kind of rhombus template based on golden section proportion, belong to technical field of image processing.
Background technology
Along with computer technology, rapid development of network technology, the information transmitted amount is sharp increase thereupon also.Image is the main information carrier, so various image processing techniques has also obtained corresponding development.Image often is subjected to imaging device in digitizing and transmission course and external environment condition is disturbed, and makes to comprise noise in the image.Noisy image can to successive image use and analysis brings adverse effect.So image denoising is an important research content of Digital Image Processing.Common denoising method is to realize by carry out various calculating (filtering) based on the pixel of a specific template inside at present.
Wherein, more common template has square n * n template, cruciform template, x shape template etc.Wherein square template is most widely used, and when handling some pixels, the pixel of getting in its n * n square modules participates in filtering calculating.It has taken full advantage of all pixels in this neighborhood of pixel points, and design relatively meets people's normal thinking like this, also is the most initial template, can obtain reasonable effect under many circumstances, but may occur the edge as shortcomings such as noise filtering fall; Cruciform template and x shape template can be avoided the situation at filtering edge to a certain extent, better suppress noise, but have also brought the bigger inhibition to signal simultaneously, need additional alternate manner that it is further optimized.
More common filtering method is medium filtering.The ultimate principle of tradition median filtering algorithm is: to any pixel in the image, all gray values of pixel points in its n * n square template are sorted, get intermediate value then as the final gray-scale value of this pixel.The tradition median filtering algorithm replaces gray values of pixel points without mean value, has kept edge of image and profile, but more time-consuming aspect ordering.A lot of improvement algorithms to medium filtering have also been derived on this basis, as median filtering algorithm fast, utilize divide and conquer that data are carried out block sorting, though the not necessarily real intermediate value that obtains, but it can remove noise under the prerequisite that does not influence picture quality, and reached the denoising effect the same with theoretical medium filtering, and improved filtering speed greatly, saved working time.The self-adaptive switch interpolation algorithm detects notch noise according to the characteristics of salt-pepper noise by maximum value minimal value and piece uniformity coefficient, then according to the noise profile situation, utilizes Lagrange's interpolation and adaptive median filter to come filtering noise.Experimental result shows, this method is 10%~80% noise image to salt-pepper noise density, can suppress salt-pepper noise more effectively and keep the detailed information of image well, and filtering performance is more better than traditional median filter method.
Summary of the invention
Technical matters to be solved by this invention provides the two yardstick image de-noising methods of a kind of rhombus template based on golden section proportion.
The technical solution adopted for the present invention to solve the technical problems is as follows:
Concrete steps of the present invention are as follows:
(1) reads in a two field picture, make that first pixel is current pixel point;
Whether (2) judge current pixel point is noise spot:
When being noise spot, described current pixel point carried out for (3) step;
When described current pixel point is not noise spot, carried out for (2.1) step;
(2.1) putting next pixel is current pixel point, returns for (2) step then;
Judge the method for noise spot for selecting interval method, namely gray values of pixel points be positioned at (0-5) or (250-255) between be noise spot, otherwise be signaling point;
(3) centered by noise spot, construct a rhombus template based on golden section proportion:
The major axis a of described rhombus template is transverse axis, and minor axis b is the longitudinal axis, and major axis a is 1:0.618 with the ratio of minor axis b;
Determine initial rhombus template then, the major axis a of initial rhombus template includes the length of 3 complete pixels, and the minor axis b of initial rhombus template comprises the length of 3*0.618=1.854 pixel;
When the pixel of image boundary is noise spot, then ignore for the part that exceeds image-region in the rhombus template of centered by this pixel, constructing, overflow problem takes place when preventing from exceeding image boundary;
(4) whether the number of judging the signaling point in the initial rhombus template is less than 2:
When the number of the signaling point in the initial rhombus template is not less than 2, carried out for (5) step;
When the number of the signaling point in the initial rhombus template during less than 2, carried out for (4.1) step;
(4.1) the rhombus module expands:
The extending method of rhombus module is as follows:
During each the expansion, the signaling point on the transverse axis a is increased by 2, longitudinal axis b presses on golden section proportion and the transverse axis a and expands simultaneously;
(5) utilize the characteristics of intensity profile in the rhombus template, calculate the gray scale weight P of each signaling point in the rhombus template by following formula (1)
i, and to P
iSort from big to small:
P
i=S
i/N (1)
In the formula, S
iGray-scale value C for signaling point in the rhombus template
iThe number of times that in the rhombus template, occurs;
N is total number of signaling point in the rhombus template;
(6) whether judge noise density≤50%:
(6.1) when noise density r%≤50%, ∑ P before then getting
iCalculate near the signaling point participation filtering of (1-r%); Carried out for (7) step then;
(6.2) when noise density r%>50%, then get back ∑ P
iCalculate near the signaling point participation filtering of (1-r%); Carried out for (7) step then;
(7) calculate the distance weighting D that each participates in the signaling point of calculating
i:
Utilize participate in the rhombus template signaling point that calculates to the inverse of the distance of rhombus template center's point namely according to the following equation (2) calculate the distance weighting D of each signaling point
i:
D
i=(X
i 2+Y
i 2)
-1/2 (2)
In the formula, X
i, Y
iBe respectively horizontal ordinate and the ordinate of signaling point;
(8) calculate the total weights W of normalization that each participates in the signaling point of calculating according to following formula (3)
i:
W
i=P
i*D
i/∑P
i*D
i (3)
(9) remove noise:
Calculate the amended gray-scale value C of rhombus template center's pixel by following formula (4)
i:
C
i =∑W
i*C
i*H
i (4)
In the formula, H
iIt is the ratio that i signaling point participates in calculating;
H
iComputing method as follows: the ratio of i signaling point shared area and the area of a complete signal point in the rhombus module;
(10) judge whether all pixels dispose:
When all pixels do not dispose, returned for (2.1) step;
When all pixels dispose, entered for (11) step;
(11) denoising finishes.
The rhombus template that the present invention proposes has been considered width and the height ratio of existing screen and video image etc., generally all be that width is greater than height, so adopt the transverse axis rhombus template longer than the longitudinal axis, and add golden section thought, so more meet people's visual custom.Experimental result shows that rhombus template filter effect is better than additive method.Utilize the two yardsticks of gray scale weight and distance weighting to each signaling point weighting simultaneously, it is reasonable more, comprehensive to consider, has further guaranteed filter effect preferably.
Beneficial effect of the present invention is as follows:
(1) advantage of employing rhombus template:
A, compare with square template, all signaling points that participate in calculating in the rhombus template are less to the distance variance of central point, avoid the signaling point of decentering point hypertelorism to participate in filtering calculating as far as possible, meet generally speaking the more strong actual conditions of the more near gray-scale value correlativity of distance more.
The pixel that laterally comprises in b, the rhombus template is more than the pixel that vertically comprises, and more meets people's visual custom.
C, golden section are a kind of mathematical proportionate relationships, have strict proportionality, artistry, concordance, and aesthetic values are richly stored with.0.618 be acknowledged as the ratio numeral that has aesthetic Significance most, be the ratio that can cause people's aesthetic feeling, the ratio of the pixel number that laterally comprises in the rhombus template and the pixel number that vertically comprises is 1:0.618, has taken full advantage of the classical theory of mathematics.
D, in filtering, consider signaling point (non-noise spot) number in the rhombus template.Number very little, filter effect is bad naturally, when the number of signaling point in the rhombus template does not reach minimum value 2, expands the rhombus template automatically, has adaptivity.
E, experimental result show that the present invention can handle the low-density noise, also can handle the high density noise, and noise density is more high, and effect is more good relatively.
If the pixel of f image boundary is noise, then ignore the overflow problem that has taken place when effectively having prevented from being beyond the boundary for the part that exceeds image-region in the rhombus template of centered by this pixel, constructing.
(2) take all factors into consideration gray scale and two kinds of yardsticks of distance as the advantage of filtering weighting:
A, gray scale weight: consider the probability distribution of the gray-scale value of signaling point in the rhombus template, the distribution of each gray-scale value and inequality in the rhombus template considers during filtering that intensity profile can make filter effect more near real image.
B, distance weighting: in the real image, between the pixel of non-marginal portion, the more near gray-scale value correlativity of distance is more strong, otherwise distance is more far away, and the gray-scale value correlativity is more weak.The inverse of chosen distance of the present invention meets the actual conditions of image as one of weight.
(3) filtering of the present invention is calculated according to noise density and is got part signal point participation calculating, is equivalent to signaling point has been carried out again once filtering, and makes filter effect approach actual original image more.Not only computation complexity be can reduce, and other noises that may exist in the rhombus template and edge effectively reduced to the influence of filter effect.
(4) there is the non-integer pixel point in the border of rhombus template, and these pixels during filtering have taken into full account the spatial coherence between the pixel gray-scale value if signaling point then proportionally participates in calculating.
(5) filtering of rhombus template is compared with square modules filtering, and resulting signal to noise ratio (S/N ratio) has improved (for details see attached table 1) greatly after the rhombus module filtered.
Description of drawings
Fig. 1 is program flow diagram of the present invention.
Fig. 2 (a) is that 3 pixels, the longitudinal axis are the rhombus template of 1.854 pixels for transverse axis.
Fig. 2 (b) is that 5 pixels, the longitudinal axis are the rhombus template of 3.09 pixels for transverse axis.
Fig. 2 (c) is that 7 pixels, the longitudinal axis are the rhombus template of 4.326 pixels for transverse axis.
Fig. 3 (a)~Fig. 3 (p) is that different filtering methods are to the filter effect comparison diagram of different densities noise.
Embodiment
The concrete steps of present embodiment are as follows:
(1) reads in a two field picture, make that first pixel is current pixel point;
Whether (2) judge current pixel point is noise spot:
When being noise spot, described current pixel point carried out for (3) step;
When described current pixel point is not noise spot, carried out for (2.1) step;
(2.1) putting next pixel is current pixel point, returns for (2) step then;
Judge the method for noise spot for selecting interval method, namely gray values of pixel points be positioned at (0-5) or (250-255) between be noise spot, otherwise be signaling point;
(3) centered by noise spot, construct a rhombus template based on golden section proportion:
The major axis a of described rhombus template is transverse axis, and minor axis b is the longitudinal axis, and major axis a is 1:0.618 with the ratio of minor axis b;
Determine initial rhombus template then, the major axis a of initial rhombus template includes the length of 3 complete pixels, and the minor axis b of initial rhombus template comprises the length of 3*0.618=1.854 pixel;
When the pixel of image boundary is noise spot, then ignore for the part that exceeds image-region in the rhombus template of centered by this pixel, constructing, overflow problem takes place when preventing from exceeding image boundary;
(4) whether the number of judging the signaling point in the initial rhombus template is less than 2:
When the number of the signaling point in the initial rhombus template is not less than 2, carried out for (5) step;
When the number of the signaling point in the initial rhombus template during less than 2, carried out for (4.1) step;
(4.1) the rhombus module expands:
The extending method of rhombus module is as follows:
During each the expansion, the signaling point on the transverse axis a is increased by 2, longitudinal axis b presses on golden section proportion and the transverse axis a and expands simultaneously;
(5) utilize the characteristics of intensity profile in the rhombus template, calculate the gray scale weight P of each signaling point in the rhombus template by following formula (1)
i, and to P
iSort from big to small:
P
i=S
i/N (1)
In the formula, S
iGray-scale value C for signaling point in the rhombus template
iThe number of times that in the rhombus template, occurs;
N is total number of signaling point in the rhombus template;
(6) whether judge noise density≤50%:
(6.1) when noise density r%≤50%, ∑ P before then getting
iCalculate near the signaling point participation filtering of (1-r%); Carried out for (7) step then;
(6.2) when noise density r%>50%, then get back ∑ P
iCalculate near the signaling point participation filtering of (1-r%); Carried out for (7) step then;
(7) calculate the distance weighting D that each participates in the signaling point of calculating
i:
Utilize participate in the rhombus template signaling point that calculates to the inverse of the distance of rhombus template center's point namely according to the following equation (2) calculate the distance weighting D of each signaling point
i:
D
i=(X
i 2+Y
i 2)
-1/2 (2)
In the formula, X
i, Y
iBe respectively horizontal ordinate and the ordinate of signaling point;
(8) calculate the total weights W of normalization that each participates in the signaling point of calculating according to following formula (3)
i:
W
i=P
i*D
i/∑P
i*D
i (3)
(9) remove noise:
Calculate the amended gray-scale value C of rhombus template center's pixel by following formula (4)
i:
C
i =∑W
i*C
i*H
i (4)
In the formula, H
iIt is the ratio that i signaling point participates in calculating;
H
iComputing method as follows: the ratio of i signaling point shared area and the area of a complete signal point in the rhombus module;
Be example explanation H with Fig. 2 (a) original template figure
iComputing method (transverse axis is got 3 pixels, the longitudinal axis is got 3*0.618=1.8543 pixel, if each pixel is the length of side is 1 square, serve as with reference to 0 point with template diagonal line intersection, then its left side is 1.5 with right length, upside and downside length are (1.8543-1) ÷ 2, namely 0.927): Fig. 2 (a) first row relates to the pixel that filtering calculates 1, the ratio that participates in calculating is that the interior elemental area of template is divided by the area of whole pixel, because whole pixel point areas is 1, be numerically equal to the interior elemental area of template so participate in the calculating ratio.The area of this pixel in template be isosceles triangle area and rectangular area and, wherein the triangle horizontal direction length of side is 1, corresponding height is 0.927-0.5-(0.618-0.5)=0.309, so triangle area is 0.5 * 1 * 0.309 ≈ 0.155, the rectangular horizontal direction length of side is 1, the vertical direction length of side is 0.618-0.5=0.118, so rectangular area is 1 * 0.118=0.118, i.e. the ratio that this pixel participation is calculated is 0.155+0.118=0.273; The pixel that second row relates to filtering calculating has 3, the ratio that first pixel participates in calculating be isosceles triangle area and rectangular area with, wherein the triangle vertical direction length of side is 1, corresponding height is 1-(0.618-0.5) ÷ 0.618 ≈ 1-0.191=0.809, so triangle area is 0.5 * 1 * 0.809=0.405, the rectangle vertical direction length of side is 1, the horizontal direction length of side is (0.618-0.5) ÷ 0.618 ≈ 0.191, so rectangular area is 1 * 0.191=0.191, so the ratio that second first pixel of row participates in calculating is 0.405+0.191=0.596; Second pixel correspondence of second row be center noise pixel point, its gray-scale value does not participate in calculating, and is 0 so participate in the calculating ratio; The ratio of the 3rd pixel of second row is 0.596 with the ratio of second first pixel of row.The pixel that the third line relates to filtering calculating has 1, and the ratio that participates in calculating is 0.273 with first row.
Fig. 2 (a) is original template figure, and transverse axis is got 3 pixels, and the longitudinal axis is got 3*0.618=1.8543 pixel, and the pixel that first row relates to filtering calculating has 1, participates in the ratio H that calculates
iBe 0.273;
The pixel that second row relates to filtering calculating has 3, participates in the ratio H that calculates
iBe followed successively by 0.596,0,0.596;
The third line is 0.273 with the ratio Hi that first row participates in calculating;
Fig. 2 (b) gets 5 pixels for transverse axis, and the longitudinal axis is got the rhombus template of 5*0.618=3.09 pixel, and the pixel that first row relates to filtering calculating has 3, participates in the ratio H that calculates
iBe followed successively by 0.427,0.868,0.427;
The pixel that second row relates to filtering calculating has 5, participates in the ratio H that calculates
iBe followed successively by 0.596,1,0,1,0.596;
The third line participates in the ratio H that calculates with first row
iBe followed successively by 0.427,0.868,0.427;
Fig. 2 (c) gets 7 pixels for transverse axis, and the longitudinal axis is got the rhombus template of 7*0.618=4.326 pixel;
The pixel that first row relates to filtering calculating has 3, participates in calculating ratio H
iBe followed successively by 0.101,0.509,0.101;
The pixel that second row relates to filtering calculating has 5, participates in calculating ratio H
iBe followed successively by 0.427,0.93,1,0.93,0.427;
The pixel that the third line relates to filtering calculating has 7, participates in calculating ratio H
iBe followed successively by 0.596,1,1,0,1,1,0.596;
Fourth line participates in calculating ratio H with second row
iBe followed successively by 0.427,0.93,1,0.93,0.427;
Fifth line participates in calculating ratio H with first row
iBe followed successively by 0.101,0.509,0.101.
Below Fig. 3 (a)~Fig. 3 (p) is described further:
Fig. 3 (a)~Fig. 3 (p) is that different filtering methods are to the filter effect comparison diagram of different densities noise image.
Fig. 3 (a) is original Lena figure;
Fig. 3 (b) is for adding 10% the Lena figure that makes an uproar; Fig. 3 (c) is to containing the design sketch that 10% noise Lena figure uses 3*3 square template medium filtering; Fig. 3 (d) is for using the filter effect figure that the present invention relates to containing 10% noise Lena figure;
Fig. 3 (e) is for adding 30% the Lena figure that makes an uproar; Fig. 3 (f) is to containing the design sketch that 30% noise Lena figure uses 3*3 square template medium filtering; Fig. 3 (g) is for using the filter effect figure that the present invention relates to containing 30% noise Lena figure;
Fig. 3 (h) is for adding 50% the Lena figure that makes an uproar; Fig. 3 (i) is to containing the design sketch that 50% noise Lena figure uses square template 3*3 medium filtering; Fig. 3 (j) is for using the filter effect figure that the present invention relates to containing 50% noise Lena figure;
Fig. 3 (k) is for adding 80% the Lena figure that makes an uproar; Fig. 3 (l) is to containing the design sketch that 80% noise Lena figure uses 3*3 square template medium filtering; Fig. 3 (m) is for using the filter effect figure that the present invention relates to containing 80% noise Lena figure;
Fig. 3 (n) is for adding 90% the Lena figure that makes an uproar; Fig. 3 (o) is to containing the design sketch that 90% noise Lena figure uses 3*3 square template medium filtering; Fig. 3 (p) is for using the filter effect figure that the present invention relates to containing 90% noise Lena figure.
(10) judge whether all pixels dispose:
When all pixels do not dispose, returned for (2.1) step;
When all pixels dispose, entered for (11) step;
(11) denoising finishes.
Subordinate list 1: different filtering methods are to the filter effect analytical table of different densities noise image
Noise proportional |
3*3 medium filtering Y-PSNR |
The two scale filter Y-PSNRs of rhombus |
Improve number percent |
10% |
18.18 |
22.09 |
21.5% |
30% |
17.23 |
21.21 |
23% |
50% |
13.48 |
20.3 |
50.5% |
80% |
7.65 |
18.76 |
145% |
90% |
6.24 |
17.38 |
179% |
Annotate: i.e. the experimental data of two kinds of filter effect correspondences among Fig. 3.