Skip to content

Histogram equalization

Redistribute grayscale intensities using their cumulative histogram.

Try it on your image ↓

VISUAL WALKTHROUGHColour
REFERENCE INPUTNarrow intensity range

The same scene stays here while the working view changes.

RESULTRedistributed intensities

Applying the monotone mapping stretches the occupied range and makes the objects easier to distinguish.

STEP 03 / 03

Map each input intensity to its cumulative rank.

Computed teaching example on a 24 × 16 image. Small kernels and simplified settings keep each change visible; use the image laboratory for native OpenCV.

Try it on an image

YOUR IMAGE · REAL OPENCV

Experiment at pixel level

Open full lab ↗

Equalize the global grayscale histogram.

The engine loads on your first run. Your images stay in this browser.

Input448 × 320
OutputWaiting for a result

Scroll over either image to zoom at the pointer. Use the scrollbars to pan both views over the same relative area. Zoom is relative to the input; pixel coordinates belong to each image. Warps can change scene correspondence.

Pixel inspector RGBA · native values · matched scale · 9 × 9 output pixels
Hover to inspect. Click to pin a pixel.
Input
Select a pixel

Output
Select a pixel

Sample models and licenses

When to use it

Increase global contrast when useful intensities occupy a narrow range.

How it works

  1. 01Count the occurrence of each intensity.
  2. 02Form a normalized cumulative distribution.
  3. 03Map each input intensity to its cumulative rank.

output = normalized cumulative histogram(input)

What to tune

equalizeHist accepts 8-bit grayscale. calcHist offers general histogram building; backprojection maps histogram likelihoods back to pixels.

Where it breaks down

Equalization can amplify noise and shift brightness. Applying it independently to colour channels changes colour relationships.

TypeScript API

Open an entry for its exact overloads, parameter descriptions, result ownership and pinned upstream source.

All of these calls execute on the CPU. Native objects need explicit disposal. See matrices and ownership and build compatibility.