CV Lab 14 · Module 4 — Thresholding

Thresholding: Simple & Otsu

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

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?