Histogram Equalization

Machine Learning
Introduced by
Signal processing community
Year
1970s
Type
Contrast enhancement and preprocessing
Family
Image enhancement

What does it do?

Histogram equalization is an image preprocessing technique that remaps pixel intensities so that the histogram of the output is spread more evenly across the available range.

It is most often used on images with poor contrast, where many pixels occupy a small part of the intensity scale, so that details become easier to see. The method applies a fixed, global mapping derived from the image's own histogram, and it can help some downstream image analysis steps.

The intuition behind the method

Many images have uneven intensity distributions; some images are dominated by dark pixels (like underexposed photos) or bright pixels (like overexposed ones). A histogram shows the frequency distribution of pixel intensities. Histogram equalization aims to flatten this distribution by remapping intensities so that each intensity level appears equally often. This stretches out underutilized intensity ranges, spreading dark and bright details across a wider dynamic range, which makes subtle features more visible and easier to detect. It is not the same as linear contrast stretching, which only rescales the intensity range and leaves the shape of the histogram unchanged.

History

Histogram equalization is a classical image enhancement technique covered in standard digital image processing textbooks, including Gonzalez and Woods. Pizer et al. (1987) described adaptive histogram equalization, which computes the mapping in local neighbourhoods instead of over the whole image, and discussed its variations. Contrast-limited adaptive histogram equalization (CLAHE) is one such variant; it restricts the contrast enhancement to limit noise amplification.

When to use it

Choose global histogram equalization as a preprocessing step when an image is underexposed, washed out, or otherwise uses only a narrow part of its intensity range, and when the next step (detection, segmentation, or classification) relies on intensity or edge information. Medical, satellite and surveillance images are examples of domains in which compressed intensity ranges can occur. Avoid it when the image already has good contrast, since it can produce artifacts, and when absolute or calibrated intensity values matter, because the mapping changes them. If illumination varies across the image, an adaptive or local variant is usually a better choice.

Limitations and considerations

  • Global mapping: one histogram is used for the whole image, so the adaptation reflects overall intensity statistics only and cannot respond to local lighting differences; adaptive variants (Pizer et al., 1987) address this
  • Noise amplification: where pixel values are clustered, such as dark or flat regions, the mapping spreads them apart, which makes noise and compression artifacts more visible
  • Information loss: the lookup table can merge distinct input intensities into one output level, so the original image generally cannot be recovered from the output
  • Unnatural appearance on images with good contrast, where the mapping flattens a histogram that was already well spread

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Simple and computationally cheap: the histogram, the lookup table and its application each require a single pass over the image, which suits real-time preprocessing
  • No tuning parameters: the mapping is derived entirely from the image's global histogram, so the same image always produces the same output
  • Effective when much of the intensity range is unused, as in underexposed or washed-out images, because the CDF-based mapping stretches the occupied levels across the full output range
  • Monotonic mapping: a brighter input level never maps to a darker output level, so the ordering of intensities is preserved
  • Can improve edge and feature detection on low-contrast images, although the benefit depends on the downstream task

Applications

  • Medical image analysis: enhancing visibility of subtle features in X-rays, CT, MRI, and ultrasound images
  • Satellite and aerial imagery: improving visibility of terrain and objects in varied lighting conditions
  • Surveillance video: enhancing visibility in low-light or backlit scenes for object detection and tracking
  • Industrial inspection: improving contrast in manufacturing quality control images
  • Photograph restoration: recovering detail in underexposed or faded historical photographs

How it works

How it works

1

Count how many pixels take each intensity level of the input image (0–255 for 8-bit images), which gives the histogram. For 16-bit or floating-point images, the levels are the integer values of the representation or, for floating-point data, bins over the value range; L is the number of levels or bins used.

2

Despite the label, no parameters are fitted from data. Compute the cumulative distribution function (CDF) from the histogram and normalise it to the output intensity range.

3

Build a lookup table (LUT) that maps each original intensity to its equalised value using the normalised CDF, then apply this table to every pixel of the image. With L gray levels, the mapping is s_k = round((L − 1) · c(r_k)), where r_k is an input level and c(r_k) is the normalised CDF at that level; for 8-bit images L = 256.

4

Recompute the histogram of the output and check whether it is more evenly spread. The method has no built-in quality score, so judge the visual result and the visibility of the features of interest. Visual judgement alone can miss noise amplification, so also compare flat or dark regions before and after equalization, where noise becomes most visible, and check the effect on the downstream task that the preprocessing is meant to support.

Common pitfalls

  • Applying global equalization to multimodal images (several separate intensity clusters, such as distinct objects with different intensity ranges) can compress the gaps between the clusters and reduce the separation between objects
  • Using histogram equalization on already well-contrasted images, which often produces over-enhanced results
  • Applying equalization separately to RGB channels can shift colours; equalise the intensity channel of a colour space that separates intensity from colour instead
  • Assuming it improves all downstream tasks: it can help classical detectors, but a learning-based model trained on images with a different intensity distribution may perform worse on equalised inputs, because the input statistics have changed

Frequently asked questions

What is the cumulative distribution function (CDF) and how does it relate to histogram equalization?

The CDF gives, for each intensity value, the proportion of pixels with an intensity less than or equal to that value. Histogram equalization uses the normalised CDF as the mapping: each input intensity is replaced by a value that depends on its CDF, so intensities in densely populated parts of the histogram are spread over a wider part of the output range. The exact scaling and rounding depend on the implementation.

Why does histogram equalization amplify noise?

Histogram equalization stretches underused intensity ranges to fill the full range. If a region of the image contains clustered pixel values (e.g., a dark, noisy area), equalization spreads these values across a wider range, making noise more visible. This is a trade-off: improved contrast in underexposed regions comes at the cost of emphasising noise.

What is the difference between global and adaptive histogram equalization?

Global histogram equalization uses a single histogram for the entire image, treating all regions uniformly. Adaptive histogram equalization (AHE) computes the histogram in small local neighbourhoods for each pixel, so the mapping adapts to local intensity statistics and can improve local contrast where illumination varies. Because this local mapping can strongly amplify noise, contrast-limited adaptive histogram equalization (CLAHE) restricts the enhancement to reduce that effect.

Can histogram equalization be applied to color images?

Yes, but care must be taken to preserve colour balance. Applying equalization independently to R, G, and B channels can distort colours. Instead, convert to a colour space where intensity and colour are separated (e.g., HSV), equalise only the intensity channel, and convert back to RGB. Alternatively, use perceptually uniform colour spaces for more natural results.

Related methods

Sources

  1. Gonzalez, R. C., & Woods, R. E. (1992). Digital Image Processing. Addison-Wesley, 2nd edition, Chapter 3.

    Open publication reference
  2. Pizer, S. M., Amburn, E. P., Austin, J. D., et al. (1987). Adaptive histogram equalization and its variations. Computer Vision, Graphics, and Image Processing, 39(3), 355–368.

    Open DOI reference