Image Segmentation
Fundamentals
► Let R represent the entire spatial region occupied by an
image. Image segmentation is a process that partitions R
into n sub-regions, R1, R2, …, Rn, such that
n
(a) Ri R.
i 1
(b) Ri is a connected set. i 1, 2, ..., n.
(c) Ri R j .
(d) ( Ri ) TRUE for i 1, 2, ..., n.
(e) ( Ri R j ) FALSE for any adjacent regions
Ri and R j .
Background
► First-order derivative
f
f '( x) f ( x 1) f ( x)
x
► Second-order derivative
2 f
f ( x 1) f ( x 1) 2 f ( x)
x 2
5/12/2024 4
Characteristics of First and Second Order
Derivatives
► First-order derivatives generally produce thicker edges in
image
► Second-order derivatives have a stronger response to fine
detail, such as thin lines, isolated points, and noise
► Second-order derivatives produce a double-edge response
at ramp and step transition in intensity
► The sign of the second derivative can be used to determine
whether a transition into an edge is from light to dark or
dark to light
Detection of Isolated Points
► The Laplacian
2
f 2
f
f ( x, y ) 2 2
2
x y
f ( x 1, y ) f ( x 1, y ) f ( x, y 1) f ( x, y 1)
4 f ( x, y )
9
1 if | R( x, y ) | T R wk zk
g ( x, y ) k 1
0 otherwise
Line Detection
► Second derivatives to result in a stronger response and to
produce thinner lines than first derivatives
► Double-line effect of the second derivative must be
handled properly
Detecting Line in Specified Directions
► Let R1, R2, R3, and R4 denote the responses of the masks in
Fig. 10.6. If, at a given point in the image, |Rk|>|Rj|, for all
j≠k, that point is said to be more likely associated with a
line in the direction of mask k.
Edge Detection
► Edges are pixels where the brightness function changes
abruptly
► Edge models
Basic Edge Detection by Using First-Order
Derivative
f
g x x
f grad ( f )
g y f
y
The magnitude of f
M ( x, y ) mag(f ) g x 2 g y 2
The direction of f
gx
( x, y ) tan
1
g y
The direction of the edge
- 90
Basic Edge Detection by Using First-Order
Derivative
f
g x x
Edge normal: f grad ( f )
g y f
y
Edge unit normal: f / mag(f )
In practice,sometimes the magnitude is approximated by
f f f f
mag(f )= + or mag(f )=max | |,| |
x y x y
The Canny Edge Detector
► Home task
Thresholding
1 if f ( x, y ) T (object point)
g ( x, y )
0 if f ( x, y ) T (background point)
T : global thresholding
Multiple thresholding
a if f ( x, y ) T2
g ( x, y ) b if T1 f ( x, y ) T2
c if f ( x, y ) T1
Optimum Global Thresholding Using Otsu’s
Method
► Principle: maximizing the between-class variance
Let {0, 1, 2, ..., L -1} denote the L distinct intensity levels
in a digital image of size M N pixels, and let ni denote the
number of pixels with intensity i.
L 1
pi ni / MN and p
i 0
i 1
k is a threshold value, C1 [0, k ], C2 [k 1, L -1]
k L 1
P1 (k ) pi and P2 (k ) p i 1 P1 (k )
i 0 i k 1
Optimum Global Thresholding Using Otsu’s
Method
The mean intensity value of the pixels assigned to class
C1 is
k
1 k
m1 (k ) iP(i / C1 ) ipi
i 0 P1 (k ) i 0
The mean intensity value of the pixels assigned to class
C2 is
L 1
1 L 1
m2 ( k ) iP(i / C2 ) ipi
i k 1 P2 (k ) i k 1
1 1 P2 m2 mG (Global mean value)
Pm
Optimum Global Thresholding Using Otsu’s
Method
Between-class variance, B2 is defined as
B2 P1 ( m1 mG ) 2 P2 ( m2 mG ) 2
= P1 P2 ( m1 m2 ) 2
mG P1 m1P1
2
=
P1 (1 P1 )
mG P1 m
2
=
P1 (1 P1 )
Optimum Global Thresholding Using Otsu’s
Method
The optimum threshold is the value, k*, that maximizes
B2 (k*), B2 (k*) max B2 (k )
0 k L 1
1 if f ( x, y ) k *
g ( x, y )
0 if f ( x, y ) k *
B2
Separability measure 2
G