Modified dark channel prior based on multi-scale Retinex for power image defogging

At present, defogging technologies can be roughly divided into two categories: the first category is the method of defogging based on image enhancement non-physical model. This method does not start from the essence of optical imaging, but only improves the visual effect of the image by improving the contrast and color of the image, so as to achieve the purpose of defogging. The commonly used methods include histogram equalization, contrast enhancement and automatic color levels, Retinex theory and wavelet transform, etc. The second type is based on atmospheric scattering physical model. This method analyzes the degradation mechanism in the process of imaging, establishes the degradation model of foggy image, and restores the real scene without fog by using the prior knowledge in the degradation process. This method needs to obtain prior conditions as model parameters, but the prior conditions are often difficult to obtain. In this paper, an adaptive power image defogging algorithm based on multi-scale Retinex and modified dark channel is proposed. Sobel operator is used to detect the edges of luminance components and multi-scale Retinex algorithm is used to eliminate luminance components. A priori theory of dark channel optimization by guided filtering is used to obtain rough estimated transmittance. The global atmospheric light value is selected by quadtree subspace search method. In order to eliminate the phenomenon that the restored image is dark as a whole and cannot display details, the brightness value is corrected by two-dimensional gamma function, and finally the restored defogging image is obtained. The experimental results show that the proposed algorithm can effectively restore the details of foggy images, completely remove foggy images, have good color brightness, and the images are clear and natural.


Introduction
In the air of haze weather, a large number of water molecules and PM2.5 particles and other impurities will affect the straight line propagation of light, resulting in blurred images and reduced contrast. This not only affects people's visual perception of images, but also seriously affects the recognition and feature extraction of computer vision systems [1]. As one of the most intuitive media to obtain information, it is of great significance to process low-quality images into images that can obtain more effective information [2]. With  Haiyan Yu and Jihong Wang 2 methods can be divided into image restoration and image enhancement [3]. Image enhancement algorithms are mainly represented by histogram equalization algorithm, Retinex algorithm and correlation algorithm based on Retinex [4][5][6]. In these image restoration algorithms, the image restoration algorithm based on dark channel prior proposed by He et al. [7] was the most creative, and the atmospheric scattering model could be used to effectively restore fog-free images. But the algorithm had limitations. This could lead to inaccurate estimates of atmospheric light values when an image contained large areas of sky or highlights of light sources. The method of minimum filtering and soft matting would cause the halo effect in the restored image and the timeliness of the algorithm was poor. Yu et al. [8] proposed a single image defogging algorithm to optimize dark channels by using the blockto-pixel interpolation method. However, there was halo effect in the edge region of the restored image and the color recovery in the sky region was poor. Zhu et al. [9] proposed the color attenuation prior, under this condition, the sky area could be effectively restored and detail information could be well protected, but the restored image contained mist. Sun et al. [10] proposed a local atmospheric light value estimation algorithm, which could solve a series of restoration problems caused by inaccurate estimation of global atmospheric light value by dark channel prior algorithm. Meng et al. [11] limited the transmittance and processed the image with regularization method, resulting in color skew in the restoration results. Cai et al. [12] used neural network to design an end-toend deep learning algorithm to remove fog, which could restore fog-free images, indicating that the algorithm had a good recovery effect on the sky region. Zhao et al. [13] processed fog-covered images with dark channel prior algorithm, then transferred the processed images to HSV (Hue, Saturation, Value) space and optimized the V component according to Retinex theory. In order to protect image edge information and maintain image color, Ma et al. [14] converted fog-covered images into Lab color space, where L represented brightness, a represented green to red component, and b represented blue to yellow component. L component (brightness) was processed according to Retinex theory.
Due to atmospheric environment, complex and changeable terrain or poor imaging effect of equipment, the image contrast is low and the visualization effect is poor. At present, the commonly used contrast correction and enhancement methods mainly include Retinex theory image enhancement, histogram equalization and morphological filtering. Retinex theory image enhancement method removes light components according to color constancy to ensure the reflective properties of objects. However, in this kind of method, halo phenomenon appears in the region of edge mutation after image processing [15]. Histogram equalization method has the advantages of simple algorithm and high timeliness, but poor adaptive performance for different brightness regions in images with uneven illumination [16]. Morphological filtering can enhance the visibility of images, but the natural characteristics of objects will change [17].
Aiming at the problems of distortion, obvious halo effect in edge area, overall dark and low contrast of restored image, a power image defogging algorithm with edge protection, eliminating halo effect and enhancing contrast was proposed. In this algorithm, multi-scale Retinex (MSR) algorithm and Sobel edge detection operator are combined to convert RGB (Red, Green, Blue) images into Lab color space and perform edge preservation processing. Secondly, guided filtering algorithm is used to optimize the image transmittance. Then fog-free images are obtained using atmospheric scattering model. Finally, the fog-free image is transformed into HSV color space, and the brightness component is adjusted by two-dimensional gamma function to enhance the contrast. Finally, a fog-free image with well-protected details, natural colors and distinct layers is obtained.

