Keywords

1 Introduction

Images of outdoor scenes are usually degraded due to various atmospheric factors like scattering of large number of suspended aerosol particles in the atmosphere resulting in poor visibility of image [1, 2, 11,12,13]. In last decade, many techniques have evolved to solve this problem, and many researchers come with different ideas. These techniques can be classified as physics based approach, dark channel approach, filtering approach etc. Furthermore, we made a comparative analysis of all three techniques along with their advantages and shortcomings over dark channel prior.

The remainder of this paper is organized as follows. Section 2 discusses some state of art methods on image dehazing techniques along with their relative advantages and disadvantages. Section 3 focuses on the methodology of Dark Channel Prior dehazing algorithm along with its pseudo code. Section 4 deals with result and discussion and also presented some objective measurements to evaluate the dehazing performance of Dark Channel Prior Technique. Section 5 concludes this paper and indicates some future work.

2 Literature Review

Hazy or foggy images are never desired ones. But in reality, we do face situations where picture quality is degraded due to bad weather conditions.

In this paper, we thoroughly get a rundown on some existing defogging techniques proposed by Nayar et al. [1], Al-Zubaidy et al. [2], Oakley et al. [3], Tan [4], He et al. [5], Wang et al. [6], Chen et al. [7] and Xu et al. [8].

In [1, 2], the proposed method in this paper is a weather condition based method. It tried to recover scene structure from one or two images without prior knowledge of atmospheric conditions.

Oakley et al. [3] technique is mainly concerned with correction of simple contrast loss due to added airlight in an image which is often caused by optical scattering of light due to fog or mist. First of all, for detecting the presence of airlight in an arbitrary image, a statistical model is formulated. It provides an algorithm to estimate the level of airlight in an image, assuming airlight to be constant throughout the image. It is based on finding the minimum of a global cost function, applicable to both monochrome and color images. After estimating airlight, image correction is performed.

In [4], we come across a method where a single image is taken as input and haze is removed by maximizing the local contrast of the restored image. At first estimation of atmospheric light and light chromaticity is done. Using it, removal of light chromaticity is done, then using the chromaticity, removal of light color from the input image is done and delta cost, smoothness cost for every pixel is evaluated. This further leads to an estimation of airlight and thus finally computation of direct attenuation is done which enhances the visibility. This method solely works on enhancing the contrast.

In [5,6,7,8], dark channel prior statistics is used to remove haze from outdoor hazy images which is more efficient than previous state of art methods. It is based on the observation that local patches in outdoor haze free images contain pixels which have very low intensity in at least one color channel and this method is efficient than other existing defogging approaches. The summarization of different researchers on Image Dehazing Technique along with their advantages and shortcomings is depicted in Table 1.

Table 1. Summarization of different researchers on image dehazing techniques

3 Implementation of Dark Channel Prior Technique on Images

Images in the outdoor environment sometimes are captured hazy by the camera due to the presence of aerosol particles in the environment which causes the light to scatter. The incoming airlight blending with the scene radiance also poses a problem. A major problem is posed by the unknown depth as haze depends on this factor.

After analyzing procedure used in [5] Dark channel prior, we get the following output mentioned below. Every parameter and constraints mentioned in [5] are kept same here. Assumptions too are being kept same.

This paper deeply analyzes Dark Channel Prior Technique. The DCP technique for image dehazing is done through the following steps.

Formation of hazy images can be described by the following model:-

$$ I(x) = J(x)t(x) + A(1 - t(x)) $$
(1)

Where I, is the observed intensity, J is the scene radiance, t is the transmission medium defined by the light that is not scattered and reaches the camera, A is the atmospheric or global light. The term \( {\mathbf{J}}\left( {\mathbf{x}} \right){\mathbf{t}}\left( {\mathbf{x}} \right) \) defines the direct attenuation and \( {\mathbf{A}}\left( {\text{1} - {\mathbf{t}}\left( {\mathbf{x}} \right)} \right) \) defines the airlight.

The transmission, ‘t’ can be expressed in the form of the following formula

$$ t(x) = e^{ - \beta d(x)} $$
(2)

Where \( \beta \) is the scattering coefficient of the atmosphere and d is the scene depth.

Geometrically, the haze imaging Eq. (1) means that in RGB color space, the vectors A, I(x), and J(x) are coplanar, and their end points are collinear. The transmission t is the ratio of two line segments:

$$ t(x) = \frac{{A^{c} - I^{c} (x)}}{{A^{c} - J^{c} (x)}} $$
(3)

1. Estimating the transmission – We assume that atmospheric light A is given.

Normalizing Eq. (1), gives us:

$$ \frac{{I^{c} (x)}}{{A^{c} }} = t(x)\frac{{J^{c} (x)}}{{A^{c} }} + 1 - t(x) $$
(4)

