Histogram equalization
Redistribute grayscale intensities using their cumulative histogram.
The same scene stays here while the working view changes.
Most samples occupy a small portion of the available intensity range.
This teaching example uses the cumulative rank directly; each step adds the next intensity bin.
Applying the monotone mapping stretches the occupied range and makes the objects easier to distinguish.
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
Experiment at pixel level
Equalize the global grayscale histogram.
The engine loads on your first run. Your images stay in this browser.
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
Select a pixel
Select a pixel
When to use it
Increase global contrast when useful intensities occupy a narrow range.
How it works
- 01Count the occurrence of each intensity.
- 02Form a normalized cumulative distribution.
- 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.
Related methods
CLAHE local contrast
Equalize local histograms while limiting how much a concentrated bin can amplify contrast.
Colour-space conversion
Re-express pixels in a different channel order or colour representation.
Colour range masks
Keep pixels whose channel values all lie within specified lower and upper bounds.
White balance
Estimate channel gains or mappings that reduce an image’s illumination colour cast.