Beginner level · Module 3: Image Processing Fundamentals · Lesson 2 of 3
Histograms, Equalisation and Thresholding
Learners read image histograms, improve contrast with histogram equalisation and CLAHE, and separate objects from background with global, Otsu and adaptive thresholding, including on scanned school documents.
In this lesson you will
- Interpret histograms and apply equalisation
- Choose and apply a thresholding method
Key concepts
histogramequalizeHist and CLAHEglobal thresholdOtsu's methodadaptive threshold
The lesson
A histogram counts how many pixels have each brightness value. A histogram bunched on the left means a dark image; a narrow peak means low contrast. cv2.equalizeHist spreads values out; CLAHE (cv2.createCLAHE) does this in small tiles and avoids over-amplifying noise.
Thresholding turns grayscale into black and white: pixels above a value become white. Otsu's method (cv2.THRESH_OTSU) picks the threshold automatically from the histogram, which works when object and background have clearly different brightness.
Scanned or photographed documents often have uneven lighting. cv2.adaptiveThreshold computes a threshold for each neighbourhood, which produces clean black text on white even when one side of the page is in shadow. This is the first step in digitising paper forms and records.
Step by step
- Plot the histogram of a dark and a bright image.
- Apply equalizeHist and CLAHE and compare.
- Threshold a leaf photo with Otsu's method.
- Clean a phone photo of a printed form (fictional content) with adaptive thresholding.
Practice activity
Produce clean binary versions of three fictional document photographs taken under uneven light.
Expected result: Readable binary documents and a note comparing global and adaptive thresholding.
Check your understanding
-
When does Otsu's method work well?
Show answer
When the object and background have clearly different brightness levels.
-
Why use adaptive thresholding for documents?
Show answer
It handles uneven lighting by using a local threshold for each area.
Further learning
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.