Retinex theory
According to Retinex theory, a given image S(x,y) can be decomposed into reflection image R(x,y) and incident image L(x,y) [18], where (x,y) is the coordinate of the image midpoint, and S(x,y) can be expressed as: L(x,y) determines the dynamic range of the image, and R(x,y) determines the intrinsic properties of the image. Gaussian filtering function F(x,y) is usually used to process S(x,y), which can be obtained: Where * is the convolution symbol. In order to obtain R(x,y), the image is transferred to the logarithmic domain for solution, expressed as:

Atmospheric scattering model
Nayer and Narasimhan improved the atmospheric scattering model. This model describes the causes of image degradation based on image degradation in foggy days [19], and the mathematical expression is: Modified dark channel prior based on multi-scale Retinex for power image defogging Where, I(x) is the obtained foggy image. J(x) is a clear fog-free image. A is atmospheric light value. t(x) is the transmittance, and the value range is (0,1). It represents the light loss caused by external factors in the process of transmission, and finally reaches the imaging equipment after removing the loss part. d(x) is the depth of field of the scene light.  is atmospheric scattering coefficient.
The t(x) of each channel can be expressed as: Where c is the RGB color channel.

Dark channel prior theory
In most local areas of outdoor fog-free images (non-sky areas), there are some pixels with very low and small values in at least one color channel, which tend to approach. Hence it is named as dark channel. He et al. [7] made statistics and observation on dark channel maps of more than 5000 fog-free images, and found that about 75% of the pixels had 0 values, and 90% of the pixels had very small values concentrated in [0,16]. The dark channel of the image is expressed as: Where dark J is the minimum channel map of fog free image.Ω(x) is the window size of the minimum value filter. According to equations (5) and (8) is the minimum channel map of foggy image.  is the fog retention coefficient and its value range is [0,1]. Finally, the restored image is: Where 0 t is the lower bound of transmittance and the value is 0.1.

Proposed defogging model
In this paper, an image defogging and restoration method is proposed. The algorithm can solve the problems of halo effect, fog sensation, overall image darkening in some unevenly illuminated foggy images, and the large brightness difference between the light and dark areas of the image, which can not reflect the details.
The RGB image is converted into Lab space, and the edge detection of L component is carried out by Sobel operator. According to MSR theory, Gaussian filtering is performed on non-edge regions to remove L components. A more accurate transmittance can be obtained by optimizing the transmittance roughly estimated by dark channel prior theory using guided filtering. The atmospheric light value is selected by improved Quadtree subspace search method. This method can avoid excessive value of global atmospheric light. The atmospheric scattering model can be used to reconstruct the fog image. In order to further optimize the image, adjust the brightness and enhance the contrast, the image is first transformed into HSV space and the V component is extracted. Then, V component is processed by twodimensional gamma function, and finally RGB image is synthesized to obtain fog-free image after brightness correction. The processing flow of the proposed algorithm is shown in figure 1.

Improved MSR algorithm for Lab color space
In order to avoid that the color fidelity and detail retention of images cannot be balanced when the single-scale Retinex algorithm processes different images, MSR algorithm is introduced in this paper. This algorithm can enhance image color and compress local and global dynamic range simultaneously. The mathematical expression of MSR algorithm is: Where r(x,y) is the preliminary estimated reflection component. N is the number of central wrapping functions. n  is the weight. At the edge where the difference of image brightness is large, the image brightness does not transition smoothly. Therefore, Retinex algorithm applicable to smooth image has obvious halo effect on non-smooth image and fails to improve the area details with high illumination intensity.

