0% found this document useful (0 votes)
99 views17 pages

Basic Adaptive Thresholding: Bill Ames CIS 467 Spring '05

Adaptive thresholding uses multiple threshold values instead of a single global threshold value to account for non-uniform illumination in images. It separates an image into foreground and background objects by applying different threshold values to sub-regions of the image. The basic formula computes thresholds for each sub-image by taking the morphological opening of the image and applying thresholding to the result. In MATLAB, adaptive thresholding can be implemented using morphological operations and thresholding functions.

Uploaded by

Gabriel Humpire
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views17 pages

Basic Adaptive Thresholding: Bill Ames CIS 467 Spring '05

Adaptive thresholding uses multiple threshold values instead of a single global threshold value to account for non-uniform illumination in images. It separates an image into foreground and background objects by applying different threshold values to sub-regions of the image. The basic formula computes thresholds for each sub-image by taking the morphological opening of the image and applying thresholding to the result. In MATLAB, adaptive thresholding can be implemented using morphological operations and thresholding functions.

Uploaded by

Gabriel Humpire
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Basic Adaptive Thresholding

Bill Ames
CIS 467
Spring `05
Overview
• Thresholding is used to separate out
different parts of the histogram of an image
– Given the threshold of an image f(x,y) is an
object point if it is greater than the threshold
– Otherwise it is known as a background point
Overview
• Illumination effects the histogram of an
image
• Where there is non-constant illumination,
the histogram of an image can be difficult to
threshold using one value, because the
background value will change from point to
point
Example:

• This image, with the varing illumination would


look ugly if a global thresh hold was used
Ex Con’t
• Namely, it would look like this:
Solution
• Unlike global thresholding, which uses one
value of T, adaptive thresholding uses
multiple values
• Example:
– Two classes, background and object;
• T1 < (x,y) < T2

• Where f(x,y) > T1 = object and


• f(x,y) <= T0 = background
Math Stuff
• The basic formula for local thresholding is:

– g(x,y) = 1 if (f(x,y) >= T(x,y)


– 0 if (f(x,y) < T(x,y)
Where:
T(x,y) = fo(x,y) + To(x,y)
Where fo is the morphological opening of f
and To is the threshold of that opening
Math Con’t
• Before those values can be calculated, the
image has to be sub-divived.
• A threshold is computed for each sub-image
The image is then adjusted using the
multible thresholds on the various sub-
images
In MATLAB
• Thresholds can be computed in MATLAB by
using either graythresh(image) or:
– T = .5*(double(min(f(:))) +
double(max((f(:))));
– done = false;
– while –done
• g = f >= T;
• Tnext = .5*(mean(f(g)) + mean(f(~g)));
• done = abs(T-Tnext) < .t;
• T = Tnext
– done
In MATLAB
• Adaptive Thresholding can be done by
taking the morphological opening of an
image, then applying graythresh() to the
result.
• It can be shown to be equivalent to the
methods shown in the “Math” slides.
In MATLAB
• That looks something like:
function [] = project(var1, var2, var3, var4)
• mod1 = imtophat(var1, strel(var2, var3, var4));
T = graythresh(mod1);
out = im2bw(mod1,T);
imshow(out);

Var1 is the image, var2-4 are the parameters to the


top-hat function, the output is displayed by the
function and there is no return value
Examples
• The images used in the book for these
examples are not in the downloads, so I will
draw them for you, and you can pretend that
I am MATLAB when I transform the
images.
Reflection and Illumination
Basic Adaptive Thresholding
Basic Adaptive Thresholding
Comments
• This method is not optimal
• Optimal Adaptive Thresholding creates a
Threshold that produces the minimum
average segment error
• It does this by lots of probability stuff that is
not covered in this presentation.
Questions?

You might also like