Applying dark channel prior to it (4) we get:

$$ \mathop {\hbox{min} }\limits_{{y \in\Omega (x)}} \left( {\mathop {\hbox{min} }\limits_{c} \frac{{I^{c} (y)}}{{A^{c} }}} \right) = t(x)\mathop {\hbox{min} }\limits_{{y \in\Omega (x)}} \left( {\mathop {\hbox{min} }\limits_{c} \frac{{J^{c} (y)}}{{A^{c} }}} \right) + 1 - t(x) $$
(5)

Ac is always positive which means

$$ \mathop {\hbox{min} }\limits_{{y \in\Omega (x)}} \left( {\mathop {\hbox{min} }\limits_{c} \frac{{J^{c} (y)}}{{A^{c} }}} \right) = 0 $$
(6)

From (4) & (5) we get:

$$ t(x) = 1 - \mathop {\hbox{min} }\limits_{{y \in\Omega (x)}} \left( {\mathop {\hbox{min} }\limits_{c} \frac{{I^{c} (y)}}{{A^{c} }}} \right) $$
(7)

We have noticed that dark channel prior is not a good prior for sky region but fortunately, the color of the sky in a hazy image I is very similar to the atmospheric light A.

$$ \mathop {\hbox{min} }\limits_{y \in \varOmega (x)} \left( {\mathop {\hbox{min} }\limits_c \frac{{{I^c}(y)}}{A^c}} \right)\,{\rm{ {{-}{>}} }}\,1 $$
(8)

(8) gives t(x) -> 0 which is true because the sky is indefinitely distant.

We optionally keep a small amount of haze for perceiving the depth of distant object by introducing a constant parameter \( \omega \) which is set to 0.95 for this paper. The equation now becomes

$$ t(x) = 1 - \omega \mathop {\hbox{min} }\limits_{{y \in\Omega (x)}} \left( {\mathop {\hbox{min} }\limits_{c} \frac{{I^{c} (y)}}{{A^{c} }}} \right) $$
(9)

Therefore, a more generalized formula can be written as

$$ I(x) = J(x)t_{1} (x) + A(1 - t_{2} (x)) $$
(10)

As we can find the additive term using (8), so the problem is now only left for the multiplicative term J(x)t1(x).

  • Problem: As the transmission maps are not constant in a patch, it results in distortion of the image in the form of block artifacts.

  • Solution: Refine transmission maps by applying soft matting.

2. Soft Matting – (1) has a similar form as the image matting equation

$$ I = F\alpha + B(1 - \alpha ) $$
(11)

Where F and B are foregrounds, and background colors.

\( \alpha \) is the foreground opacity. As the transmission map in the haze imaging equation is exactly an alpha map, we can apply a closed-form framework of matting to refine the transmission.

$$ E(t) = t^{T} Lt + \lambda (t - \mathop t\limits^{\sim } )^{T} (t - \mathop t\limits^{\sim } ) $$
(12)

Here the first term is a smoothness term and the second term is a data term with a weight \( \lambda \). The matrix L is called the Laplacian matrix.

$$ (L + \lambda U)t = \lambda \mathop t\limits^{\sim } $$
(13)

Where U is an identity matrix of the same size as L.

3. Estimating the atmospheric light – Contrary to the method of assuming that the atmospheric light is known, now we will try to find out the most-haze opaque region. With reference to Tan’s work, the brightest region is assumed to be the most-haze opaque region which is true only when the weather is overcast and sunlight can be affectedly ignored. In this case, the atmospheric light is the only source of light. So, the scene radiance of each color channel can be represented as

$$ J(x) = R(x)A $$
(14)

Where \( R \le 1 \) is the reflectance of the scene points. The haze imaging model can now be written as

$$ I(x) = R(x)At(x) + (1 - t(x))A \le A $$
(15)

But for practical purposes, we cannot ignore sunlight, so the equation becomes

$$ I(x) = R(x)St(x) + R(x)At(x) + (1 - t(x))A $$
(16)

From this equation, we can conclude that the brightest pixel in the image can be brighter than the atmospheric light.

  • Problem: The brightest pixels in an image can be brighter than atmospheric light.

  • Solution: Using dark channel method for finding the most haze opaque region in the image and then selecting top 0.1 percent brightest pixels in dark channel for improving estimation of atmospheric light.

4. Recovering Scene Radiance – We can recover the scene radiance according to (1) by using estimated atmospheric light and the transmission map.

  • Problem: When the transmission t(x) is close to zero, J(x)t(x) can be very close to zero causing directly recovered scene radiance to be noisy.

  • Solution: Providing a lower bound t0 (typical value = 0.1) to the transmission, t(x).

