PICTURE DE-HAZING TECHNIQUE

by Babak Khademi and Peter Yu

Download the DEMO code (approximately 67 megabytes)

Introduction:

In this project we explore a way to eliminate haze from pictures that are shot either in foggy weather conditions or any other obstacles in the air that destroys the clarity of image. This problem is most signified with larger distant images and especially in aerial imagery. This approach is based on a work done by Yoav Y. Schechner, Srinivasa G. Narasimhan and Shree K. Nayar in their paper on "Instant Dehazing of Images Using Polarization". The main principle here is to find a way to separate the haze content from the actual image content and then subtract that haze part from the mixture to end up with a clear picture. The way we find the haze content is through using a polarization filter in front of a camera and alter the orientation of it for different angles and gather all those images. Then in the back-end, we fed the data to a MAtlab processing code which will determine the haze content from all these images collectively and then with simple math equation we subtract the haze or as we call it "Airlight" from the compromised image to get the clear picture. This method is very precise in finding and removing the haze which makes it possible to enjoy a much clearer image at the end.

Problem:

An example image is shown below to demonstrate the problem of haze in images. The image clarity is compromised in hazy weather conditions and smog, fog, and aerial particles block the true nature of image.


Image from Robby Tan, Niklas Pettersson, Lars Petersson's paper 'Visibility Enhancement for Roads with Foggy or Hazy Scenes'

Polarization Dehazing:

In order to solve this problem, polarization can be used to determine the haze content of the image and then this haze can be subtracted from the image to get the original clear picture. An example of a dehazed image is shown below.


Image from Robby Tan, Niklas Pettersson, Lars Petersson's paper 'Visibility Enhancement for Roads with Foggy or Hazy Scenes'\

 

Single-Image Dehazing:

There are many algorithms that remove haze from an image. One of those algorithms is proposed by Raanan Fattal from the Hebrew University of Jerusalem in Israel. His paper is called "Single Image Dehazing" and he shows a technique that estimates the haze content of an image and removes it. The pros of this approach is that it does not require initial equipment setup and can be applied to any picture. The drawback is that it is not as accurate as polarization based dehazing.


Images from Raanan Fattal's Paper "Single Image Dehazing"

 

What is Polarization?

Polarization is used in many applications such as sunglasses, LCDs, and professional cameras. The basic premise is that light can be blocked by using a filter.

Airlight is polarized and thus can be filtered out using a polarization filter. By altering the orientation of a polarization filter on a camera, different amounts of haze can be captured. Thus, by capturing two images, the haze content of an image can be determined simply by subtracting one image from the other.

 


Image from 'whatis.techtarget.com'

 

Algorithm:

The algorithm developed was based on Schechner, Narasimhan and Nayar's paper "Instant Dehazing of Images Using Polarization." The main algorithm is written in MATLAB and to run the algorithm, simply type "dehaze_demo." The code first reads in two polarized image files (DSC_0011.NEF and DSC_0014.NEF). The image files are in RAW format (specifically Nikon file format - NEF) and are read into MATLAB using "nefReadImageDCRaw.m". The code was developed by Manu Parmar, a Stanford PhD student. DCRaw is used to read in the image to a data format that can be manipulated by MATLAB. Next, the two image files are registered with each other using "Unaided_Image_Registration3.m", which was developed by Vlachos Marios, a student from the University of Patras, Greece. The code has been altered somewhat for this application.

Then, the two images are subtracted from one another to estimate the airlight. The airlight is basically the haze content of the image.

With this, the airlight can then be subtracted from the image to give the user the transmitted image. The final dehazed image requires one additional processing step, which is to take into consideration the attenuation. As the camera is further away from a light source, the amount of light that reaches the sensor is less. The map of attenuation is created by finding the location of the maximum amount of airlight in the image (generally a portion of the sky) and then comparing that amount of airlight to the airlight at each region in the image. Once the attenuation map is created, the transmitted image is compensated for and the final dehazed image is created. The user can view the dehazed image by simply typing "imshow(dehazed_image)".

There are two other image files in the archive, DSC_0006.NEF and DSC_0018.NEF. The first image is the color target up close. The user can compare the dehazed image target (located inside the stadium) with this image to see how accurate the dehazing was. DSC_0018.NEF is the image of the scene without any polarization filters.

 


Schechner, Narasimhan, and Nayar's paper 'Instant Dehazing of Images Using Polarization

 

Logistics for Acquiring the Data:

-Created targets with known color content
-Laid out the target on Stanford Stadium seats

-Setup camera equipment at the Dish
-Snap shots from far away
-Used polarization filter with different orientations

 

Polarization Dehazing:

Below are the results from the demo code.


Unpolarized image

                                                       

                                             

                               Polarized image 1 (T/2 + Airlight1)                     Polarized Image 2 (T/2 + Airlight2)

 


Estimated airlight (obtained by subtracting polarized image 1 from polarized image 2)

 


Corrected image (Direct transmission, obtained by subtracting airlight from total image)


Estimation of the attenuation (obtained by comparing maximum region of airlight to the rest of the image)


Comparison of hazy image (left) to dehazed image (right)


Comparision of Photoshopped corrected image (left) to dehazed image (right)

 

Conclusion:

We have shown that the polarization approach is more precise than single image dehazing techinque. The haze content is exactly traceable in polarization method which helps in subtracting the right content from the image to end up with the clear shot. However, in the single image dehazing the haze content is not exactly extractable due to limitations inherent to this technique which will result in a less crisp image.

Additionally, this technique allows the user to obtain better image quality under bad weather conditions. By applying this technique, the user is given the flexibility to take images in hazy weather conditions that provide image as if there were no particles in the air.

This technique should prove useful in aerial photography since many times haze poses a major problem. Taking images from high up at such distances results in images that contain haze. This project was created in collaboration with Google (Iain Mcclatchie and Peter Brueckner) to show that by using a camera rig containing polarization filters, clear images can be obtained.

 

Sources:

 

Acknowledgements:

           We would like to thank you all the members of Psych221 staff members who helped us along the project to realize this work. Specially, we want to recognize the leadership and efforts of Joyce Farrell to organize the logistics, the technical guidance of Manu Pramar and Dave Cardinal who helped us take some quality images with his camera. We also want to thank Prof. Brian Wandell for his great mentorship and coverage of the necessary materials in this field that helped us deal with this project in the first place. Thank you all.