Processing of luminance component
The traditional MSR algorithm is used to enhance the three color channels of the image. Due to the mutual influence of color channels, color distortion appears in the final image. However, in Lab color space, the three channels are independent of each other. When only the brightness component is processed, the a component (green to red variable) and the b component (blue to yellow variable) remain unchanged, so the accurate analysis of the processed image will not be inconvenient.
Since the brightness component has little influence on the image and the reflection component has a great influence on the image color, in order to eliminate the influence of the brightness component on the image, the brightness component is separated according to Retinex theory, and the remaining reflection component can optimize the foggy image. Therefore, in Lab color space, the brightness component is extracted and processed, then the image S can be expressed as: Where L' is the incident image after extracting brightness component. For the convenience of calculation, Equation (12) is converted to the logarithmic domain for solving, and the expression is: L'(x,y) is estimated in Lab space using Gaussian convolution, it is expressed as:  (16) When  value is small, the detail information is kept well and the dynamic range is compressed well, and the global characteristics of extracted illumination values are good. However, the color cannot be maintained. When  value is large, the color can be better maintained and the extracted illumination value has good global characteristics, but the detail information is poorly maintained.

Edge preserving
When Retinex algorithm is used to process edge details, it is easy to lose the restored image edge details, so Sobel edge operator is used to obtain edge information E(x,y). In order to save the edge details in the restored image, the image is divided into two parts: edge region and non-edge region. Multi-scale Gaussian filter is used to process the non-edge region, and the brightness component of the non-edge region is obtained. Finally, the brightness component containing the fused edge information is obtained, it is expressed as: According to equations (15), (16) and (19), the initial estimated reflection component can be obtained, and the expression is: Back to RGB color space and take R(x,y) as the image to be processed.

Transmittance optimization
The dark channel of R(x,y) is represented by dark J .
According to the dark channel prior theory, the rough estimation of transmittance can be expressed as: The dark channel prior algorithm proposed by He et al. [7] used minimum filtering, which leaded to too small transmittance at the edge of foggy image, and details were covered. The obtained transmittance has obvious block effect, and the image at the restoration has obvious halo effect [20]. In order to obtain a better transmittance, the guided filtering algorithm is used to optimize the transmittance. Guided filter is a combination of domain filter and range filter, which can protect edge details and reduce noise. The expression of the guide filter is:

Local atmospheric light estimation
In order to obtain the atmospheric light value closer to the real value, the quadtree subspace block search method is used in the experiment. This method can extract the local features of the image and eliminate the phenomenon that the restoration effect is not ideal due to the inaccurate estimation of atmospheric light value.
To reduce the influence of sky region or bright light source on the acquisition of atmospheric light in the image, histogram equalization is carried out on the image first, and then the processed image is divided into four sub-rectangular regions. Then, the pixel mean minus the pixel standard deviation was used as the scoring standard and the four regions were scored. The region with the highest score is processed by the above steps until the number of pixels in the selected region is less than the set threshold. Finally, the corresponding pixel value is selected in the RGB color channel of the region and taken as the atmospheric light value.

Contrast enhancement
Processing brightness components in HSV space can avoid large computation, poor timeliness and color distortion in RGB space [21,22]. According to Retinex theory, the multi-scale Gaussian filter function can effectively compress the dynamic range and accurately estimate the irradiation component of the scene. So the multi-scale Gaussian filter function is used to extract the illumination component. In view of the large difference of illumination brightness in different areas of the image, and in order to improve contrast and highlight details, the improved two-dimensional gamma function is used to process the image, and the mathematical expression is: The two-dimensional gamma function takes the illumination value at each pixel point as a parameter and combines it with the mean value of brightness component to improve or reduce the illumination value in different areas to achieve adaptive correction, so as to generate new HSV images and finally convert them into RGB images. The purpose of brightness correction is to compress the dynamic range of the image, enhance the contrast and improve the image quality while preserving the effective information of the original image.

Experiments and analysis
The software used in the experiment is MATLAB 2017, the operating system is Windows10, the processor is Intel (R) Core (TM) i78750H CPU@2. 20 GHz, and the memory is 24.0 GB. The proposed algorithm is compared with other classical algorithms and the experimental results are analyzed from both subjective and objective aspects. Although subjective analysis has certain one-sidedness, it can observe the effect of image restoration most directly. The selected images are divided into three groups of images according to their different properties: close shot group, far and near alternated group and distant shot group. The proposed algorithm is compared with literature [7][8][9]12]. The effect comparison of the close-up image is shown in figure 3.  [7]; (c) Ref. [8] ; (d) Ref. [9]; (e) Ref. [12] ; (f) proposed algorithm

