The simplest possible edge between "this" and "that": pick one number, and every pixel above it becomes white, everything below becomes black. The whole art is picking that number — by hand, automatically by finding the natural valley in the histogram, or locally so lighting can't cheat you.
Finding the valley
Most real images have a bimodal histogram — a dark hump (background or shadow) and a bright hump (foreground or paper). The best threshold almost always sits in the low valley between them. Otsu's whole method is a mathematically precise way to find that valley without a human looking at the chart.
Ready.
Threshold T
127
Input → output mapping
Histogram
Otsu threshold: —
Manual override127
Histogram + between-class variance
Pixel countBetween-class varianceCurrent T
Otsu tries every possible threshold, splits the histogram into two classes at each one, and scores how well-separated those two classes are. The score peaks exactly at the natural valley — that peak is the optimal threshold.
Block size
21
C (offset)
5
This scene has a deliberate lighting gradient — bright top-right, shadowed bottom-left — like a phone photo of a page. One global number can't serve both corners. Adaptive thresholding computes a fresh local threshold for every pixel from its own neighbourhood, so it isn't fooled by uneven light.
Three ways to pick one number
▾
Manual — you decide
Fast and simple, but brittle: the right threshold depends on the specific image's brightness, and a value that works perfectly on one photo can fail completely on the next.
Otsu — the histogram decides
No human tuning needed, as long as the image is genuinely bimodal (a clear dark group and a clear bright group). If the histogram doesn't have two clean humps, Otsu still picks a number, but it may not mean much.
Adaptive — the neighbourhood decides
Solves Otsu's biggest weakness: uneven lighting across a single image. The cost is that it's purely local — it can't see "the whole picture," so a single global number is sometimes still the right tool for evenly-lit scenes.
Predict, then verify
You scan a printed page with a lamp shining from one corner, creating a strong brightness gradient across the page. You run Otsu's method (global) to turn it into clean black text on white. What's the most likely result?