Skip to content

Contrast Limited Adaptive Histogram Equalization (CLAHE) with Sentinel 2a

Image CLAHE Sentinel2

This week I have been thinking about image stretching. I want to start with a quote taken from the concluding remarks of Image Processing and GIS for Remote Sensing.

Image Processing can never increase the information provided in the original image data, but the use of appropriate image processing can improve visualisation, comprehension and analysis of the image information for any particular application. There is no magic trick in image processing that will create something that does not already exist in the image, but it can be magical when image processing makes subtle things seem obvious and distinctive

Liu, J.G & Mason, P.J. (2016) Image Processing and GIS for Remote Sensing Techniques and Applications (2nd Edition).

I like this quote a great deal… no magic trick… but image processing can be magical! There are an enormous amount of image stretching techniques available today, some more useful than others. Initially I was looking at Histogram Equalization stretches until I came across a nice piece of code on Contrast Limited Adaptive Histogram Equalization (CLAHE).

Sentinel 2a data

As I have written previously it’s possible to access Sentinel2a data in a variety of ways. I used an FME server demo site to search for and retrieve two cloud free Sentinel2a tiles.

Data here (Egypt / Sudanworld’s most cloud free place?)

and (Vancouver)

Both these images have the TCI.jp2 file in the container. This is a really useful addition that ESA have made to the Sentinel2a data set.

On the 6th of December 2016 a TCI (True Colour Image) in JPEG2000 format is included within the Tile folder of Level-1C products in this format. The TCI is an RGB image built from the B02 (Blue), B03 (Green), and B04 (Red) Bands. The reflectances are coded between 1 and 255, 0 being reserved for ‘No Data’. The saturation level of 255 digital counts correspond to a level of 2000 for the individual bands (i.e. reflectance of 0.2).

I ran both images through gdal_translate to convert this data to 8bit jpeg. The command looks like this, and I made sure I created the worldfile to use in GIS later.

gdal_translate -ot Byte -of JPEG -scale -co worldfile=yes TCI.jp2 sentinel2.jpg

 

Vancouver on the left, Egypt/Sudan desert on the right. Snow vs Sand.

CLAHE

First off AHE, or Adaptive Histogram Equalization. It is different from Histogram Equalization because it computes several histograms over the image (as opposed to just the one) and uses these histograms to ‘redistribute the lightness values of the image’. CLAHE was developed to limit the amplification of noise that AHE can produce. Read more about it all here.

I wanted to see if I could apply CLAHE to Sentinel2a data. Fortunately there is some code available here to run this. (note: depending on your computer’s available memory you might need to resize the input image).

CLAHE Vancouver Sentinel2

CLAHE Egypt Sentinel2

The original images (TCI) are on the left and the CLAHE images are on the right. The results look pretty good I think. Certainly more features seem to stand out and because we used Gdal_translate to convert the file at the beginning you just need to copy the wld file to the new file and it will be correctly referenced in your GIS of choice.

Remember…

“There is no magic trick in image processing that will create something that does not already exist in the image, but it can be magical when image processing makes subtle things seem obvious and distinctive” 🙂