Contrast Enhancement
Brief Description
This application is the implementation of the histogram equalization algorithm. It can be used to enhance contrast in an image or to reduce the dynamic of the image without losing too much contrast. It offers several options as a no data value, a contrast limitation factor, a local version of the algorithm and also a mode to equalize the luminance of the image.
Tags
Image Filtering
Long Description
This application is the implementation of the histogram equalization algorithm. The idea of the algorithm is to use the whole available dynamic. In order to do so it computes a histogram over the image and then use the whole dynamic: meaning flattening the histogram. That gives us gain for each bin that transform the original histogram into the flat one. This gain is then apply on the original image.
The application proposes several options to allow a finer result:
- There is an option to limit contrast. We choose to limit the contrast by modifying the original histogram. To do so we clip the histogram at a given height and redistribute equally among the bins the clipped population. Then we add a local version of the algorithm.
- It is possible to apply the algorithm on tiles of the image, instead of on the whole image. That gives us gain depending on the value of the pixel and its position in the image. In order to smoothen the result we interpolate the gain between tiles.
Parameters
Input Image (in): Input image.
Output Image (out): Output image.
Number of bins (bins): Number of bins in the histogram
Contrast Limitation (hfact): This parameter will set the maximum height accepted in a bin on the input image histogram. The maximum height will be computed as hfact*eqHeight where eqHeight is the height of the theoretical flat histogram. The higher hfact, the higher the contrast.
When using 'luminance mode', it is recommended to limit this factor to a small value (ex: 4)
Nodata Value (nodata): If there is a value in the image that has no visualization meaning, it can be ignored by the algorithm.
Spatial parameters for the histogram computation (spatial):
Local (local): The histograms will be computed on each thumbnail. Each of the histogram will be equalized and the corresponding gain will be interpolated.
Thumbnail height (spatial.local.h): Height of the thumbnail over which the histogram will be computed. The value is in pixels.
Thumbnail width (spatial.local.w): Width of the thumbnail over which the histogram will be computed. The value is in pixels.
Global (global): The histogram will be computed on the whole image. The equalization will be computed on this histogram.
Minimum and maximum settings (minmax): Minimum and maximum value that will bound the histogram and thus the dynamic of the resulting image. Values over those boundaries will be clipped.
Automatic (auto): Minimum and maximum value will be computed on the image (nodata value won't be taken into account) . Each band will have a minimum and a maximum.
Global (minmax.auto.global): Min/max computation will result in the same minimum and maximum for all the bands.
Manual settings for min/max values (manual): Minimum and maximum value will be set by the user
Minimum value (minmax.manual.min):
Maximum value (minmax.manual.max):
What to equalized (mode):
Channels (each): Each channel is equalized independently
Luminance (lum): The relative luminance is computed according to the coefficients.Then the histogram is equalized and the gain is applied to each of the channels. The channel gain will depend on the weight (coef) of the channel in the luminance.
Note that default values come from color space theories on how human eyes perceive colors)
Red channel (red):
Red channel (mode.lum.red.ch):
Value for luminance computation for the red channel (mode.lum.red.coef):
Green channel (green):
Green channel (mode.lum.green.ch):
Value for luminance computation of the green channel (mode.lum.green.coef):
Blue channel (blue):
Blue channel (mode.lum.blue.ch):
Value for luminance computation of the blue channel (mode.lum.blue.coef):
Available RAM (Mb) (ram): Available memory for processing (in MB)
Load otb application from xml file (inxml): Load otb application from xml file
Save otb application to xml file (outxml): Save otb application to xml file
Limitations
None
Authors
OTB-Team
See also
Example of use
Local contrast enhancement by luminance
in: colours.tif
out: equalizedcolors.tif float
bins: 256
spatial.local.w: 500
spatial.local.h: 500
mode: lum
Local contrast enhancement by luminance
otbcli_ContrastEnhancement -in colours.tif -out equalizedcolors.tif float -bins 256 -spatial.local.w 500 -spatial.local.h 500 -mode lum