Earth imaging satellite data is hard to display, even on modern OLED screens.
— Abraham Lincoln
Say goodbye to dark satellite images with Contrast Enhancement, a new OTB app featuring Adaptative Histogram Equalization. If you need a colorful 8-bit visual product this is the solution! Here’s a quick demo on a Sentinel-2 image:
Adaptative Histogram equalization
The basic idea is to use the full image dynamic. Satellite imagery can have almost unlimited dynamic range, but most computer screens can only display 8-bit values per pixel! The basic idea is to flatten the intensity distribution of our pixels and then rescale to 8 bits. This means flattening a histogram and then doing a linear rescale over the resulting image. And that is exactly what this new application is doing.
Except that a simple linear rescale to [0-255] raises another problem. There are details in bright areas we want to keep, but also in dark areas that we don’t want to loose. To mitigate that, we can compute local histograms for sub-areas of the image. Each area’s gain is interpolated between adjacent tiles. This method shows great results but can lead to contrast inversion. In some cases, pixels that are dimmer than others become brighter after contrast enhancement.
Check out the wikipedia page for the full details.
The new Contrast Enhancement application implements Adaptative Histogram Equalization in OTB, and works with the streaming pipeline. The only things stored in RAM are the histograms. So unless you are entering some crazy parameters everything should run smoothly and without dragging your computer resources.
To work with multiband images, the application has two equalization modes:
- Luminance: The image is equalized in luminance, i.e. the histogram is computed on the luminance.
- Each: Image channels are equalized independently.
Here’s an illustration of both modes on a true color Sentinel 2 product:
Equalizing in luminance (contrast limitation set to 20)
Equalizing each band independently (contrast limitation set to 20)
Another important parameter is the local component. With the former parameter we saw that we could modify the color and thus change the perception over an image. But with a local adaptation we can change the global view of an image. In the image below there are two kinds of textures: water and land.
Here’s a comparison of global vs local equalization.
Global luminance equalization (contrast limitation set to 10)
As one can see the shore is a bit bright and one might want better contrast on the shore. It can be done with a local equalization. With a window size of 1000×1000 pixels we get much better results:
Local (1000×1000 window) luminance equalization (contrast limitation set to 10)
While the aspect of water might be arguably a bit worse, the shore becomes much more detailed with local equalization.
Last but not least, let’s look at the contrast limitation parameter. In order to see the importance of the parameter here is the previous image with the same parameters but with no limitation of contrast:
Global channels equalization with and without contrast limitation of 20
Local luminance equalization with and without contrast limitation of 10
A nice way to proceed to find the algorithm’s best tunning is to begin with a global luminance equalization with no contrast limitation. Then one can increase the limitation (meaning lower the factor) until the image looks alright. One still needs to tune the spatial aspect and whether one want to equalize each channel or stay in luminance. In a broad aspect if the image has bright and dark distinct zone one might want to try a local equalization (the shore example), and the channel equalization would be to emphasis details (the mountain example shows the enhancement of contrast in the snow).
In anyway, this is an application to help you create your visual product. So the best tunning will the one that produce the best image in your opinion!