# Adaptive Tolerance Dehazing Algorithm Based on Dark Channel Prior
## 3 Our Improved Method  
### Calculation of Adaptive Tolerance  
It can be seen from Figure 2 that selecting a suitable value of tolerance can make the bright area of the restored image undistorted and retain more effective information. Therefore, we need to calculate an adaptive value of tolerance to recover the hazy images with different characteristics. After many experiments, we find that the larger the proportion of bright areas in the whole image, the higher the \(K\) value required to recalculate the transmission. When the bright area is small in the image (for example, yellow clouds or branches and poles in the sky will reduce the proportion of the sky in the whole picture), taking the smaller \(K\) value will retain more details. At this point, the problem is converted to how to calculate the adaptive \(K\) value by the proportion of the bright area so that it can have a good recovery effect for all images. Similar to introducing the tolerance \(K\), we introduce \(|I(x)\)-\(A|\) to record the difference between pixel \(I(x)\) in the hazy image and the atmospheric light \(A\). The average image contrast reflects the concentration of the haze to some extent. In addition, through experiments, we further found that images with different contrasts have different dehazing effects on images with different tolerance values. The average contrast of the images is positively correlated with the tolerance value. The larger the average contrast of the image, the larger the tolerance value. Therefore, we use the average contrast as the threshold parameter for calculating the tolerance,  
Figure 3: Restored images before and after using the tolerance mechanism. Figure 2: Dehazing effect diagram corresponding to different tolerance values. and use it as an index and compare it with \(|I(x)\)-\(A|\) to determine whether the pixel belongs to a bright area. The formula is as follows:  
\[K_{1}=\left[\frac{\left\langle\left|I(x)-A\right|<\alpha*C\right\rangle_{num}}{ I_{num}}*100\right] \tag{12}\]  
The experimental results show that when \(\alpha\) is set to 2, there is a better dehazing effect. In the above formula, \(I_{num}\) is the number of pixels in the entire image, and the contrast \(\alpha^{*}C\) is a threshold, which is used to determine whether the pixel belongs to the bright region. If the value of \(|I(x)\)-\(A|\) is less than the threshold, it means that the pixel belongs to a bright area, and the numerator represents the number of pixels belonging to the bright area in the entire picture. \(C\) is the contrast of the image, and the calculation formula is as follows [29]:  
\[C=\sqrt{\frac{1}{MN}\sum\
olimits_{i=0}^{N-1}\sum\
olimits_{j=0}^{M-1}\left( I_{ij}-I_{mean}\right)^{2}}, \tag{13}\]  
where intensities \(I_{ij}\) are the \(i\)-th \(j\)-th element of the two-dimensional image of size \(M\) by \(N\). \(I_{mean}\) is the average intensity of all pixel values in the image. Figure 4 shows the transmission map and restored images obtained using different algorithms. The first line is the dehazing effect after using the algorithms of He [8], and its transmittance image is obtained directly by using Equation (7) after using the DCP algorithm. So the transmittance of the distant sky area is close to zero, and it can be clearly seen that the color distortion of the sky area is serious. The second line is the dehazing effect after introducing the empirical tolerance to correct the transmission rate. It has some improvement compared with the algorithm of He [8]. The third line is the transmission map and the restored image obtained by using the improved algorithm of this paper. The adaptive tolerance K = 62 is calculated according to the characteristics of the image itself, as shown in Equation (12). The transmittance value of the distant sky region of the second and third rows of Figure 4 is calculated by the Equation (10) to be between 0 and 1. It can be seen from Figure 4 that the improvement effect of the adaptive tolerance determined by the image feature on the color distortion of the sky region is most obvious.