A list,

1. Dark channel prior image defogging method 1.1 Light transmittance modelIn the propagation of light, due to scattering, only part of the radiation from the light source can reach the receiving sensor, and the rest is scattered into the propagation medium. It is assumed that the scattering light intensity has a linear relationship with the distance when the distance sensor is infinitely close to the light source. The attenuation value of light can be approximated as Br, where β is the scattering coefficient of air. R is the distance between the light source and the sensor. When atmospheric density is uniform, the mathematical model of light transmittance is:Where, D is the scene depth; T is the light transmittance, which is used to quantify the proportional relationship between the light intensity received by the sensor and the light intensity on the surface of the light source, that is, the proportional relationship between the radiation that is not scattered and the radiation of the light source.

1.2 Dark channel prior theoryThe dark channel prior theory based on the statistics of a large number of clear images refers to the existence of at least one color channel gray value in R, G and B channels for all pixels of most high-quality images without sky, which is very low and approaches 0[5], that is, the minimum radiation intensity value in a certain tiny region is extremely low. An image J can be defined as:Where, J dark is the dark channel value of image J; J is the gray value of c channel of image J; Q(x) is the local tiny region centered on pixel x; Y is any pixel in the region.

The goal of image defogging is to restore a clear image by defogging the foggy image received by the sensor using the useful information obtained. Dark channel prior image defogging processing is based on dark channel principle to obtain prior knowledge, and then use foggy image degradation model to achieve image defogging effect.

1.3.1 Image degradation modelIn the field of computer vision graphics, the degradation model of foggy images is [6] :Where, L (x) is the scene signal received by the sensor, that is, the foggy image input; Scene radiation J(x) is a clear image after signal processing; A is environmental light intensity; T (x) is atmospheric transmittance. J(x) T (x) is called the direct attenuation term, which is used to quantify the signal loss in the radiation and propagation of the scene. A(1-t(x)) represents the atmospheric scattering light intensity received by the image, which is the direct cause of color offset and cloud effect.

1.3.2 Estimation of ambient Light Intensity In the dark channel image, the higher the gray value is, the thicker the cloud is. In the input image, the gray value of] pixel located in this region is closer to the ambient light intensity. To estimate the environmental light intensity first need to find the dark channel image grey value and highest accounted for 01% of the total number of pixels of the image pixels, coordinate their corresponding indexes, and then according to the coordinate index in the input of the fog find corresponding pixels in the image and calculate the fog as environment corresponding pixels in the image grayscale average light intensity.

1.3.3 Estimation of atmospheric transmittanceT ‘(x) is used to represent the atmospheric transmittance in the filtering window centered on pixel x. Assuming that it is locally invariant, the minimum value in formula (3) is calculated, namely, the minimum value in the three color channels R, G and BBy calculating the minimum values of the three color channels, the gray minimum value in the filtering window centered on pixel X can be obtained, i.eAccording to dark channel prior principle and Formula (2), it can be concluded that:Thus, the atmospheric transmittance can be calculated from Equations (5) and (6) : 1.3.4 Defogging treatmentDark channel prior conditions can be used to quantify cloud thickness and radiative reduction of all pixels, and then restore clear and high-quality images. According to the foggy image degradation model of Equation (3), environmental illumination intensity A and atmospheric transmittance T (x), A single image can be defogged, i.e 2. Dark channel prior algorithm is optimized for defogging effectThe optimization process of this paper is shown in Figure 1. When the input image has uneven cloud and fog, the gray level information of the atmospheric transmittance layer is only in a limited range, and the radiation reduction amount of the whole image will be limited within a certain range, so the radiation intensity of the cloud thickness area cannot be accurately restored respectively, thus affecting the image defogging effect. The method of stretching the contrast of atmospheric transmittance layer is considered to improve the fog-free image quality based on dark channel prior when the cloud thickness is uneven.FIG. 1 Image defogging effect optimization process based on dark channel prior

Two, some source code

