= Image thresholding
<Image thresholding> classifies <pixels> by comparing their intensities with a threshold, often producing a <binary image>. A global threshold uses the same value throughout the image; <adaptive thresholding> permits the threshold to depend on position and nearby intensities.<Image Thresholding in the OpenCV documentation>[Simple Thresholding; Adaptive Thresholding]{ref}
For example, define
$$
B(x,y)=\begin{cases}1&I(x,y)>100,\\0&I(x,y)\leq100.\end{cases}
$$
Intensities $99,100,101$ then become $0,0,1$. The comparison at equality matters: a rule using $I\geq100$ would instead give $0,1,1$. OpenCV's `THRESH_BINARY` uses the strict greater-than rule, assigning its chosen maximum output value only above the threshold.<Image Thresholding in the OpenCV documentation>[Simple Thresholding, threshold equality and maxval]{ref}
Threshold choice affects which distinctions survive. Two different bright intensities can become the same foreground value, while a small change near the boundary can change a pixel's classification. The resulting mask can then feed <connected-component labeling>, where <pixel connectivity> separately decides which selected <pixels> form a region.
A useful motivating experiment keeps one image of dark marks fixed while adding or recording a gradual illumination variation across the background. Compare a global threshold with a declared local-neighborhood rule, inspecting lost strokes and falsely selected background. OpenCV documents local mean and Gaussian-weighted rules with an offset; this addresses varying illumination rather than proving that every resulting region is a meaningful object.<Image Thresholding in the OpenCV documentation>[Adaptive Thresholding, neighborhood-based thresholds and varying illumination]{ref}
A <histogram> can guide global selection, but intensity statistics alone do not determine semantic identity. Noise and overlapping foreground/background intensities can make every threshold imperfect. Report the input representation, comparison convention and any filtering or local-window settings so that a thresholded result can be reproduced.
Back to article page