Therefore, final scene radiance is J(x) is recovered by

$$ J(x) = \frac{I(x) - A}{{\hbox{max} (t(x), {\text{t}}_{0} )}} + A $$
(17)

We increase the exposure in the final recovered image since the haze-free image has lower scene radiance.

5. Size of the patch – Patch size of 15 × 15 is taken here. This paper establishes the pseudocode of DCP Technique which is described below.

Dark Channel Prior Pseudocode:

MAIN()

Input – A single hazy image \( I(x) = J(x)t(x) + A(1 - t(x)) \).

Output – A de-hazed image.

Initialization

  1. 1.

    Select a hazy image and read the image into a variable imageRGB.

  2. 2.

    Resize the image with scaling factor 0.1.

  3. 3.

    Find dark channel of the image using darkchannel(imageRGB) function and store into variable ‘JDark’.

    1. (3.1)

      Select a JDark zero matrix.

    2. (3.2)

      Select patch size as 15 and pad size as half of patch size i.e. 7.

    3. (3.3)

      Let height be height of imageRGB and width be width of imageRGB.

    4. (3.4)

      For j = 1 to height

    5. (3.5)

      For i = 1 to width

    6. (3.6)

      Patch = J(j : j + patchsize − 1), i : (i + patchsize − 1), :)

    7. (3.7)

      JDark = min(patch(:))

    8. (3.8)

      End For

    9. (3.9)

      End For

    10. (3.10)

      Return JDark.

  4. 4.

    Find atmospheric light using atmLight(imageRGB, JDark) function and store into variable ‘atmospheric.’

    1. (4.1)

      Create a vector of pixels of JDark in JDarkVec and vector of pixels of original image in imageRGBVec.

    2. (4.2)

      Sort the JDarkVec.

    3. (4.3)

      Store the last few indices of JDarkVec as those indices will have pixel value close to 1.

    4. (4.4)

      Let numpx be size of image by 1000.

    5. (4.5)

      Let atm be a zero matrix of size 1 × 3.

    6. (4.6)

      For i = 1 to numpx

    7. (4.7)

      atm = atm + imageRGBVec(indices(i), :)

    8. (4.8)

      End For

    9. (4.9)

      Return atmospheric = atm/numpx.

  5. 5.

    Find transmission light using transmissionEstimation(imageRGB, atmospheric) and store into variable transmission.

    1. (5.1)

      Take amount of haze we are keeping into a variable omega = 0.95.

    2. (5.2)

      For i = 1 to 3

    3. (5.3)

      im(:, :, i) = imageRGB(:, :, ind)./atmospheric(i)

    4. (5.4)

      End For

    5. (5.5)

      Return transmission = 1 – omega * darkChannel(im)

  6. 6.

    Apply soft matting to the image using matte(imageRGB, transmission) function and store into a variable refinedTransmission.

    1. (6.1)

      Take epsilon = 10^4 and lambda = 10^4.

    2. (6.2)

      Let matrix mattingLaplacian = sparse matrix with rows and columns as number of pixels of imageRGB.

    3. (6.3)

      For row = 2 to size of imageRGB(1) – 1

    4. (6.4)

      For col = 2 to size of imageRGB(2) – 1

    5. (6.5)

      Take matrix windowIndices with 4 elements row − 1, col − 1, row + 1, col + 1 and reshape imageRGB into window matrix using windowIndices. size.

    6. (6.6)

      Find covariance of mean of the matrix window.

    7. (6.7)

      Take inverse of the matrix window.

    8. (6.8)

      For firstRow = windowIndices(1) : windowIndices(3)

    9. (6.9)

      For firstCol = windowIndices(2) : windowIndices(4)

    10. (6.10)

      mattingLaplacianRow = ((firstRow – 1) * imageSize(2)) + firstCol;

    11. (6.11)

      For secondRow = windowIndices(1) : windowIndices(3)

    12. (6.12)

      For secondCol = windowIndices(2) : windowIndices(4))

    13. (6.13)

      mattingLaplacianCol = ((secondRow – 1) * imageSize(2)) + secondCol;

    14. (6.14)

      If(mattingLaplacianRow == mattingLaplacianCol) then

    15. (6.15)

      kroneckerDelta = 1;

    16. (6.16)

      Else then

    17. (6.17)

      kroneckerDelta = 0;

    18. (6.18)

      End If

    19. (6.19)

      Set mattingLaplacian = mattingLaplacian + (kroneckerDelta − windowInvNumPixels * (1 + transpose(rowPixelVariance)/windowInvCovarianceIdentity * colPixelVariance));

    20. (6.20)

      End For.

    21. (6.21)

      End For.

    22. (6.22)

      End For.

    23. (6.23)

      End For.

    24. (6.24)

      End For.

    25. (6.25)

      End For.

    26. (6.26)

      Return refinedTransmission = transpose of matting Laplacian + lambda product of transimission divided by lambda product of the number of pixels in imageRGB.

  7. 7.

    Find scene radiance using getRadiance(atmospheric, imageRGB, refinedTransmission) and store into dehazedImage.

    1. (7.1)

      Take lower bound of transmission light, t0 = 0.1.

    2. (7.2)

      For i = 1 to 3

    3. (7.3)

      DehazedImage(:, :, i) = atmospheric(i) + (imageRGB(:, :, i) – atmospheric(i))./max(refinedTransmission, t0)

    4. (7.4)

      End For.

    5. (7.5)

      Return DehazedImage = DehazedImage./max(max(max(DehazedImage)))

  8. 8.

    dehazedImage is the desired output

