Skip to content
CoreSource checked

Histogram Equalization

Improves contrast by spreading image intensities across the available range.

Quick Facts

Compact metadata for implementation and discovery.

Category
Image Processing
Difficulty
Beginner
Family
Contrast Enhancement
Tier
Core
Status
Verified
Review
Source Checked
Sources
1
Formulas
1
Relationships
1
Code example
Ready
Visualization
Ready

Overview

Histogram Equalization uses the cumulative distribution of pixel intensities to remap values for stronger contrast.

Core Concepts

pixel operationregion separationcontrast enhancementpixel neighborhoodlocal operationimage transform

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(w h + k)

Average

O(w h + k)

Worst

O(w h + k)

Space

O(k)

When to Use

  • Use Histogram Equalization when you need to count pixel intensities.
  • Use it for contrast enhancement with inputs like grayscale image.
  • Use it when pixel-level transformation or region analysis is the main task.
  • Use it when the Contrast Enhancement tradeoff is acceptable for the problem size.

When Not to Use

  • Avoid it when lighting, noise, or color space changes make a fixed rule unreliable.
  • Avoid it when the required output is not contrast-adjusted image.

What It Does

  • Counts pixel intensities
  • Remaps intensities using cumulative counts

Use Cases

  • Contrast enhancement
  • Medical image preprocessing
  • Low-contrast photo correction

Inputs

  • Grayscale image

Outputs

  • Contrast-adjusted image

Key Formulas (1)

Equalized value

newvalue = round((cdf(value) − cdfmin) / (pixels − cdfmin) · (levels − 1))
new_value = round((cdf(value) - cdf_min) / (pixels - cdf_min) * (levels - 1))

Redistributes intensity values using the cumulative histogram.

Pseudocode

  1. 1.Build the intensity histogram
  2. 2.Compute cumulative counts
  3. 3.Normalize cumulative counts to output intensities
  4. 4.Map each pixel through the new intensity table
  5. 5.Return the adjusted image

Canonical Example

Input
image = 3x3 grayscale pixels
Output
processed 3x3 image or mask
Explanation
Histogram Equalization: The algorithm transforms local pixel values into a clearer feature, mask, or image.

Implementation Notes

  • Keep the input contract explicit: Grayscale image.
  • Test on tiny images where each expected output pixel can be inspected by hand.
  • Keep coordinate conventions, border handling, and image normalization explicit in tests.

Common Pitfalls

  • Global equalization can over-amplify noise or local contrast.
  • Processing color, alpha, and boundary pixels inconsistently.
  • Handle empty, invalid, and boundary inputs before trusting contrast-adjusted image.
  • Thresholds tuned on one clean image can fail under different lighting, scale, blur, or noise.

Interactive Mechanism Walkthrough

Spatial Primitive & Sweep-Line Canvas

Show a narrow histogram spreading across the full intensity range.

Histogram Equalization mechanism walkthrough step 1 of 5
Step 1 of 5: Build the intensity histogram
histogram-remap

Notes

Histogram Equalization operates in O(w h + k) time and O(k) space within the Contrast Enhancement family. Key governing relation: new_value = round((cdf(value) - cdf_min) / (pixels - cdf_min) * (levels - 1)). Often compared with Thresholding and Bilateral Filter.

Sources (1)

What each reference supports for this entry.

Digital Image Processing

Book

Image-processing textbook support for Histogram Equalization's pixel-neighborhood operations, filtering rules, and image-analysis role.

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Often paired withThresholding

Histogram equalization is often used before thresholding to improve contrast separation.

Tags

Image ProcessingSegmentationClassic