Sie sind auf Seite 1von 29

Technique for partitioning images directly into regions based on

intensity values and/or properties of these values.







Global thresholding: T is a constant applicable over an entire image
Variable thresholding: Value of T changes over an image
Local / Regional thresholding: Variable thresholding in which the
value of T at any point (x,y) in an image depends on properties of a
neighbourhood of (x,y)
Dynamic / adaptive thresholding: Variable thresholding in which T
depends on the spatial coordinates (x,y) themselves.

Thresholding
1 if ( , ) (object point)
( , )
0 if ( , ) (background point)
: global thresholding
f x y T
g x y
f x y T
T
>

2
1 2
1
Multiple thresholding
if ( , )
( , ) if ( , )
if ( , )
a f x y T
g x y b T f x y T
c f x y T
>

= < s


Segmentation problems requiring more than two thresholds are
difficult (often impossible) to solve, and better results usually
are obtained using other methods, such as variable thresholding.




Observations

Success of intensity thresholding is directly related to the width and
depth of the valley(s) separating the histogram modes.

Key factors affecting the properties of the valley(s) are:
Separation between peaks
Noise content in the image
Relative sizes of objects and background
Uniformity of the illumination source
Uniformity of the reflectance properties of the image.
Basic Global Thresholding
1. Select an initial estimate for the global threshold, T.

2. Segment the image using T. It will produce two groups of pixels: G1
consisting of all pixels with intensity values > T and G2 consisting
of pixels with values T.

3. Compute the average intensity values m1

and m2 for the pixels in G
1

and G
2
, respectively.

4. Compute a new threshold value:

5. Repeat Steps 2 through 4 until the difference between values of T in
successive iterations is smaller than a predefined parameter .

global thresholding can be expected to be successful in highly
controlled environments, such as industrial inspection, where control
of the illumination usually is feasible.


s
( )
1
1 2
2
T m m = +
T A
Principle: maximizing the between-class variance
1
0
Let {0, 1, 2, ..., -1} denote the distinct intensity levels
in a digital image of size pixels, and let denote the
number of pixels with intensity .
/ and 1
i
L
i i i
i
L L
M N n
i
p n MN p

= =

1 2
is a threshold value, [0, ], [ 1, -1] k C k C k L +
1
1 2 1
0 1
( ) and ( ) 1 ( )
k L
i i
i i k
P k p P k p P k

= = +
= = =

Optimum Global Thresholding Using Otsus
Method
1
1 1
0 0
1
The mean intensity value of the pixels assigned to class
C is
1
( ) ( / )
( )
k k
i
i i
m k iP i C ip
P k
= =
= =

2
1 1
2 2
1 1
2
The mean intensity value of the pixels assigned to class
C is
1
( ) ( / )
( )
L L
i
i k i k
m k iP i C ip
P k

= + = +
= =

1 1 2 2
(Global mean value)
G
Pm Pm m + =
Optimum Global Thresholding Using Otsus
Method
| |
| |
2
2 2 2
1 1 2 2
2
1 2 1 2
2
1 1 1
1 1
2
1
1 1
Between-class variance, is defined as
( ) ( )
= ( )
=
(1 )
=
(1 )
B
B G G
G
G
P m m P m m
PP m m
m P m P
P P
m P m
P P
o
o = +

Optimum Global Thresholding Using Otsus


Method
2 2 2
0 1
The optimum threshold is the value, k*, that maximizes
( *), ( *) max ( )
B B B
k L
k k k o o o
s s
=
1 if ( , ) *
( , )
0 if ( , ) *
f x y k
g x y
f x y k
>

2
2
Separability measure
B
G
o
q
o
=
Optimum Global Thresholding Using Otsus
Method
1. Compute the normalized histogram of the input image. Denote
the components of the histogram by p
i
, i=0, 1, , L-1.
2. Compute the cumulative sums, P
1
(k), for k = 0, 1, , L-1.
3. Compute the cumulative means, m(k), for k = 0, 1, , L-1.
4. Compute the global intensity mean, m
G
.
5. Compute the between-class variance, for k = 0, 1, , L-1.
6. Obtain the Otsus threshold, k*.
7. Obtain the separability measure.



Otsus Algorithm: Summary


Using Image Smoothing to Improve Global
Thresholding

Using Edges to Improve Global Thresholding
1. Compute an edge image as either the magnitude of the
gradient, or absolute value of the Laplacian of f(x,y)
2. Specify a threshold value T
3. Threshold the image and produce a binary image, which is
used as a mask image; and select pixels from f(x,y)
corresponding to strong edge pixels
4. Compute a histogram using only the chosen pixels in f(x,y)
5. Use the histogram from step 4 to segment f(x,y) globally

Using Edges to Improve Global Thresholding


( )
1 2
2
2
1
In the case of classes, , , ..., , the between-class
variance is

1
where and
k k
K
K
B k k G
k
k i k i
i C i C
k
K C C C
P m m
P p m ip
P
o
=
e e
=
= =


1 2 1
2 2
1 2 1 1 2 1
0 1
The optimum threshold values, *, *, ..., * that maximize
( *, *, ..., *) max ( , , ..., )
K
B K B K
k L
k k k
k k k k k k o o


s s
=
Multiple Thresholds

Subdivide an image into nonoverlapping rectangles

The rectangles are chosen small enough so that the illumination
of each is approximately uniform.
Variable Thresholding: Image Partitioning


Let and denote the standard deviation and mean value
of the set of pixels contained in a neighborhood , centered
at coordinates ( , ) in an image. The local thresholds,

xy xy
xy
xy
m
S
x y
T
o

If the background is nearly constant,

xy xy
xy xy
a bm
T a bm
o
o
= +
= +
1 if ( , )
( , )
0 if ( , )
xy
xy
f x y T
g x y
f x y T
>

Variable Thresholding Based on Local Image


Properties
A modified thresholding
1 if (local parameters) is true
( , )
0 otherwise
Q
g x y

=

. .,
true if ( , ) AND ( , )
( , )
false otherwise
xy xy
xy xy
e g
f x y a f x y bm
Q m
o
o
> >

Variable Thresholding Based on Local Image


Properties

a=30
b=1.5
m
xy
= m
G

Thresholding based on moving averages works well when the
objects are small with respect to the image size

Quite useful in document processing

The scanning (moving) typically is carried out line by line in
zigzag pattern to reduce illumination bias

Variable Thresholding Using Moving Averages


1
1
2
Let denote the intensity of the point encountered in
the scanning sequence at step 1. The moving average
(mean intensity) at this new point is given by
1 1
( 1) ( ) (
k
k
i
i k n
z
k
m k z m k
n n
+
+
= +
+
+ = = +
1
1
)
where denotes the number of points used in computing
the average and (1) / , the border of the image were
padded with -1 zeros.
k k
z z
n
m z n
n
+

=
Variable Thresholding Using Moving Averages


1 if ( , )
( , )
0 if ( , )
xy
xy
xy xy
f x y T
g x y
f x y T
T bm
>

=

s

=
Variable Thresholding Using Moving Averages

N = 20
b=0.5

Das könnte Ihnen auch gefallen