Dark passage to fog algorithm % % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % dark grey to dark fog algorithm is based on the natural outdoor scene channel priority rules to fog on the basis of the method I(x)=J(x)t(x)+A(x)1-t(x)) % where I(x) is the image polluted by fog,J(x) is the image we need to remove fog. %t(x) is the transmission distribution rate of clouds in the sky. A is the brightness of the sky % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = img_name = imread ('1.bmp'); % Original image I =double(img_name)/255; [h,w,c] = size(I); % get image size w0 =0.95; % dehaze = zeros(h,w,c); Win_dark = zeros(h,w); Initializes the shadow channel image % % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- % % calculation dark channel first calculate the lowest value of each pixel RGB component, Store in a grayscale image of the same size as the original image. % and then perform minimum filtering on the gray imagefor i=1:h                 
    for j=1:w win_dark(i,j) = min(I(i,j,:)); End end win_dark = ordfilt2(win_dark,1,ones(9.9),'symmetric');   %9*9Minimum value filtering (dark channel window) % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- atmospheric brightness A dark_channel = % calculation win_dark; temp = max(max(dark_channel)); [i,j] = find(dark_channel==temp); i = i(1);
j = j(1); A = mean(I(i,j,:)); % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- % calculating transmittance t gray_I (x) = I (:, :,1); % where gray_I can be any channel in RGB image p = transmission; % transmittance diagram r =80;
eps = 10^- 3; % Use guided Filter for TrasmissionmapGray_I is the boot image, P is the input image, r is the local window radius, Eps is the regularization parameter % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- no fog image t0 = % o0.1; % Set threshold t1 = Max (t0,transmission_filter);for i=1:c
    for j=1:h
        for l=1:w dehaze(j,l,i)=(I(j,l,i)-A)/t1(j,l)+A; % % no fog image restoration end end end -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- % display imagesfigure
subplot(121)
imshow(win_dark); title('Dark channel')
subplot(122) imshow(t1); title('Transmittance diagram')
figure
subplot(121)
imshow(I); title('Before the fog')
subplot(122) imshow(dehaze); title('After the fog') % boxfilter filtering function (box) % = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = % input: imSrc % of the given sliding window size: r %========================================================================== function imDst = boxfilter(imSrc,r) imDst = zeros(size(imSrc)); Initialization % % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- imCum = cumsum (imSrc,1); %y axis accumulative sum, sum each row to the next row %y axis direction difference imDst(1:r+1,:) = imCum(1+r:2*r+1, :); % to imCum1+ r to2*r+1The row data is copied to the imDst function1To the r +1Line imDst (r +2:hei-r,:) = imCum(2*r+2:hei,:)-imCum(1:hei2 -*r- 1, :); % to imCum2*r+2The heI row is subtracted1To hei2 -*r- 1The value % of the line stores the final result into r+ of the function imDst2Line to hei - r imDst (hei - r +1:hei,:) = repmat(imCum(hei,:),[r,1])-imCum(hei2 -*r:hei-r- 1, :); % Use the repmat function to change imCum to R *1The format % is then subtracted from the hei function imCum2 -* r to hei - r- 1The value % of the row results in the HEi-r + of imDst1To hei line % -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- % y direction difference imDst (:1:r+1) = imCum(:,1+r:2*r+1); % to imCum1+ r to2*r+1Column data is copied to the imDst function1To the r +1Column imDst (:, r +2:wid-r) = imCum(:,2*r+2:wid)-imCum(:,1:wid2 -*r- 1); % to imCum2*r+2The heI column is subtracted1To hei2 -*r- 1The value % of the column stores the final result in r+ of the function imDst2To the hei-R column1:wid) = repmat(imCum(:,wid),[1,r])-imCum(:,wid2 -*r:wid-r- 1); % Use the repmat function to change imCum to R *1The format % is then subtracted from the hei function imCum2 -* r to hei - r- 1The value % of the column results in the HEi-r + of imDst1To end of the HEI columnCopy the code

3. Operation results

Matlab version and references

1 matlab version 2014A

2 Reference [1] CAI Limei. MATLAB Image Processing — Theory, Algorithm and Case Analysis [M]. Tsinghua University Press, 2020. [2] Yang Dan, ZHAO Haibin, LONG Zhe. Examples of MATLAB Image Processing In detail [M]. Tsinghua University Press, 2013. [3] Zhou Pin. MATLAB Image Processing and Graphical User Interface Design [M]. Tsinghua University Press, 2013. [4] LIU Chenglong. Proficient in MATLAB Image Processing [M]. Tsinghua University Press, 2015.