Histogram Equalization

Requires a Wolfram Notebook System

Interact on desktop, mobile and cloud with the free Wolfram CDF Player or other Wolfram Language products.

Requires a Wolfram Notebook System

Edit on desktop, mobile and cloud with any Wolfram Language product.

The histogram of an image shows how many pixels have each of the possible intensity values. Histogram equalization is a kind of contrast enhancement that stretches the histogram so that all values occur (more or less) an equal number of times. The resulting image uses the full range of possible values. This often works well, especially for bringing out details in overly light or overly dark sections of a grayscale image. When operating on color images, straightforward application of the histogram equalization to the red, green, and blue channels increases the contrast, but may also change the color balance. A common trick (selected here using the mode chooser box) is to operate in the HSB colorspace, applying the histogram equalization to the brightness channel, while leaving the hue and saturation channels unchanged. The display shows the original image on the left and the equalized image on the right. The histograms of the two images are shown immediately below. Observe how the RGB mode stretches all three channels while the HSB mode only stretches the brightness channel.

Contributed by: William Sethares (September 2012)
Open content licensed under CC BY-NC-SA


Snapshots


Details

Histogram equalization is a classic image processing technique that adjusts the contrast of an image so that the image utilizes the full range of possible values from 0 (black) to 255 (white). In the equalized image, each value occurs with (roughly) the same frequency. The method is described in many places, including the Wikipedia article and the book cited below. This implementation can operate on grayscale images (where it is probably most effective) and on color images, where two choices are possible: equalization of the three RGB channels separately or equalization in the HSB colorspace, where the equalization is applied only to the brightness channel. This implementation also allows the addition of dither (using the slider), which can help to fill in empty spaces in the histogram. An example is the tank image; without dither, the equalized histogram is spikey and does not use all the possible grayscale values. Adding dither smooths this out, though too much dither is tantamount to adding noise to the image. A good rule of thumb is to add dither until you can start to actually see the graininess in the image, then reduce the dither somewhat.

References

[1] Wikipedia. "Histogram Equalization." (June 28, 2012) en.wikipedia.org/wiki/Histogram_equalization.

[2] R. C. Gonzalez and R. E. Woods, Digital Image Processing, 3rd ed., Upper Saddle River, NJ: Prentice Hall, 2007.



Feedback (field required)
Email (field required) Name
Occupation Organization
Note: Your message & contact information may be shared with the author of any specific Demonstration for which you give feedback.
Send