4 Result and Discussion

Original and processed images have been implemented on Benchmark images [2,3,4,5] and some real time images collected from different sources [14]. Both sets of real time data set and bench mark data set are being implemented by the dark channel prior algorithm that has been depicted in Fig. 1. From Fig. 1, it is understood that although this technique produces good results in hazy or fog degraded images but if the image consists of sky region, the algorithm fails to produce a good quality image.

Fig. 1.
figure 1

(a) Input hazy image collected from different sources [2,3,4], (b) Dark channel, (c) Transmission map, (d) Radiance, (e) Output image

The next stage of the experiment demonstrates a qualitative assessment evaluation or performance evaluation based on reference and non-reference strategies on the fog degraded images to examine the efficiency of the technique used.

4.1 Performance Evaluation

Performance Evaluation is conducted based on non-reference methods and reference methods, and it has been observed that using these methods the quality of the restored image is much effective than the original fog degraded image. We have implemented these assessment techniques on the color images of size 300 * 300.

4.1.1 Non-reference Methods

Non-reference Methods are some methods used for evaluation of restored images where no reference image is available for the input/degraded image. Generally, the non reference methods that are used for evaluating the haze free output image is determined by three parameters e, r and \( \sigma \). Any better enhancement technique should have higher values of e, r and lower values for \( \sigma \) [9]. Figure 2 depicts the performance evaluation on sample image 4 based on non reference strategy.

Fig. 2.
figure 2

Performance evaluation on sample Image 4 based on non reference strategy

4.1.1.1 Increased Rate of Visible Edges

The increased rate of visible edges is determined by e metrices

It is represented as:

$$ e = \frac{{n_{r} - n_{0} }}{{n_{0} }} $$
(18)

Here nr and n0 are cardinal no. image of edges in original and contrast image. It depicts no of new edges that occur in the restored images.

4.1.1.2 Restoration Degree of the Image Edge and Texture Information

The Restoration degree of the image edge and texture information is determined by \( \overline{r} \) metrics. It is represented as:

$$ \overline{r} = \exp \left[ {\frac{1}{{n_{r} }}\sum {\log r_{i} } } \right] $$
(19)

4.1.1.3 Percentage of the Number of Saturated Pixels

The Percentage of the Number of Saturated pixels is represented as \( \sigma \) metrics.

It is represented as:

$$ \sigma_{y} = \frac{n}{M*N}*100 $$
(20)

It shows the no of pixels those have been saturated after the enhancement technique.

4.1.2 Reference Methods

Reference-based parametric evaluation is performed when a reference image [10] is available. Here we have considered the reference image as original fog degraded image. Three different non reference metrics have been used here, i.e. Mean Square Error (MSE), Peak Signal to Noise Ratio (PSNR), Normalized Absolute Error (NAE) and MD. A higher value of PSNR and lower value of MSE and NAE indicates that the restoration efficacy of the output image produces better results.

From Table 2, it is clearly understood that Dark Channel Prior method performs well on fog degraded images and can efficiently dehaze the image.

Table 2. Performance evaluation of dark channel prior technique

5 Conclusion and Future Work

The problem of degradation in outdoor images because of poor atmospheric environment is a serious issue in computer vision-based applications. Images acquired by a visual system are severely degraded under the hazy and foggy weather, which will affect several computer vision based applications. Therefore, restoring the degraded image to its clear form is of great significance. The paper investigated many approaches about image dehazing algorithms. This paper performed an in-depth study of Dark Channel Prior Technique and implemented it on real time and benchmark dataset, and a comparative analysis is also being done. This paper also establishes the pseudocode of this dark channel prior technique. Finally, to evaluate the effectiveness of the technique used, different performance evaluation is carried out based on reference and non reference strategies. Experimental results demonstrate that the used methods show good results for fog degraded visual images but this technique has some disadvantage too. If the image consists of sky region, the algorithm fails to produce a good quality image and this problem need to be addressed.