CV Lab 05 · Module 1 — Foundations

Histograms & Equalization

A histogram counts how many pixels fall at each brightness. Its shape tells you if the photo is dark, washed-out, or well-exposed — long before you look at the image. Equalization re-spreads those pixels across the full range and rescues low-contrast shots that look flat.

input intensity
The mapping curve Equalization builds a curve that takes each input brightness and maps it to a new one. Dashed = identity (no change). Amber = an equalization curve that stretches dim mid-tones toward bright.
Intensity distribution — how many pixels at each brightness (0–255)
Original After processing CDF (cumulative)
Brightness
0
Contrast
1.00×

Push brightness up — the whole histogram slides right and pixels bunch up against 255 (clipping to white). Crank contrast — the histogram stretches from the centre outward, spikes at 0 and 255 grow, subtle mid-tones vanish. Read the histogram, and you can already tell what a photo looks like without seeing it.

Mean brightness
Std deviation
Dynamic range
Clipping (%)

Reading a histogram like a photographer

Histogram = the "vitals" of an image

Every pixel votes for one of 256 bins based on its brightness. Pile of votes on the left → dark photo. Pile on the right → bright/overexposed. Tall spike at 0 or 255 → clipping (info destroyed). Wide, even spread → good exposure. You can diagnose an image before ever seeing it, just from the shape.

Equalization — the CDF trick

Sort pixels by brightness, then rank them 0…N. Map each pixel's brightness to its rank-percentile times 255. Result: every intensity ends up used equally often. This is what "equalize" literally does — makes the histogram as flat as possible using the cumulative distribution as the mapping.

Why CLAHE beats plain equalization

Plain equalization uses one curve for the whole image — good for a uniformly dark photo, bad for a scene that's dark on one side and bright on the other (the bright side gets crushed). CLAHE breaks the image into small tiles, equalizes each locally, and interpolates. Result: shadows and highlights both come out with detail — the technique medical imaging and dashcam pipelines rely on.

Predict, then verify

A hospital sends you a chest X-ray where subtle details are hidden in the mid-grey mid-tones — the important structures are only visible after enhancing local contrast, not global. Which technique fits?