Skip to main content

Module otsu

Module otsu 

Source
Expand description

Otsu’s method: automatic global thresholding.

Given the gray-level histogram of an image, Otsu’s method picks the threshold t that maximises the between-class variance of the two classes it creates (pixels <= t and pixels > t), equivalently minimises the within-class variance. For a bimodal histogram (dark background, bright foreground) it lands in the valley between the modes without any tuning. With class probabilities ω₀(t), ω₁(t) and means μ₀(t), μ₁(t):

σ_b²(t) = ω₀ ω₁ (μ₀ − μ₁)²

When several thresholds tie (as for an image with only two gray levels), the middle of the tied range is returned.

See the book entry Segmentation.

Structs§

OtsuResult
The result of Otsu thresholding.

Functions§

otsu
Thresholds an 8-bit image with Otsu’s method.
otsu_threshold
Computes the Otsu threshold of an 8-bit image.