Subjective assessment
As can be seen from figure 3, the fog in the image is basically eliminated in reference [7] and more details are recovered, but obvious halo effect appears in the edge area, and the restored image is dark in the case of white highlighting area. The algorithm in reference [8] is simple and fast, but the recovery effect of edge details is poor, and there is obvious halo effect and the color distortion of restored images is serious. The haze treatment in reference [9] has a relatively obvious effect, but the restored image still has a sense of fog, and the color of the restored image is dark. The restoration effect of reference [12] is good, but residual fog still exists at the abrupt change of depth of field, and the existence of highlight area will lead to the overall darkening of the image. Compared with other algorithms, the proposed algorithm has the best haze removal effect, the overall color of the image is natural, and there is no halo phenomenon at the sudden change of the depth of field.
The effect comparison of near and far alternating images is shown in figure 4. As can be seen from figure 4, the image restored in reference [7] is dark in the closerange area, with distortion in the sky area and block effect at the edge, which is caused by the insufficient estimation of transmittance in the sky area. In reference [8], the processing effect of perspective image is poor, and the sky area after processing is seriously distorted, and there is halo effect. Reference [9] has a good restoration effect for the sky region, but the estimated atmospheric light value is too large, leading to the dark close-range region, and the restoration effect of detail information is poor. The end-to-end system defogging algorithm proposed in reference [12] has excellent performance and can effectively restore the sky area and details, but the problem of incomplete defogging still exists. The proposed algorithm has the most obvious haze removal effect, and has a good restoration effect on the sky area, and the color restoration effect in the close-range area is natural, and the detail restoration is better.  [7] ; (c) Ref. [8] ; (d) Ref. [9] ; (e) Ref. [12] ; (f) proposed algorithm A comparison of the effects of a distant image is shown in figure 5. As can be seen from figure 5, the image processed in reference [7] shows color distortion in the sky region and obvious halo effect. After processing in reference [8], the color of the image is dark, and the color distortion of the sky region is serious. Reference [9] can recover most of the details, and the processing effect of sky area is good, but the overall image after restoration is dark and the processing effect of fog image is mediocre. Reference [12] has a good restoration effect on the sky area, but the fog in the prospective area cannot be completely removed. Compared with other algorithms, the proposed algorithm has better defogging effect and can restore rich details with clear images, but the phenomenon of over-saturation occurs in the close-range area.  [7];(c) Ref. [8] ; (d) Ref. [9]; (e) Ref. [12]  From subjective perspective, the proposed algorithm has a better treatment effect, can effectively to fog, a more natural and truly restored image, and can enhance the image contrast to highlight the details, but not only from subjective judgment to evaluate the restored image, also from its objective standard evaluation to verify the feasibility and validity of the algorithm.

Objective evaluation
The objective evaluation recovery indexes are visible edge p , mean gradient r , peak signal to noise ratio (PSNR) [23][24][25][26][27] and running time  Table 1-4. It can be seen from Table 1 that the proposed algorithm has obvious advantages, which can eliminate the influence of brightness component in the fusion edge information and protect the edge details. It can be seen from Table 2 that the proposed algorithm has a great improvement compared with other classical algorithms. As can be seen from Table 3, the restoration result of reference [12] is superior to the proposed algorithm, while the restoration result of the proposed algorithm is superior to reference [6][7][8]. As can be seen from Table 4, the algorithm in references 7-8 is simple and can save time, while the algorithm in reference [8,12] and the proposed algorithm are slightly less time-efficient. The proposed algorithm takes a long time to accurately calculate atmospheric light value, optimize transmittance and enhance contrast. At the same time, the proposed algorithm can quickly eliminate the influence of illumination components according to Retinex theory, so the proposed algorithm has good timeliness. In conclusion, the performance of the proposed algorithm is better.

Conclusions
In order to solve the problems that dark channel prior algorithm can easily lead to low transmittance, halo effect at the edge of depth of field and insufficient estimation of atmospheric light value in processing images with bright regions, this paper proposes a dark channel prior algorithm combined with multi-scale Retinex algorithm. The influence of brightness component is extracted and eliminated in Lab color space to avoid the influence of traditional Retinex algorithm on image color. Edge extraction can effectively increase the details of the restored image and avoid the halo effect caused by minimum filtering. The rough transmittance is processed by guided filtering and the transmittance is effectively smoothed. In HSV space, the brightness component is processed by two-dimensional gamma function, which can correct the brightness value of different regions, thus achieving contrast enhancement and finally obtaining the optimized fog-free image. Experimental results show that the proposed algorithm has good processing effect on close shot, near far alternating and distant image, and the restored image has rich details, natural color and good processing effect on sky or highlight area, and has obvious advantages in objective evaluation. However, the proposed algorithm is prone to over-saturation in the processing of the close-up part of the distant image, so further processing of color deviation is one of the focuses of the following research.

R E T R
A C T E D EAI Endorsed Transactions Scalable Information Systems 03 2022 -04 2022 | Volume 9 | Issue 36 | e10