# A Single Image Enhancement Technique Using Dark Channel Prior
## 2 Dark Channel Prior Algorithm
### Disadvantages of Defogging Using Dark Channel Prior  
In the soft mating algorithm, the matting model can be formulated as:  
\[I=Fa+B(1-a) \tag{7}\]  
where \(F\) and \(B\) represent foreground and background areas, respectively, \(a\) is the transparency of the foreground. Assuming that the refined transmittance is \(t(x)\), and \(t(x)\) and \(t^{\prime}(x)\) are re-written to \(t\) and \(t^{\prime}\), the objective function of soft matting can be formulated as:  
\[E(t)=t^{T}Lt+\lambda(t-t^{\prime})^{T}(t-t^{\prime}) \tag{8}\]  
where \(t^{T}Lt\) and \(\lambda(t-t^{\prime})^{T}(t-t^{\prime})\) are the smoothing term and data term, respectively, \(\lambda\) is a weighting factor, \(L\) is a matte Laplacian matrix, and the elements \((i,j)\) in \(L\) are defined as:  
\[\sum_{k(ij)\in\omega_{k}}(\theta_{ij}-\frac{1}{|\omega_{k}|}(1+(I_{i}-u_{k})^{ T}(\sum_{k}+\frac{\gamma}{|\omega_{k}|}U_{3})^{-1}(I_{k}-u_{k}))) \tag{9}\]  
where \(u_{k}\) and \(\sum_{k}\) are the mean and variance of the matrix in the window \(\omega_{k}\). \(I_{i}\) and \(I_{j}\) denote the color of the input image \(I\) at pixels \(i\) and \(j\), respectively. \(\theta_{ij}\) represents the Kronecker function, \(U_{3}\) represents a 3 \(\times\) 3 identity matrix, \(\gamma\) represents a normalization parameter and \(|\omega_{k}|\) denotes the number of pixels in the window \(\omega_{k}\). We can get the optimal \(t\) by solving the sparse linear system of Equation (10):  
\[(L+\lambda U)t=\lambda t^{\prime} \tag{10}\]  
Using this matting algorithm to repair the acquired transmission can achieve satisfactory results, but the algorithm involves the reversible operation of a large matrix, which takes up more than 95% time of the defogging algorithm. Aiming at using the soft matting technology to refine the transmittance results in a high time complexity, we use guided filtering instead of soft matting to refine the transmittance, which can not only maintain the edge information, but also shorten the defogging time. Dark channel prior defogging algorithms use minimum filtering strategy in the process of obtaining transmittance. Then, using local block area \(\omega(x)\) as a template to perform point-by-point calculations, and take the minimum value of the R, G, and B channels in the block area as the dark channel value of the center pixel. Finally, the transmittance is estimated by the dark channel prior theory. The local filtering process shows that the transmittance of each pixel in the image is obtained by estimating the transmittance of the pixels in its adjacent area, but it is not the true transmittance value. Figure 1 shows local filtering for smooth depth of field and depth-changing edges. Among them, 3 \(\times\) 3 local block is the filter window \(\omega(x)\), the dark box area represents its central pixel, the A-side area is a distant area with low pixel intensity, and the B-side area is a near-field area with high pixel intensity. As shown in Figure 1(a) (left side), when the filtering window \(\omega(x)\) is a scene with a smooth depth of field (the filtering window is the highlighted area of close scene B in the figure), the dark channel value of the central pixel can be accurately obtained through the minimum filtering. The transmittance of each pixel in the window can take approximately the same value, and it can achieve the desired defogging effect. As shown in Figure 1(b) (right side), when the depth of filter window \(\omega(x)\) changes (the boundaries of A and B regions in the filter window), the dark channel value of the central pixel obtained by the minimum filter will become small, and the transmittance value of the pixels in the window are not similar. In this way, a dark transition zone (C region as shown in Figure 1(b)) will appear between A and B regions after filtering, resulting in the blur of depth-changing edges in the defogged images, thereby causing obvious edge effects.