StrataQuest Home › StrataQuest Glossary › Otsu Threshold
Pre-Processing

Otsu Threshold

Automatic intensity thresholding across the whole sample

View
Definition
Otsu's method sets the intensity at which foreground is divided from background. It tries every possible threshold and scores how well each one splits the pixels into two internally consistent groups. The chosen threshold gives the tightest clustering, where background pixels are most alike, foreground pixels are most alike, and the two groups are as different as possible.
Detection - Automatic Background Threshold params
Video · Primary
Detection - Total Area
Video · Primary
Measurements Mask - Cellular
Video · Primary
Supporting
Guided workflow - nucl and cell measurements
Video · Supporting
Detection - Nuclei Segmentation Classic
Video · Supporting
Automatic threshold selection
Usually needs no manual tuning
Variance optimization
Maximize between-class separation
Bimodal assumption
Works best with two-peaked histograms
One threshold for the sample
Used by other engines

How It Works

The engine computes the threshold in four steps:

  1. Histogram. Compute the intensity histogram of the input image, or of the intensity range set by the Lower and Upper limits.
  2. Exhaustive search. For every possible threshold T from the minimum to the maximum intensity:
    • Split all pixels into background (intensity ≤ T) and foreground (intensity > T).
    • Compute the weight, mean and variance of each group.
    • Compute the between-class variance: σ²_B = w₁ × w₂ × (m₁ − m₂)².
  3. Selection. Choose the T that maximizes σ²_B, where the two groups are most separated.
  4. One value for the whole sample. The threshold draws on all fields of view, so one value applies to the entire sample or region of interest. Other engines use it: for example, Total AreaLoading... can threshold with the value this engine produces.
Simplified

Otsu tries every possible threshold and keeps the one that best splits the pixels into "bright stuff" (foreground) and "dark stuff" (background): each group as uniform as possible, and the two as different as possible.

Science Behind It

The mathematics. For a threshold T on an image with L gray levels, w₁(T) and w₂(T) are the probabilities of the background class (pixels ≤ T) and the foreground class (pixels > T), m₁(T) and m₂(T) are their means, and m_G is the global mean. The between-class variance is σ²_B(T) = w₁(T) × w₂(T) × [m₁(T) − m₂(T)]². Otsu proved that the threshold maximizing σ²_B minimizes the probability of classification error when the two classes have equal covariance. The search is fast: its cost grows only linearly with the number of gray levels.

Where Otsu needs help. Three conditions blur the two-peak picture the method relies on:

  • Small object area. When the foreground occupies a tiny fraction of the image, such as sparse fluorescent dots on a large dark background, its peak barely influences the histogram, and Otsu may place the threshold in the middle of the background distribution.
  • High noise. Noise fills the valley between the histogram peaks, so the bimodal structure is less distinct and the optimal threshold less stable.
  • Non-uniform illumination. When background intensity varies across the image, no single global threshold classifies every region correctly. Adaptive (local) thresholding, which applies Otsu in small neighborhoods, addresses this case.

Otsu in the broader context. Otsu's method ignores spatial structure and classifies each pixel by intensity alone. In effect it is a Bayesian classifier with equal Gaussian variances and equal priors, working in one dimension, intensity. Approaches such as MRF-based segmentation and learned classifiers use spatial context, the tendency of neighboring pixels to belong to the same class, for better results, but Otsu's simplicity and speed keep it the standard first approach.

Simplified

Otsu works well when the histogram has two clear peaks with a valley between them. It works poorly when the foreground is sparse (a tiny peak lost beside the background), when noise fills the valley, or when illumination is uneven. It remains the standard automatic thresholding method because it is fast and simple.

Parameters & Settings

ParameterDescription
Gray ImageInput grayscale image.
LowerLower limit of the intensity range: above the background values and below the dimmest areas that must be detected.
UpperUpper limit of the intensity range: above the average intensity of the areas that must be detected. A lower value forces a lower threshold.
ResultA threshold level for the entire sample or region of interest, for use by other engines such as Total AreaLoading....
Simplified

Usually no tuning is needed. When the histogram is not cleanly two-peaked, for example when the objects are small compared with the background, use Lower and Upper to limit the intensity range.

Practical Example

Creating a tissue mask from an autofluorescence channel:

  1. In the autofluorescence channel, tissue is moderately bright and the glass background is dark.
  2. Otsu Threshold (global) finds the tissue/glass boundary in the intensity histogram automatically.
  3. Total AreaLoading... uses that threshold to create the mask that defines the analysis region. Tissue Detection does a similar job on the low-resolution preview image, with its own fragment-merging, minimum-area and contour-inflate settings.

The tissue/glass histogram is strongly bimodal with a deep valley, which is the case Otsu's method handles well.

Simplified

Otsu works well on clean separations: tissue against glass, strongly positive against negative staining, nuclear counterstain against background. Given two clear histogram peaks, it finds the dividing line automatically and reliably.

Connected Terms

Share This Term
Term Connections