# Adaptive Tolerance Dehazing Algorithm Based on Dark Channel Prior
## 3 Our Improved Method
### Threshold of Tolerance Mechanism  
We know that the value of adaptive tolerance \(K\) needs to be used to adjust the transmission only when the dark channel prior is invalid in the sky area or in the bright area of the scene, while other regions use the original dark channel prior to calculating the transmission, it can also obtain a better dehazing effect. Unfortunately, when there is a dense haze area or a third-party direct light source (sunlight, headlights, reflected glare, etc.) in the image, it is misjudged as sky area because the brightness of these areas is similar to the brightness of the atmosphere. As a result, the transmission of these regions is excessively increased, resulting in a serious loss of image detail in the region.  
We find that the common feature of the bright areas of misjudgment is that the proportion in the image is small, basically no more than 5% of the entire image's pixel. Therefore, we must first determine whether there is a large area of bright areas in the image before calculating the value of tolerance \(K\). If the bright area does not exceed 5% of the entire image's pixels, indicating that there is no large bright area in this image, then the value of tolerance should be as small as possible to maintain the original transmission for the dehazing calculation. If the bright area exceeds 5% of the entire image's pixels, then there is a large area of the sky in this image. At this time, it is necessary to calculate the value of adaptive tolerance \(K\) using Equation (12) to adjust the transmission. The final formula of tolerance K is as follows:  
\[K=\left\{\begin{array}{ll}K_{1}&thd>5\%\\ 0.01&thd<5\%\end{array}\right. \tag{14}\]  
\[thd=\frac{\left(I(x)>I_{th}\right)_{num}}{I_{num}}, \tag{15}\]  
where the numerator in the formula is the number of pixels that satisfy the condition, and \(I_{num}\) is the number of pixels in the entire image. We set the threshold \(I_{th}\) to 190 because the pixel values of the bright regions are relatively average and high.  
The 5% mentioned in Equation (14) is a threshold value to decide whether or not the image introduces adaptive tolerance to modify the transmission function. This parameter was determined after extensive experimental observation. As shown in Figure 5, the proportion of the bright areas of the five images is 3.223%, 1.78%, 5.78%, 6.761%, and 27%, respectively. The first three images do not have a large area of the sky, and the proportion of bright areas is less than 5%. The details of the image can be saved without using a tolerance mechanism. The last three areas have sky areas, and the bright areas account for more than 5%. Using the tolerance mechanism can reduce the distortion of the sky area image. Figure 5 shows the restored image corresponding to the different judgment values of whether or not to use the tolerance mechanism in this paper. Setting the threshold to 5% to determine whether to introduce adaptive tolerance to modify the transmission function can enhance the effectiveness of the proposed algorithm for different pictures.  
Figure 5: _Cont._