Professional Documents
Culture Documents
Stefano Ferrari
Universit`a degli Studi di Milano
stefano.ferrari@unimi.it
Elaborazione delle immagini
(Image processing I)
academic year 20112012
Segmentation by thresholding
1, if f (x, y) > T
0, if f (x, y) T
Multiple thresholding:
g(x, y) =
a, if f (x, y) > T
2
b, if T
1
< f (x, y) T
2
c, if f (x, y) T
1
.
Stefano Ferrari Elaborazione di immagini (Image processing) a.a. 2011/12 1
Choosing the thresholds
G
1
, pixels brighter than T;
G
2
, pixels darker than (or equal to) T.
3. Computation of the average intensities m
1
and m
2
of G
1
and
G
2
.
4. New threshold value:
T
new
=
m
1
+ m
2
2
5. If |T T
new
| > T, back to step 2, otherwise stop.
.
Stefano Ferrari Elaborazione di immagini (Image processing) a.a. 2011/12 3
Global thresholding: an example
Otsus method
M N image histogram:
n
i
#pixels of intensity i :
MN =
L1
i =0
n
i
Normalized histogram:
p
i
=
n
i
MN
L1
i =0
p
i
= 1, p
i
0
.
Stefano Ferrari Elaborazione di immagini (Image processing) a.a. 2011/12 4
Otsus method (2)
two classes: C
1
(pixels in [0, k]) and C
2
(pixels in
[k + 1, L 1])
P
1
= P(C
1
) =
k
i =0
p
i
, probability of the class C
1
P
2
= P(C
2
) =
P
L1
i =k+1
p
i
= 1 P
1
, probability of the class C
2
m
1
, mean intensity of the pixels in C
1
:
m
1
=
k
i =0
i P(i |C
1
)
=
k
i =0
i
P(C
1
|i )P(i )
P(C
1
)
=
1
P
1
k
i =0
i p
i
where P(C
1
|i ) = 1, P(i ) = p
i
e P(C
1
) = P
1
.
Otsus method (3)
Similarly, m
2
, mean intensity of the pixels in C
2
:
m
2
=
1
P
2
L1
i =k+1
i p
i
i =0
i p
i
i =0
i p
i
Hence:
P
1
m
1
+ P
2
m
2
= m
G
P
1
+ P
2
= 1
.
Stefano Ferrari Elaborazione di immagini (Image processing) a.a. 2011/12 5
Otsus method (4)
2
G
=
L1
i =0
(i m
G
)
2
p
i
2
B
= P
1
(m
1
m
G
)
2
+ P
2
(m
2
m
G
)
2
= P
1
P
2
(m
1
m
2
)
2
=
(m
G
P
1
m)
2
P
1
(1 P
1
)
x
2
G
Otsus method (5)
2
G
where
2
B
(k) =
(m
G
P
1
(k) m(k))
2
P
1
(k) (1 P
1
(k))
, satises:
2
B
(k
) = max
0<k<L1
2
B
(k)
.
Stefano Ferrari Elaborazione di immagini (Image processing) a.a. 2011/12 6
Otsus method: an example
a b
c d
(a) original image;
(b) histogram of
(a);
(c) global
threshold:
T = 169,
= 0.467;
(d) Otsus method:
T = 181,
= 0.944.
Smoothing
Between-class variance:
2
B
(k
1
, k
2
) = P
1
(m
1
m
G
)
2
+P
2
(m
2
m
G
)
2
+P
3
(m
3
m
G
)
2
1
and k
2
can be computed as:
2
B
(k
1
, k
2
) = max
0<k
1
<k
2
<L1
2
B
(k
1
, k
2
)
1
, k
2
) =
2
B
(k
1
, k
2
)
2
G
.
Stefano Ferrari Elaborazione di immagini (Image processing) a.a. 2011/12 9
Multiple thresholds Otsus method: an example
Image partitioning based thresholding
For example:
T
xy
= a
xy
+ bm
xy
T
xy
= a
xy
+ bm
G
1, if Q
xy
0, otherwise
where Q
xy
can be, for instance:
f (x, y) > T
xy
f (x, y) > a
xy
AND f (x, y) > bm
xy
Pixels are visited following a zigzag path and the statistics are
computed using only the last n visited pixels.
Growing based segmentation
It is strictly application-dependent.
S(x, y), binary image with the seeds (it is 1 only where
the seeds are located);
(b) 32 32
(c) 16 16
(b) 8 8
Watershed
HSI space
.
Stefano Ferrari Elaborazione di immagini (Image processing) a.a. 2011/12 20
Color based segmentation (2)
a b
c d
(a) Binary
saturation
mask
(threshold at
90%);
(b) product of the
mask by the
hue;
(d) segmentation
of (b) based on
its histogram
(c).
Color based segmentation (3)
(z a)
T
(z a)
1
2
D(z, a) =
(z a)
T
C
1
(z a)
1
2
.
Stefano Ferrari Elaborazione di immagini (Image processing) a.a. 2011/12 21
Color based segmentation (4)
a
b
(a) Manual selection of the color of
interest.