Image defogging method based on dark channel compensation and atmospheric light value improvement
Technical Field
The invention belongs to the technical field of image processing, and particularly relates to an image defogging method based on dark channel compensation and atmospheric light value improvement.
Background
In a haze scene, atmospheric suspended particles tend to generate certain absorption and scattering effects on light, so that the visibility of outdoor images is greatly reduced, the phenomena of degradation such as contrast reduction and color attenuation of the images occur, the visual observation of human eyes and the normal operation of machine vision equipment are influenced, and therefore, the research on the image defogging method has very important practical significance.
The image defogging method is mainly divided into two types, one type is a defogging method based on image enhancement, and the image clearness is realized mainly by improving contrast, highlighting detail characteristics and the like, but the method ignores the internal relation of a real fog scene, so that the color distortion phenomenon of the image is easily caused; the other defogging method is an image restoration method based on an atmospheric scattering physical model, and an image restoration model is derived by means of a strict theoretical formula.
An image defogging algorithm based on hypothesis or priori knowledge becomes the most widely applied defogging method at present, for example, He and other people find a new theory, namely a dark channel prior theory (DCP), by carrying out statistics on outdoor defogged images, the method utilizes dark channel prior to estimate atmospheric light and transmittance, improves a transmittance map by Soft Matting (SM) to recover clear defogged images, but the Soft Matting technique greatly increases the time complexity and space complexity of the dark channel prior inspection algorithm, then He and other people successively provide guide filtering instead of Soft Matting to reduce the complexity of the calculation method but still have obvious residual fog in a distant view region, Meng and other people provide a defogging algorithm based on boundary constraint, the method recovers the defogged images by increasing the constraint conditions of parameters in a physical model, improves the recovery effect by sacrificing a small amount of details to obtain clear images, but processes the calculation complexity of operation, finds that the calculation complexity is greater than that of the boundary constraint, and sets up a linear attenuation coefficient of the transmittance and a depth of field by using a Saturation coefficient of Saturation of a human beings (Hue, Saturation coefficient of Saturation, and Saturation coefficient of the Saturation of the image, thus, and the method realizes the unified recovery of the brightness of the background image by using a simple observation method of observation of a saturated image.
In the above defogging algorithm, the dark channel prior defogging method proposed by He et al is known to more people for simplicity and effectiveness, but in practical application, the method directly affects the overall image recovery effect due to the problems of underestimation of the dark channel, inaccurate selection of the atmospheric light value, and the like.
Disclosure of Invention
The invention aims to provide an image defogging method based on dark channel compensation and atmospheric light value improvement, which can effectively solve the problem of insufficient dark channel prior algorithm in the prior art.
The invention adopts the technical scheme that an image defogging method based on dark channel compensation and atmospheric light value improvement is implemented according to the following steps:
step 1, acquiring a red, green and blue three color channel value minimum value channel image I of an input foggy day image I (x)dark1Then, the initial dark channel image I is obtained through minimum value filtering calculationdark2(x);
Step 2, according to the minimum value channel image Idark1Initial dark channel image Idark2(x) Calculating a dark channel compensation model to obtain a compensated dark channel image Idark(x);
Step 3, calculating an atmospheric light value A of the foggy day image I (x) by combining an improved quadtree segmentation method, and according to the compensated dark channel image Idark(x) Calculating the atmospheric transmittance t (x);
and 4, substituting the atmospheric light value A and the atmospheric transmittance t (x) into an atmospheric scattering model formula of the foggy day image, denoising through a fogless image recovery formula, and calculating a fogless image J (x).
Step 1 initial dark channel image Idark2(x) The expression is as follows:
the specific process of the step 2 is as follows:
step (ii) of2.1 solving the minimum value channel image Idark1Initial dark channel image Idark2(x) And identifying and extracting a halo region part in the initial dark channel image, wherein the specific expression is as follows:
Iedge1=αIdark1-βIdark2(2);
in the formula (2), Iedge1Representing halo region maps before correction, α and β are weighting parameters;
step 2.2, the extracted halo image is corrected by using morphological corrosion and weighted fusion operation processing, namely:
bringing formula (2) into equation (3) yields:
in the formula (4), Iedge2(x) Indicating the modified halo region, ξ1、ξ2For weighting parameters, Ω (x) is a filtering area centered at x, and the structural elements of the filtering take a square matrix of 15 × 15;
and 2.3, carrying out image fusion on the corrected halo image and the original dark channel image in a linear fusion mode to obtain a dark channel compensation model:
Idark=Idark2+Iedge2(5);
the dark channel compensation model can be obtained by bringing formula (4) into formula (5):
in the formula (6), IdarkRepresenting the fused dark channel image, C1、C2、C3And C4For linear weighting coefficients, ε (x) is the random error of the random variable representation model.
Step 2.3 in step C1、C2、C3And C4For linear weighting coefficients, the calculation method is as follows:
let I
0(x)、I
1(x)、I
2(x)、I
3(x) And I
4(x) Respectively represent I in formula (6)
dark(x)、I
dark1(x)、 I
dark2(x)、
And
variables, combined with ε (x) to N (0, σ)
2) And the nature of the normal distribution, we can obtain:
I(x)~N(C1I1(x)+C2I2(x)+C3I3(x)+C4I4(x),σ2) (7)
assuming that the probability of each pixel error is independent, the following joint probability density function is constructed:
in the formula, i represents a pixel point, and logarithms are taken from two sides of the formula (8) at the same time to obtain:
the maximum value of the equation (9) is σ
Assuming σ is a constant, the maximum of the above equation can be converted to the minimum of the following equation
And (3) solving the minimum value of the formula (11) by adopting a gradient descent algorithm, and respectively solving partial derivatives of the parameters in the formula (11) to obtain:
step 3, calculating the atmospheric light value A of the foggy day image I (x) by combining an improved quadtree segmentation method, which comprises the following specific steps:
step 3.1, according to the initial threshold value T0Obtaining a gray scale image I from the input foggy day image I (x)gray;
Step 3.2, aiming at the gray level image IgrayObtaining a filtered image I using median filteringmedian;
Step 3.3, image ImedianAveragely dividing the four rectangular areas and four adjacent areas by a quadtree segmentation method;
step 3.4, calculating the average pixel value of each rectangular area, subtracting the standard deviation of the area from the average pixel value to obtain a score, and selecting the maximum score and the area corresponding to the maximum score;
step 3.5, the four adjacent areas are marked again;
step 3.6, rotating the four marked adjacent regions counterclockwise, and recombining the four marked adjacent regions into an image;
step 3.7, calculating the average pixel value of each region in the step 3.6 minus the standard deviation of the corresponding region, and selecting the maximum score and the region corresponding to the maximum score;
step 3.8, comparing the maximum score in the step 3.4 with the maximum score in the step 3.7, and selecting a region with the maximum score;
step 3.9, repeat step 3.2 andstep 3.3, until the size of the area is smaller than the initial threshold T0The area is a target area;
and 3.10, calculating the average value of the gray values of the target area, wherein the average value is the atmospheric light value A.
Step 4, the atmospheric scattering model formula is as follows:
I(x)=J(x)t(x)+A[1-t(x)](16)。
step 4, the process of calculating the fog-free image J (x) is as follows:
in the formula (17), t0The lower threshold value set for the transmittance t (x) is 0.1.
The invention has the beneficial effects that:
1) the image halo phenomenon caused by underestimation of a dark channel value in the existing dark channel prior image defogging algorithm is solved by using a dark channel compensation model;
2) the atmospheric light value selection method for the quadtree segmentation increases a strategy of comparing adjacent regions, so that the atmospheric light value selection is more accurate.
Drawings
FIG. 1 is a flow chart of a method for image defogging based on dark channel compensation and improvement of atmospheric light values according to the present invention;
FIG. 2(a) is a diagram of a region partitioned by a conventional quadtree partitioning method;
FIG. 2(b) shows the left leakage region after the quadtree division method;
FIG. 2(c) is a combined image of the regions segmented by the quadtree segmentation method;
FIG. 3(a) is a foggy day image;
FIG. 3(b) is an original dark channel image;
FIG. 3(c) is a compensated dark channel image;
FIG. 3(d) shows the results of the original treatment;
FIG. 3(e) is the result of the compensated processing;
FIG. 4(a) is a foggy day image;
FIG. 4(b) is an atmospheric light value region selected by the quadtree splitting method;
FIG. 4(c) is an atmospheric light value region selected for improved quadtree splitting;
FIG. 4(d) is a processing result of the quadtree splitting method;
FIG. 4(e) is a processing result of the improved quadtree splitting method;
FIG. 5(a) is an original foggy day image;
FIG. 5(b) shows the results of He arithmetic processing;
FIG. 5(c) shows the processing results of Meng algorithm;
FIG. 5(d) is the results of the Zhu algorithm processing;
FIG. 5(e) shows the processing result of the method of the present invention.
Detailed Description
The present invention will be described in detail below with reference to the accompanying drawings and specific embodiments.
The origin of the dark channel prior theory: he et al proposed a new defogging solution in 2009, which He et al found by observing a large number of defogged and haze-free images: in most non-sky areas of fog-free images, the pixel value of at least one color channel of the red, green and blue color channels of the image is low and approaches to zero, and the formula is expressed as
In the formula Jc(y) represents the three color channels of the image and Ω (x) represents a square filter window centered at j (x), typically 15 × 15. This formula, the dark channel prior condition.
The dark channel first pass algorithm is based on an atmospheric scattering model, and the mathematical expression of the atmospheric scattering physical model is I (x) ═ J (x) t (x) + A [1-t (x) ]
In the formula, i (x) represents a haze image, j (x) represents a haze-free image, t (x) represents transmission transmittance, a represents an atmospheric light value, j (x) t (x) is a direct attenuation term, that is, the amount of target emission light entering a shooting device after being attenuated by atmospheric scattering, and a [1-t (x) ] is atmospheric scattered light, mainly the amount of atmospheric light entering the device after being scattered by haze.
When the atmospheric transmittance is obtained, the image is subjected to windowing refinement processing, if the atmospheric light value A is known, the transmittance t (x) is a local constant, and two minimum value filtering operations are carried out to obtain the atmospheric transmittance
The prior condition that the dark channel value in the fog-free image tends to zero can be obtained
In the formula, in order to enable the restored image to be closer to a real scene, a parameter mu is introduced, and the value of the method is 0.95.
When the transmittance value t (x) is very small, the value of j (x) will be too large, resulting in excessive white field as a whole. To avoid this problem, the present invention sets a lower threshold t for the transmittance t (x)0And if the value is 0.1, the fog-free image recovery formula is expressed as
The invention relates to an image defogging method based on dark channel compensation and atmospheric light value improvement, which is specifically implemented according to the following steps as shown in figure 1:
step 1, acquiring a red, green and blue three color channel value minimum value channel image I of an input foggy day image I (x)dark1Then, the initial dark channel image I is obtained through minimum value filtering calculationdark2(x);
Initial dark channel image Idark2(x) The expression is as follows:
step 2, according toMinimum value channel image Idark1Initial dark channel image Idark2(x) Calculating a dark channel compensation model to obtain a compensated dark channel image Idark(x);
The specific process is as follows:
step 2.1, solving a minimum value channel image Idark1Initial dark channel image Idark2(x) And identifying and extracting a halo region part in the initial dark channel image, wherein the specific expression is as follows:
Iedge1=αIdark1-βIdark2(2);
in the formula (2), Iedge1Representing halo region maps before correction, α and β are weighting parameters;
step 2.2, the extracted halo image is corrected by using morphological corrosion and weighted fusion operation processing, namely:
bringing formula (2) into equation (3) yields:
in the formula (4), Iedge2(x) Indicating the modified halo region, ξ1、ξ2For weighting parameters, Ω (x) is a filtering area centered at x, and the structural elements of the filtering take a square matrix of 15 × 15;
and 2.3, carrying out image fusion on the corrected halo image and the original dark channel image in a linear fusion mode to obtain a dark channel compensation model:
Idark=Idark2+Iedge2(5);
the dark channel compensation model can be obtained by bringing formula (4) into formula (5):
in the formula (6), IdarkRepresenting the fused dark channel image, C1、C2、C3And C4For linear weighting coefficients, ε (x) is the random error of the random variable representation model;
step 2.3 in step C1、C2、C3And C4For linear weighting coefficients, the calculation method is as follows:
let I
0(x)、I
1(x)、I
2(x)、I
3(x) And I
4(x) Respectively represent I in formula (6)
dark(x)、I
dark1(x)、 I
dark2(x)、
And
variables, combined with ε (x) to N (0, σ)
2) And the nature of the normal distribution, we can obtain:
I(x)~N(C1I1(x)+C2I2(x)+C3I3(x)+C4I4(x),σ2) (7)
assuming that the probability of each pixel error is independent, the following joint probability density function is constructed:
in the formula, i represents a pixel point, and logarithms are taken from two sides of the formula (8) at the same time to obtain:
the maximum value of the equation (9) is σ
Assuming σ is a constant, the maximum of the above equation can be converted to the minimum of the following equation
And (3) solving the minimum value of the formula (11) by adopting a gradient descent algorithm, and respectively solving partial derivatives of the parameters in the formula (11) to obtain:
step 3, calculating an atmospheric light value A of the foggy day image I (x) by combining an improved quadtree segmentation method, and according to the compensated dark channel image Idark(x) Calculating the atmospheric transmittance t (x);
the specific process of calculating the atmospheric light value A of the foggy day image I (x) by combining the improved quadtree segmentation method comprises the following steps:
step 3.1, according to the initial threshold value T0Taking the value of 30 x 30, and calculating the gray level image I (x) of the input foggy day image I (x)gray;
Step 3.2, aiming at the gray level image IgrayObtaining a filtered image I using median filteringmedian;
Step 3.3, image ImedianEqually dividing into four rectangular regions by a quadtree division method, as shown in fig. 2(a), and four adjacent regions;
step 3.4, calculating the average pixel value of each rectangular area, subtracting the standard deviation of the area from the average pixel value to obtain a score, and selecting the maximum score and the area corresponding to the maximum score;
step 3.5, re-marking the four adjacent regions, as shown in fig. 2 (b);
and 3.6, rotating the four adjacent marked areas anticlockwise, and recombining the four adjacent marked areas into an image, as shown in fig. 2 (c).
Step 3.7, calculating the average pixel value of each region in the step 3.6 minus the standard deviation of the corresponding region, and selecting the maximum score and the region corresponding to the maximum score;
step 3.8, comparing the maximum score in the step 3.4 with the maximum score in the step 3.7, and selecting a region with the maximum score;
step 3.9, repeat step 3.2 and step 3.3 until the region size is smaller than the initial threshold T0The area is a target area;
and 3.10, calculating the average value of the gray values of the target area, wherein the average value is the atmospheric light value A.
Step 4, substituting the atmospheric light value A and the atmospheric transmittance t (x) into an atmospheric scattering model formula of the foggy day image, denoising through a fogless image recovery formula, and calculating a fogless image J (x);
step 4, the atmospheric scattering model formula is as follows:
I(x)=J(x)t(x)+A[1-t(x)](16)。
the process of calculating the fog-free image J (x) is as follows:
in the formula (17), t0The lower threshold value set for the transmittance t (x) is 0.1.
Examples
The invention obtains the transmittance of the image by the color attenuation prior algorithm proposed by Zhu et al, and then by means of the formula
Reversely deducing dark channels which are not underestimated, selecting 100 training samples and 2400 ten thousand pixel points to train a linear model, obtaining the best training result C1-0.91098, C2-0.12076, C3-0.12893, C4-0.03144,
1) halo phenomenon existing a priori to dark channel
Processing the actual image, and obtaining a result graph before and after dark channel compensation: selecting a foggy day image as shown in fig. 3 (a); FIG. 3(b) is an original dark channel image; FIG. 3(c) is a compensated dark channel image; FIG. 3(d) shows the results of the original treatment; fig. 3(e) shows the processing result after compensation.
As can be seen by comparing fig. 3(c) and fig. 3(b), the compensated dark channel significantly improves the pixel values at the image edges and preserves the detail features of the image scene. The experimental result of fig. 3(e) shows that the method based on the dark channel compensation model provided by the invention can effectively remove the halo effect.
2) Improvement of atmospheric light value
Processing the actual image, and obtaining a result graph before and after the improvement of the quadtree method: FIG. 4(a) is a foggy day image; FIG. 4(b) is an atmospheric light value region selected by the quadtree splitting method; FIG. 4(c) is an atmospheric light value region selected for the improved quadtree splitting method; FIG. 4(d) is a processing result of the quadtree splitting method; FIG. 4(e) is a processing result of the improved quadtree splitting method; as can be seen from fig. 4(a) to 4(e), the atmospheric light value of the image selected by the original quadtree segmentation method is lower than the real atmospheric light value, so that the defogging of the distant view region in the restored image is not thorough.
3) Comparison of results
Selecting an original foggy day image as a picture in fig. 5 (a); FIG. 5(b) shows the He algorithm processing result, and there is still significant residual fog in the distant view region; FIG. 5(c) shows the processing results of Meng algorithm; FIG. 5(d) is the results of the Zhu algorithm processing; FIG. 5(e) shows the processing result of the method of the present invention; compared with other algorithm processing, the image restored by the method is real and natural, and the brightness of the image is more consistent with the observation of human eyes.
In order to further verify the actual recovery effect of the method, the 4 groups of images are objectively evaluated by adopting indexes such as average gradient, contrast, information entropy, processing time and the like, and the indexes are shown in tables 1-4.
TABLE 1
TABLE 2
TABLE 3
TABLE 4
The above experimental data show that the method has certain advantages and advances in image detail characteristics, gray contrast and algorithm processing time, but the method is slightly inferior to Meng algorithm and Zhu algorithm in image definition.
Through the mode, the image defogging method based on dark channel compensation and atmospheric light value improvement not only can effectively correct the underestimated dark channel value and weaken the halo effect at the edge of the image scene, but also can accurately acquire the atmospheric light value of the image, so that the recovered image is clearer and more natural, and the details are reserved more abundantly. The method comprises the following specific implementation steps: firstly, solving a minimum channel image by using R, G, B color channels of an original image, and acquiring a compensated dark channel image by using a dark channel compensation model; then, calculating the atmospheric light value of the image by performing graying processing, quadtree segmentation and other steps on the original image; and finally, estimating the image transmittance by combining the dark channel image and the atmospheric light value, and recovering the fog-free image through an atmospheric scattering model. The experimental result and subjective and objective evaluation prove the feasibility and effectiveness of the method.