3. Thresholding
It is the simplest and powerful method
of image segmentation
It is useful in discriminating foreground from
the background.
Thresholding operation is used to convert a
gray scale image into binary image
The advantage of obtaining first a binary
image is that it reduces the complexity of the
data and simplifies the process of recognition
and classifiction.
4. Where (x,y) represents a gray value/
are the coordinates of the threshold value p
T represent threshold value
g(x,y) represents threshold image
f(x,y) represents gray level image pixels/
input image
Thresholding
The most common way to convert a gray-level image
into a binary image is to select a single threshold
value(T).Then all the gray level values below T will be
classified as black(0) i.e. background and those above
T will be white(1) i.e. objects.
The Thresholding operation is a grey value remapping
operation g defined by:
0 if f(x,y) < T
g(x,y)=
1 if f(x,y) ≥ T,
7. Otsu Binarization
Otsu method is a popular thresholding method.
that it works on the histogram of the image.
It assumes the image contains two classes of
pixels - foreground and background.
It also assumes the image has a bimodal
histogram displaying two peaks.
then sets a threshold on the image such that the
intra class variance is minimized.
The first paper in this field:
N. Otsu, "A Threshold Selection Method from Gray-Level
Histograms," Transaction on systems, man and cybernetics,
vol. 9, no. 1, pp. 62-66, 1979
8. The aim is to find the threshold value where
the sum of foreground and background
spreads is at its minimum.
Based on a very simple idea: Find the
threshold that minimizes the weighted within-
class variance.
This turns out to be the same as maximizing
the between-class variance.
Operates directly on the gray level histogram
[e.g. 256 numbers, P(i)], so it’s fast (once the
histogram is computed).
Otsu Binarization…
9. Simple example
The calculations for finding the foreground and background variances (the
measure of spread) for a single threshold are now shown in next slide.
11. Example…
The next step is to calculate the 'Within-Class
Variance'. This is simply the sum of the two
variances multiplied by their associated
weights
12. Example…
This final value is the 'sum of weighted variances' for the threshold
value 3. This same calculation needs to be performed for all the
possible threshold values 0 to 5. The table below shows the results
for these calculations. The highlighted column shows the values for
the threshold calculated above
13. Example…
It can be seen that for the threshold equal to 3, as well as being
used for the example, also has the lowest sum of weighted
variances. Therefore, this is the final selected threshold. All pixels
with a level less than 3 are background, all those with a level equal
to or greater than 3 are foreground. As the images in the table
show, this threshold works well.
14. A Faster Approach
By a bit of manipulation, you can calculate what is called
the between class variance, which is far quicker to calculate.
Luckily, the threshold with the maximum between class variance
also has the minimum within class variance. So it can also be used
for finding the best threshold and therefore due to being simpler is a
much better approach to use.
15. Formula:
The weighted within-class variance is:
)()()()()( 2
22
2
11
2
ttwttwtw
Where the class probabilities are estimated as:
q1(t) P(i)
i1
t
q2 (t) P(i)
i t 1
I
t
i tw
iiP
t
1 1
1
)(
)(
)(
I
ti tw
iiP
t
1 2
2
)(
)(
)(
And the class means are given by:
Permit me to say threshold works like a compiler.the binary image contain all of the essential information about the position and shape of the objects of interest(foreground)
Thresholding works well when a grey level histogram of the image groups separates the pixels of the object and the background into two dominant modes. Then a threshold T can be easily chosen between the modes.
The threshold operator T,is the widely used image-to-image transformation.it follows that the threshold operator maps any gray-tone image into a binary image.
Histogram are constructed by splitting the range of the data into equal-sized bins (called classes). Then for each bin, the number of points from the data set that fall into each bin are counted.
Vertical axis: Frequency (i.e., counts for each bin)
Horizontal axis: Response variable
In image histograms the pixels form the horizontal axis
In Matlab histograms for images can be constructed using the imhist command.
Horizontal axis: Response variable/pixel intensity
Vertical axis: pixel count
Thresholding may be viewed as an operation that involves tests against a function T of the form:
T = T[x,y,p(x,y),f(x,y)]
Where f(x,y) is the gray level , and p(x,y) is some local property.
Simple thresholding schemes compare each pixels gray level with a single global threshold. This is referred to as Global Thresholding.
If T depends on both f(x,y) and p(x,y) then this is referred to a Local Thresholding.
Thresholding is also used to filter the output of or input to other operators. For instance, in the former case, an edge detector like Sobel will highlight regions of the image that have high spatial gradients. If we are only interested in gradients above a certain value (i.e. sharp edges), then thresholding can be used to just select the strongest edges and set everything else to black. As an example,
Permit me to say threshold works like a compiler.the binary image contain all of the essential information about the position and shape of the objects of interest(foreground)