# Adaptive Tolerance Dehazing Algorithm Based on Dark Channel Prior
## 2 Related Work
### Dark Channel Prior Dehazing Algorithm  
He [8] obtained a law by statistical analysis of a large number of outdoor haze-free images, that is, in most non-sky local regions, at least one color channel has some pixels whose intensities are very low and close to zero. This phenomenon is defined as the dark channel prior. These low pixel values are produced by shadows, colored objects, or the surfaces of darker objects. For the outdoor haze-free image \(J(x)\), the mathematical expression of the dark channel is:  
\[J^{dark}(x)=\min_{y\in\Omega(x)}(\min_{c\in[r,g,b]}J^{c}(y))\to 0, \tag{3}\]  
where \(J^{dark}\) is the dark channel image, which is always low in theory and infinitely close to zero. \(J^{c}\) is a color channel of \(J\), and \(\Omega(x)\) is a local patch centered on x. It can be clearly seen from Equation (3) that calculating the dark channel of a pixel is actually the process of finding the minimum twice.  
It is known from the atmospheric scattering model that the transmission \(t(x)\) and the ambient atmospheric light value, A, of the image must be known before recovering the haze-free image. First, the dark channel map of the hazy image can be solved by the dark channel theory:  
\[\min_{y\in\Omega(x)}(\min_{c\in[r,g,b]}(F(y))=t(x)\min_{y\in\Omega(x)}(\min_{ c\in[r,g,b]}(J^{c}(y))+A(1-t(x)) \tag{4}\]  
Both sides of the above formula are simultaneously divided by A as follows:  
\[\min_{y\in\Omega(x)}(\min_{c\in[r,g,b]}(\frac{I^{c}(y)}{A})=t(x)\min_{y\in \Omega(x)}(\min_{c\in[r,g,b]}(\frac{I^{c}(y)}{A})+A(1-t(x)) \tag{5}\]  
Assuming that atmospheric light A is a known value, the image transmission \(t(x)\) can be estimated by Equations (3) and (5):  
\[t(x)=1-\min_{y\in\Omega(x)}(\min_{c\in[r,g,b]}(\frac{I^{c}(y)}{A})) \tag{6}\]  
He [8] mentioned in the paper that even on sunny days, there are always some particles in the air. Generally, if you look at distant objects with the naked eye, you will still feel that the scenery is blurred. People can feel the depth of field in the scene through the haze. To be consistent with reality,a constant factor \(\omega\) (\(0<\omega<1\)) can be introduced in Equation (6) to retain some of the haze particles in the distance:  
\[t(x)=1-\omega\min_{y\in\Omega(\Omega)}(\min_{c\in[r,g,b]}(\frac{I^{c}(y)}{A})) \tag{7}\]  
The smaller the \(\omega\) value is, the less obvious the dehazing effect will be. According to experience, \(\omega\) generally takes a value of 0.95.  
The dark channel prior assumes that the transmission characteristics of the light in the local area are consistent, but this assumption is often not satisfied in the edge regions where the depth is inconsistent due to the discontinuity of the scene depth. For a hazy image, when the depth of the object in the local area \(\Omega(x)\) is the same, the dark channel image can be accurately obtained. However, when the depth of the field difference at the edge of the object in the local region \(\Omega(x)\) is large, the transmission value estimation in the local region is not accurate. Therefore, it is necessary to refine the transmission map so that the haze-free image can be better transitioned at the edge of the scene without the white halos. At the same time, to improve the efficiency of the algorithm operation, this paper uses the guided filtering algorithm proposed by [PERSON] [15], instead of the soft matting algorithm [9], to optimize the transmission map.  
When both \(A\) and \(t(x)\) have estimates, the atmospheric scattering model can be used to obtain a haze-free image. Since the transmission rate may be too small in some areas to cause the image \(J(x)\) value to exceed 255, it is necessary to set a threshold \(t_{0}\) for \(t\). In the study of [PERSON] [8], \(t_{0}\) was taken as 0.1. When the obtained \(t\) is smaller than the threshold \(t_{0}\), the threshold \(t_{0}\) is taken. The final haze-free image recovery formula is:  
\[J(x)=\frac{I(x)-A}{\max[t(x),t_{0}]}+A \tag{8}\]