# A Single Image Enhancement Technique Using Dark Channel Prior
## 3 Improved Image Defogging Method Based on Dark Channel Prior
### Improvement of High Time Complexity and Edge Effects of Dark Channel Prior Algorithm
#### 3.1.1 Atmospheric Light Value Estimation Based on Four-Point Weighting  
The estimation of the atmospheric light value in [PERSON]'s algorithm [11] is equal to 0.1% of the gray value in the global dark channel image, which will get poor results when the image contains a large bright area. In order to accurately estimate the atmospheric light value \(A\), this paper proposes a four-point weighting algorithm to find the optimal atmospheric light value.  
The atmospheric light value is obtained in the area with the highest fog concentration in the foggy image, where the area is generally defined as a rectangular area. For an image, when the fog concentration in the area is higher, the pixel value becomes higher, but the difference between the pixels becomes smaller, so the difference between the mean value and the standard deviation of the pixel becomes larger.  
To estimate the atmospheric light value \(A\) of an inputted image, as shown in Algorithm 1, we divide the input image \(I\) into four regions (i.e., \(i_{n}\), \(n=1,2,3,4\)) with the same size, and the difference of each region is calculated by Equation (11):  
\[S(n)=M(n)-D(n) \tag{11}\]  
where \(M(n)\) and \(D(n)\) represent the mean and variance of a region, respectively, \(n=1,2,3,4\) represents one of the four regions.  
We select the region with the largest difference in four regions. Then, the selected region is used as the new input image to repeat the above processing until the preset requirements \(Pr\) are met, and the final selected region is defined as \(Y(x)\). In this paper, the preset requirements \(Pr\) are defined as: (1) the size of the segmented area is less than 1/16 of the original input image; (2) there are two regions with the largest difference and the average of two regions is the same; (3) there are three regions with the maximum difference in four regions.  
In order to obtain the atmospheric light value \(A\) in the region \(Y(x)\), we first calculate the average pixel value \(M(n)\) of \(Y(x)\). Then, the pixels in \(Y(x)\) are divided into two parts according to the pixel value. All pixels larger than \(M(n)\) are called bright pixels, and all  
Figure 2: Comparisons of dark channel failure examples.  
pixels smaller than \(M(n)\) are called dark pixels. The number of bright and dark pixels are denoted as \(N_{b}\) and \(N_{d}\), respectively. Finally, we find the maximum values \(A_{b}\) and \(A_{d}\) of dark channel in the light and dark areas, respectively, and it is assumed that \(A_{b}\) and \(A_{d}\) are obtained at \(Y(n_{1})\) and \(Y(n_{2})\). The atmospheric value \(A\) is calculated as follows:  
\[\begin{cases}A=W_{b}*Y(n_{1})+W_{d}*Y(n_{2})\\ W_{b}=\dfrac{N_{b}}{L*W}\\ W_{d}=\dfrac{N_{d}}{L*W}\\ W_{b}+W_{d}=1\end{cases} \tag{12}\]  
where \(L*W\) denotes the size of the region, and the value of atmospheric light \(A\) is estimated by weighting \(Y(x)\). When \(N_{b}>N_{d}\), \(Y(n_{1})\) dominates the atmospheric light value A. When \(N_{b}<N_{d}\), \(Y(n_{2})\) dominates the atmospheric light value \(A\). \(Y(n_{1})\) and \(Y(n_{2})\) influencing \(A\) together makes the obtained atmospheric light value \(A\) reasonable. Thus, using the atmospheric light value \(A\) to remove fog from an image makes the defogged image consistent with the human visual system.  
```
Input image \(I\), Preset requirements \(Pr\) while!Pr do \(i_{n}=divide(I),n=1,2,3,4\) for\(m<n\)do \(S(n)=M(n)-D(n)\) endfor \(Sel=max(S(n))\) \(Sel_{index}=index(max(S(n)))\) \(I=i(Sel_{index})\) endwhile \(Y(x)=Sel\) \(M(n)=mean(Y(x))\) \(N_{b}=num(pixel>M(n))\) \(N_{d}=num(pixel<M(n))\) \(W_{b}=\frac{N_{b}}{L*W}\) \(W_{d}=\frac{N_{b}}{L*W}\) \(A=W_{b}*Y(n_{1})+W_{d}*Y(n_{2})\) Output: Atmospheric Light \(A\)
```  
**Algorithm 1** Four-point Weighting Algorithm