Adaptive Thresholds Under Uneven Light
The left side of a carton is much darker than the right.
Read the full lesson and open its transcript below. A narrated video will be added after production.
What you will learn
The left side of a carton is much darker than the right.
A practical question
The left side of a carton is dark and the right side is bright. An adaptive threshold estimates a local cutoff from pixels near each position. That can follow slow changes in illumination more closely than one rule for the whole frame.
The useful idea
Choose a neighborhood large enough to see local background, but small enough to respond to the lighting variation. Near a label edge, the neighborhood contains both ink and cardboard. If it's too small or its rule is poorly chosen, the label itself can distort the estimated threshold. The local method still needs careful validation.
Work through the example
Compare two windows: one over dark cardboard and one over bright cardboard. Inspect the resulting mask on both sides and around thin letters. Then repeat with a label partly covered by shadow. Keep the original beside the mask so a dark processing artifact doesn't become a false printed mark. Local thresholds can respond to a bright and a shaded region separately. But a small window may follow texture or noise, while a very large window behaves more like a global cutoff. Place example windows over the printed mark, blank paper, and shadow. Compare the resulting mask with the original under each condition. If a true mark disappears in one region, do not call the method successful simply because another region became clean. Use this case to test your understanding: Compare a window over the dark side with a window over the bright side. Here is the limitation to watch for: A window too small follows noise; one too large misses local changes. This supports a careful conclusion: Adaptive thresholding computes a local rule from neighborhoods to handle uneven illumination.
Limits and next step
Save the window size and local statistic with the output. Next, we'll start from one trusted pixel and grow a region using its similarity to nearby pixels.
Worked example
Compare a window over the dark side with a window over the bright side.
Quick check: test your understanding
Try it yourself: Consider this case: Compare a window over the dark side with a window over the bright side. Explain how you would check the result. In your answer, address this limitation: A window too small follows noise; one too large misses local changes.
Check the reasoning
Adaptive thresholding computes a local rule from neighborhoods to handle uneven illumination. A window too small follows noise; one too large misses local changes.
What is the main idea behind adaptive thresholds under uneven light?
Adaptive thresholding computes a local rule from neighborhoods to handle uneven illumination.
How is it used in the example?
Compare a window over the dark side with a window over the bright side.
What limitation should be checked?
A window too small follows noise; one too large misses local changes.
Further reading
Digital Image Processing, 4th edition — Rafael C. Gonzalez and Richard E. Woods.
Original ToolsInVision teaching examples. Editorial approach · Suggest a correction
Accessible referenceLesson 62 transcript302 words · Narration ready for the upcoming videoOpen transcript
The left side of a carton is dark and the right side is bright. An adaptive threshold estimates a local cutoff from pixels near each position. That can follow slow changes in illumination more closely than one rule for the whole frame.
Choose a neighborhood large enough to see local background, but small enough to respond to the lighting variation. Near a label edge, the neighborhood contains both ink and cardboard. If it's too small or its rule is poorly chosen, the label itself can distort the estimated threshold. The local method still needs careful validation.
Compare two windows: one over dark cardboard and one over bright cardboard. Inspect the resulting mask on both sides and around thin letters. Then repeat with a label partly covered by shadow. Keep the original beside the mask so a dark processing artifact doesn't become a false printed mark. Local thresholds can respond to a bright and a shaded region separately. But a small window may follow texture or noise, while a very large window behaves more like a global cutoff. Place example windows over the printed mark, blank paper, and shadow. Compare the resulting mask with the original under each condition. If a true mark disappears in one region, do not call the method successful simply because another region became clean. Use this case to test your understanding: Compare a window over the dark side with a window over the bright side. Here is the limitation to watch for: A window too small follows noise; one too large misses local changes. This supports a careful conclusion: Adaptive thresholding computes a local rule from neighborhoods to handle uneven illumination.
Save the window size and local statistic with the output. Next, we'll start from one trusted pixel and grow a region using its similarity to nearby pixels.