color histogram matching
Color histogram matching recognizes or retrieves images by comparing their color distributions, ignoring where the colors are and keeping only how much of each color is present. The intuition: a ripe tomato is mostly red regardless of its exact shape or position, a forest scene is dominated by greens and browns, a particular brand's packaging has a signature palette. So you summarize an image by a color histogram — count how many pixels fall into each color bucket — and judge two images similar if their histograms are similar. This was Swain and Ballard's color indexing (1991), one of the first practical content-based image retrieval methods.
Made precise, you choose a color space (often hue-saturation-value or a perceptually uniform space like CIELab rather than raw RGB, so that comparison better matches human perception and is more robust to lighting), quantize each channel into a handful of bins, and tally pixels into the resulting 3D histogram, usually normalizing so it sums to one (becoming a distribution that is invariant to image size). Two histograms are then compared with a similarity or distance measure. The classic is histogram intersection: for each bin take the smaller of the two counts and sum, which elegantly measures how much color the two images share and is robust to background pixels and partial occlusion. Other common measures are chi-squared distance, the Bhattacharyya coefficient, and earth mover's distance (which, unlike bin-by-bin measures, accounts for nearby bins being similar colors).
A powerful companion technique is histogram back-projection: given a target object's color histogram, you replace each pixel of a new image with the probability, read from the histogram, that its color belongs to the target. This produces a likelihood map that lights up regions matching the target's colors — the basis of simple color-based object localization and the engine inside the CamShift/mean-shift tracker. Color histograms are fast, naturally invariant to rotation, translation, and modest scale and pose change, and need no training. Their weaknesses are exactly their assumptions: they discard all spatial structure (a red ball and red scattered confetti look identical), and they are sensitive to illumination color and white balance unless you normalize carefully. They remain useful for retrieval, tracking, and as a cheap pre-filter, and were a building block of the bag-of-words pipeline; modern systems instead compare learned deep embeddings (CLIP, image-retrieval networks) that capture content, not just color.
To track a red ball, build its hue histogram from a first frame, then back-project that histogram onto each new frame to get a probability map, and run mean-shift to follow the peak. The tracker stays locked even as the ball rotates and scales, because it keys on color distribution, not shape.