Image Processing & Filtering

image histogram

An image histogram is a bar chart that counts how many pixels in an image have each possible brightness value. Imagine going through every pixel of a grayscale photo, sorting them into 256 buckets labelled 0 (pure black) through 255 (pure white), and recording how full each bucket is. The resulting curve is a compact fingerprint of the image's tones: where the bars pile up tells you whether the picture is mostly dark, mostly bright, or balanced; how widely they spread tells you the contrast; and tall spikes jammed against either end warn you that detail has been crushed to black or blown out to white.

Precisely, for an image with intensity values in the range 0 to L minus 1 (L is 256 for an 8-bit image), the histogram is the function h(i) equal to the number of pixels whose intensity equals i. Dividing by the total pixel count N gives the normalized histogram p(i) = h(i)/N, an empirical probability mass function: p(i) estimates the probability that a randomly chosen pixel has intensity i, and the values sum to one. The running sum of p, called the cumulative distribution function CDF(i) = p(0) + ... + p(i), rises from 0 to 1 and is the engine behind histogram equalization. For colour images you usually compute one histogram per channel (red, green, blue) or work on a luminance channel.

The histogram is purely a statistical summary: it records how many pixels have each value but throws away where those pixels sit. This is both its power and its limitation. It is fast to compute, illumination-revealing, and the basis of thresholding, equalization, and the exposure metering inside every camera. But because it discards all spatial information, two completely different images, for instance a random scramble and the original photo, can share the exact same histogram.

A backlit portrait often shows a bimodal histogram: a dark hump for the shadowed face and a bright hump for the blown-out sky, with a sparse valley between, signalling that no single exposure captured both well.

Why it matters: the histogram drives auto-exposure and tone curves, but never mistake histogram shape for image quality. A pleasing histogram does not guarantee a sharp or well-composed picture, and clipping (a spike at 0 or 255) is irreversible lost data.

Also called
intensity histogramtonal histogram