Summary of the invention:
The purpose of this invention is to provide a kind of quick defogging method capable, not only can effectively improve problems such as greasy weather picture contrast that gas obtains decline and cross-color are arranged, and processing speed is fast, can the higher occasion of requirement of real time.
The technical solution used in the present invention is:
The first step: read the original mist image I that has;
Second step: ask R, the G of each pixel among the original image I, the minimum value of three passages of B, and assignment gives current pixel point, the gray level image that obtains is designated as I
_{g}, if I is gray level image, then I
_{g}=I;
The 3rd step: the I that utilizes formula (1) that second step was obtained
_{g}Image carries out filtering, and (x is that (x, pixel y) are that the size at center is the masterplate zone of N*N, generally get N ∈ (9,21), and N is big more, and the atmospheric parameter of trying to achieve is more little, and the overall brightness that obtains not having the mist image is bright relatively more with coordinate y) to definition Ω;
${{I}_{g}}^{\mathrm{dark}}(x,y)=\underset{(i,j)\∈\mathrm{\Ω}(x,y)}{\mathrm{min}}\left({I}_{g}(i,j)\right)---\left(1\right)$
The 4th step: obtain I
_{g} ^{Dark}Position coordinates (the x of the pixel of intensity maximum in the image
_{Max}, y
_{Max}), if I is coloured image, atmospheric parameter A then
_{R}=I
_{R}(x
_{Max}, y
_{Max}), A
_{G}=I
_{G}(x
_{Max}, y
_{Max}) and A
_{B}=I
_{B}(x
_{Max}, y
_{Max}), I wherein
_{R}, I
_{G}And I
_{B}Be respectively R, G and the B passage of coloured image I, if I is a gray level image, its atmospheric parameter A
_{Gray}=I (x
_{Max}, y
_{Max});
The 5th step: ask for the length h and the width w of image, utilize formula (2) to I
_{g} ^{Dark}Point (the x that satisfies condition in the image, y) ask the value of its transmissivity, wherein x=1,1+S, 1+2*S ..., 1+n*S, h, y=1,1+S, 1+2*S ..., 1+m*S, w, general step-length S ∈ (40,100), S is big more, and the processing speed in the 6th step is fast more, but the coefficient of the regression equation of estimating is relatively not too accurate, mist elimination effect relative mistake is a little, if I is a coloured image, then in the formula (2)
As if I is gray level image, then A=A in the formula (2)
_{Gray}, ω 0 is the adjusting parameter, general ω 0 ∈ (0,1), and the big more mist elimination effect of ω 0 is good more;
$t(x,y)=1-\mathrm{\ω}0\left(\frac{{{I}_{g}}^{\mathrm{dark}}(x,y)}{A}\right)---\left(2\right)$
The 6th step: pixel and the corresponding transmissivity of utilizing the dihydric phenol linear regression analysis that the 5th step was related to are carried out regretional analysis, obtain the coefficient b suc as formula the equation of (3)
_{0}, b
_{1}, b
_{2}, b
_{3}, b
_{4}And b
_{5}
t＝b
_{0}+b
_{1}*x+b
_{2}*y+b
_{3}*x
^{2}+b
_{4}*xy+b
_{5}*y
^{2} (3)
The 7th step: utilize formula (3) to obtain the transmissivity t of all pixels;
The 8th step: utilize formula (4) to recover no mist image, if I is a coloured image, then utilize formula (4) at R, G, three passages of B respectively, wherein A gets A respectively
_{R}, A
_{G}And A
_{B}, I gets I respectively
_{R}, I
_{G}And I
_{B}, then obtain three passage J of J respectively
_{R}, J
_{G}And J
_{B}, if I is gray level image, then A=A
_{Gray}
$J\left(x\right)=\frac{I\left(x\right)-A(1-t\left(x\right))}{t\left(x\right)}---\left(4\right)$
The present invention is a kind of quick defogging method capable, and compared with prior art, advantage is:
1, both can handle coloured image and also can handle gray level image;
2, algorithm process is effective, and by the contrast effect figure of Fig. 2 (a) and Fig. 2 (b) as can be seen, through after this algorithm process, the tree in a distant place, street lamp and billboard have all shown clearly, and do not have distortion.Fig. 3 (b) is the result of histogram equalization, the result that Fig. 3 (c) handles for the method that adopts He Kaiming, Fig. 3 (d) is the result of this algorithm, by the result of Fig. 3 as can be seen, this algorithm is suitable with the result of the method for He Kaiming, and the histogram equalization method has serious distortion at regional area.
3, this algorithm process speed is very fast, can realize that mist elimination is handled fast.The method that table 1 is depicted as this algorithm and He Kaiming is handled the contrast of the time complexity of Fig. 3 (a) equally, and the method that this algorithm adopts binary linear regression to analyze has been saved a large amount of operation time with respect to the soft stingy drawing method of He Kaiming, and processing speed is fast.Testing used is the Pentium 1.8G computing machine of 1G internal memory, the matlab code is not optimized, and shows that this algorithm can be applied in the real-time system.
Table 1 algorithm contrast table working time
Embodiment:
Below in conjunction with instantiation the present invention is elaborated.
Example 1: this example is to carry out the process that mist elimination is handled at gray level image, and detailed process is as follows.
1: original have reading in of misty grey degree image, and gray level image is designated as I.
2: (x y) carries out the minimum value Filtering Processing, obtains I to each pixel I among the I
_{g} ^{Dark}(x, y), computing formula is as follows:
${{I}_{g}}^{\mathrm{dark}}(x,y)=\underset{(i,j)\∈\mathrm{\Ω}(x,y)}{\mathrm{min}}\left(I(i,j)\right)$
Wherein (x is that (x is the small images of the N*N size at center y), gets N=15 in this example, and we claim I with pixel I y) to Ω
_{g} ^{Dark}Be the dark primary image, carry out the estimation of atmospheric parameter A by the dark primary image.
3: find I
_{g} ^{Dark}In maximum pixel, and write down position coordinates (x in its place image
_{m}, y
_{m}), being calculated as follows of atmospheric parameter A then:
A＝I(x
_{m}，y
_{m})
4: obtain the length h and the width w of image, evenly choose the part point in the image and calculate its transmissivity, x and all combinations of y in following two conditions are satisfied in being chosen for of the coordinate of point:
a：x＝1、1+S、1+2*S、…、1+n*S、h；
b：y＝1、1+S、1+2*S、…、1+m*S、w；
General S ∈ (40,100), S gets 40 in this example.
Point (x, the computing formula of the transmissivity of y) locating is as follows:
$t(x,y)=1-\mathrm{\ω}0\left(\frac{{{I}_{g}}^{\mathrm{dark}}(x,y)}{A}\right)$
I wherein
_{g} ^{Dark}(x y) is the pixel of dark primary image, and A is the atmospheric parameter of trying to achieve in the 3rd step, and ω 0 is for regulating parameter, general ω 0 ∈ (0,1), ω 0=0.9 in this example.
5: utilize the dihydric phenol linear regression analysis that point and corresponding transmissivity in 4 are carried out regretional analysis, to obtain coefficient b
_{0}, b
_{1}, b
_{2}, b
_{3}, b
_{4}And b
_{5}, and obtain the transmissivity that other are had a few according to regression function, regression function is as follows:
t＝b
_{0}+b
_{1}*x+b
_{2}*y+b
_{3}*x
^{2}+b
_{4}*xy+b
_{5}*y
^{2}
B wherein
_{0}, b
_{1}, b
_{2}, b
_{3}, b
_{4}And b
_{5}Be respectively regression coefficient, transmissivity t is the quadratic function of coordinated indexing x and y.
6: calculate no mist image J (x) according to atmospheric parameter A that obtains above and transmissivity t, computing formula is as follows:
$J\left(x\right)=\frac{I\left(x\right)-A(1-t\left(x\right))}{t\left(x\right)}$
Wherein I (x) is the original mist image that has, and the atmospheric parameter that A obtained in the 3rd step, t are the transmissivity of obtaining in the 5th step.
Example 2: this example is to carry out the process that mist elimination is handled at coloured image, and detailed process is as follows.
1: original have reading in of mist coloured image, and image is designated as I.
2: to each pixel among the I, ask the minimum value of its R, G, three passages of B, and assignment gives current pixel point, obtain a gray level image after the processing, be designated as I
_{g}, computing formula is as follows:
${I}_{g}(x,y)=\underset{c\∈\{R,G,B\}}{\mathrm{min}}\left({I}_{c}(x,y)\right)$
Wherein R, G and B are three passages of pixel I, I
_{R}(x, y), I
_{G}(x, y) and I
_{B}(x y) is respectively pixel I (x, the value of three passages y).
3: to I
_{g}In each pixel I
_{g}(x y) carries out the minimum value Filtering Processing, obtains I
_{g} ^{Dark}(x, y), computing formula is as follows:
${{I}_{g}}^{\mathrm{dark}}(x,y)=\underset{(i,j)\∈\mathrm{\Ω}(x,y)}{\mathrm{min}}\left({I}_{g}(i,j)\right)$
Wherein (x is with pixel I y) to Ω
_{g}(x y) is the small images of the N*N size at center, gets N=15 in this example, and we claim I
_{g} ^{Dark}Be the dark primary image, carry out the estimation of atmospheric parameter A by the dark primary image.
4: find I
_{g} ^{Dark}In maximum pixel, and write down position coordinates (x in its place image
_{m}, y
_{m}), being calculated as follows of atmospheric parameter A then:
A
_{R}＝I
_{R}(x
_{max}，y
_{max})
A
_{G}＝I
_{G}(x
_{max}，y
_{max})
A
_{B}＝I
_{B}(x
_{max}，y
_{max})
I wherein
_{R}, I
_{G}And I
_{B}Be respectively R, G and three passages of B of original image I, A
_{R}, A
_{G}And A
_{B}Three passages for atmospheric parameter A.
5: obtain the length h and the width w of image, evenly choose the part point in the image and calculate its transmissivity.
Being chosen for of coordinate of point satisfied x and all combinations of y in following two conditions:
a：x＝1、1+S、1+2*S、…、1+n*S、h；
b：y＝1、1+S、1+2*S、…、1+m*S、w；
General S ∈ (40,100), S gets 40 in this example.
Point (x, the computing formula of the transmissivity of y) locating is as follows:
$t(x,y)=1-\mathrm{\ω}0\left(\frac{{{I}_{g}}^{\mathrm{dark}}(x,y)}{A}\right)$
I wherein
_{g} ^{Dark}(x y) is the pixel of dark primary image, and A is the atmospheric parameter of trying to achieve in the 3rd step, and ω 0 is for regulating parameter, general ω 0 ∈ (0,1), ω 0=0.9 in this example.
6: utilize the dihydric phenol linear regression analysis that point and corresponding transmissivity in 5 are carried out regretional analysis, to obtain coefficient b
_{0}, b
_{1}, b
_{2}, b
_{3}, b
_{4}And b
_{5}, and obtain the transmissivity that other are had a few according to regression function, regression function is as follows:
t＝b
_{0}+b
_{1}*x+b
_{2}*y+b
_{3}*x
^{2}+b
_{4}*xy+b
_{5}*y
^{2}
B wherein
_{0}, b
_{1}, b
_{2}, b
_{3}, b
_{4}And b
_{5}Be respectively regression coefficient, transmissivity t is the quadratic function of coordinated indexing x and y.
7: calculate no mist image J (x) according to atmospheric parameter A that obtains above and transmissivity t, computing formula is as follows:
${J}_{R}\left(x\right)=\frac{{I}_{R}\left(x\right)-{A}_{R}(1-t\left(x\right))}{t\left(x\right)}$
${J}_{G}\left(x\right)=\frac{{I}_{G}\left(x\right)-{A}_{G}(1-t\left(x\right))}{t\left(x\right)}$
${J}_{B}\left(x\right)=\frac{{I}_{B}\left(x\right)-{A}_{B}(1-t\left(x\right))}{t\left(x\right)}$
I wherein
_{R}, I
_{G}And I
_{B}Be respectively R, G and three passages of B of original image I, A
_{R}, A
_{G}And A
_{B}Be the atmospheric parameter of obtaining in the 4th step, t is the transmissivity of obtaining in the 6th step, the J that obtains
_{R}, J
_{G}And J
_{B}Three passages for no mist coloured image.
Though two examples of the present invention only have been described here, and meaning is not to limit the scope of the invention and applicability.On the contrary, the detailed description to example can make those skilled in the art better be implemented.