Table of Contents
The quality of the images taken under water may degrade due to factors such as medium scattering and absorption. The absorption substantially reduces the light energy, while the scattering causes changes in the light propagation direction. This degradation may cause the image to have low contrast or to contain a layer of fog. This repository provides a MATLAB implementation of a method to reduce the aforementioned negative effects and produce better versions of the underwater images. The method was introduced by Ancuti et al. [1].
One may ask "Why would we even bother to enhance underwater images?". The answer is that those images can help us identify the objects existing under the water. For instance, we can detect if a cable exists somewhere and examine other underwater infrastructure. Also, knowledge of the underwater objects may be useful for marine biologists and archaeologists.
To compensate for the changes in the light propagation direction caused by medium scattering, which is visible as some kind of shades of unwanted colors on an image taken under water, we apply white-balancing to the image. We chose the Gray-World Algorithm to reach this goal. This algorithm was designed based on the assumption that the color in each sensor channel averages to gray over the entire image. The formula for applying the algorithm to a given image in our case simplifies to:
where
- The situation under the water does not have much effect on the green channel.
- Based on the "Opponent Color Theory" which states that green and red are opponent colors, the green channel can be used to compensate for the distortions made to the red channel.
- According to the Gray-World Theory, the amount of the green channel's contribution to the red channel's compensation should be proportional to the difference of red and green average intensity levels.
- The compensation process for the red channel should only be applied to the highly distorted regions.
To increase the contrast between the lighter and darker regions, we use the "Gamma Correction" procedure. This results in losing some of the details of the picture. Assuming that a pixel has an initial intensity of
We prepare a sharpened version of the picture to compensate for the details lost due to the "Gamma Correction". To do this, we use the "Unsharp Masking" method. The process is done as follows: 1. Make a blurry version of the image by applying a Gaussian filter to it. 2. Calculate the difference of the original image and the blurry version. 3. Add the difference to the original image.
At this step, we combine the Gamma-Corrected and Sharpened versions of the image to obtain the enhanced image. The details of this combination is written in the paper [1].
There are two folders in this repo: "code-all-in-one" and "code-section-by-section". The former contains a MATLAB script named "main_all_in_one.m" which has everything we need to give an image and produce the enhanced output. The latter one consists of many MATLAB scripts each corresponding to a part of the original code. For instance, "apply_gray_world.m" applies the Gray-World algorithm to the picture.
Original Image | Enhanced Image |
---|---|
A Persian report of the implementation is also available here.
- Ancuti, C. O., Ancuti, C., De Vleeschouwer, C., & Bekaert, P. (2017). Color balance and fusion for underwater image enhancement. IEEE Transactions on image processing, 27(1), 379-393.