OpenCV  4.1.0
Open Source Computer Vision
Histograms - 2: Histogram Equalization






Histograms Equalization in OpenCV

We use the function: cv.equalizeHist (src, dst)

srcsource 8-bit single channel image.
dstdestination image of the same size and type as src.

Try it

CLAHE (Contrast Limited Adaptive Histogram Equalization)

In adaptive histogram equalization, image is divided into small blocks called "tiles" (tileSize is 8x8 by default in OpenCV). Then each of these blocks are histogram equalized as usual. So in a small area, histogram would confine to a small region (unless there is noise). If noise is there, it will be amplified. To avoid this, contrast limiting is applied. If any histogram bin is above the specified contrast limit (by default 40 in OpenCV), those pixels are clipped and distributed uniformly to other bins before applying histogram equalization. After equalization, to remove artifacts in tile borders, bilinear interpolation is applied.

We use the class: cv.CLAHE (clipLimit = 40, tileGridSize = new cv.Size(8, 8))

clipLimitthreshold for contrast limiting.
tileGridSizesize of grid for histogram equalization. Input image will be divided into equally sized rectangular tiles. tileGridSize defines the number of tiles in row and column.
Don't forget to delete CLAHE!

Try it