Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

clahe

Contrast Limited Adaptive Histogram Equalization


Description

Improve contrast locally by performing adaptive histogram equalization.

Usage

clahe(x, nx = 8, ny = nx, bins = 256, limit = 2, keep.range = FALSE)

Arguments

x

an Image object or an array.

nx

integer, number of contextual regions in the X direction (min 2, max 256)

ny

integer, number of contextual regions in the Y direction (min 2, max 256)

bins

integer, number of greybins for histogram ("dynamic range"). Smaller values (eg. 128) speed up processing while still producing good quality output.

limit

double, normalized clip limit (higher values give more contrast). A clip limit smaller than 0 results in standard (non-contrast limited) AHE.

keep.range

logical, retain image minimum and maximum values rather then use the full available range

Details

Adaptive histogram equalization (AHE) is a contrast enhancement technique which overcomes the limitations of standard histogram equalization. Unlike ordinary histogram equalization the adaptive method redistributes the lightness values of the image based on several histograms, each corresponding to a distinct section of the image. It is therefore useful for improving the local contrast and enhancing the definitions of edges in each region of an image. However, AHE has a tendency to overamplify noise in relatively homogeneous regions of an image. Contrast limited adaptive histogram equalization (CLAHE) prevents this by limiting the amplification.

The function is based on the implementation by Karel Zuiderveld [1]. This implementation assumes that the X- and Y image dimensions are an integer multiple of the X- and Y sizes of the contextual regions. The input image x should contain pixel values in the range from 0 to 1, inclusive; values lower than 0 or higher than 1 are clipped before applying the filter. Internal processing is performed in 16-bit precision. If the image contains multiple channels or frames, the filter is applied to each one of them separately.

Value

An Image object or an array, containing the filtered version of x.

Note

The interpolation step of the original implementation by Karel Zuiderveld [1] was modified to use double precision arithmetic in order to make the filter rotationally invariant for even-sized contextual regions, and the result is properly rounded rather than truncated towards 0 in order to avoid a systematic shift of pixel values.

Author(s)

Andrzej Oleś, andrzej.oles@embl.de, 2017

References

[1] K. Zuiderveld: Contrast Limited Adaptive Histogram Equalization. In: P. Heckbert: Graphics Gems IV, Academic Press 1994

See Also

Examples

x = readImage(system.file("images", "sample-color.png", package="EBImage"))
  y = clahe(x)  
  display(y)

EBImage

Image processing and analysis toolbox for R

v4.32.0
LGPL
Authors
Andrzej Oleś, Gregoire Pau, Mike Smith, Oleg Sklyar, Wolfgang Huber, with contributions from Joseph Barry and Philip A. Marais
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.