Thresholding is the most fundamental segmentation operation in image processing — the point where a continuous grayscale image becomes a discrete binary decision: foreground or background. Despite its simplicity, the choice of threshold method and value profoundly affects every downstream result (Gonzalez & Woods, §10.3).
Global Thresholding & Otsu's Method
Global thresholding applies a single value T to the entire image: g(x,y) = 1 if f(x,y) ≥ T, else 0. The core assumption is histogram bimodality — foreground and background pixels form two separable peaks. Otsu's method formalizes this by finding the threshold that maximizes the between-class variance σ2B = ω0ω1(μ0 − μ1)2, where ω0, ω1 are the class probabilities and μ0, μ1 are the class means. This is equivalent to minimizing within-class variance. Otsu's method is optimal when classes have equal variances and the histogram is truly bimodal, but degrades when: (1) one class is much smaller than the other, (2) class variances differ greatly, or (3) noise fills the valley between peaks.
Adaptive Thresholding
When illumination varies across the image — common in large whole-slide scans — no single global threshold works everywhere. Adaptive thresholding computes a local threshold at each pixel from its neighborhood: T(x,y) = mean(neighborhood) + offset. The mean can be unweighted (box filter) or Gaussian-weighted (giving more influence to nearby pixels). Solomon & Breckon describe this as "the workhorse operator" of practical machine vision — a different threshold at each pixel location. The window size is a critical trade-off: too small and the threshold is noisy (responds to individual pixels rather than illumination trends); too large and it loses the ability to adapt to local conditions, approaching global behavior.
Multi-Level & Hysteresis Thresholding
Multi-level Otsu extends the method to more than two classes by maximizing the total between-class variance across multiple thresholds — useful when the histogram has three or more modes (e.g., background, cytoplasm, nuclei). Hysteresis thresholding uses two thresholds (Tlow, Thigh): pixels above Thigh are definitely foreground, pixels below Tlow are definitely background, and pixels between the two are foreground only if connected to a definite foreground pixel. This dual-threshold approach is the basis of the Canny edge detector's final stage and is available in StrataQuest's BOM through chained threshold-then-compare operations.
Compare Operations as Boolean Algebra
Binary masks are sets of pixels, and compare operations implement set operations: A > B produces the set where A exceeds B; combining masks with AND computes the intersection, OR computes the union, and XOR computes the symmetric difference. This enables construction of complex ROIs from simple threshold results — for example, (channel_A > T1) AND (channel_B < T2) selects pixels that are bright in one marker and dim in another, a common operation in multiplex immunofluorescence analysis.
Thresholding is the simplest segmentation: pick a brightness cutoff, and everything above it becomes 'object.' Otsu's method finds this cutoff automatically by looking at the histogram's shape. When lighting is uneven across a slide, adaptive thresholding adjusts the cutoff at each location based on the local brightness — Solomon & Breckon call it 'the workhorse operator' of machine vision. Compare operations let you combine multiple binary masks using AND/OR logic to build complex regions of interest.