Segmentation
Segmentation
© P. Strumillo
IMAGE ANALYSIS
Classification Image understanding
Preprocessing
Segmentation
Feature extraction
database
Classification and query
interpretation
The best enemy spy!
Industrial robotics
Cartography, Geology
! "
9
2 1 3
1 for f ( x, y ) ≥ T
g ( x, y ) =
0 for f ( x, y ) < T
Thresholding
?
#&'(
1000
800
256 for f ( x , y ) ≥ T
600
g( x , y ) =
400
0 for f ( x , y ) < T
200
#$%
!
DEMO MATLAB
DEMO MATLAB
%MATLAB
x=imread('cameraman.tif'); figure(1), imshow(x);
bw=im2bw(x,0.5); figure(2), imshow(bw)
Thresholding
&) ≤ ') ≤ *)
%MATLAB
x=imread('cameraman.tif'); figure(1), imshow(x);
bw=im2bw(x,0.5); figure(2), imshow(bw)
Multilevel thresholding -example
250
200
150
100
50
x=imread('blood1.tif');
figure(1), imshow(x);
figure(2),imshow(x), colormap(jet(16))
Thresholding - revisited
1
0.9
P1
0.8
0.7
0.6
0.5 P2
0.4
0.3
T?
0.2
0.1
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
m1 m2
Optimum Threshold
m1 + m2 σ2 P2
T= + ln
2 m1 − m2 P1
2500
2000
1500
1000
500
N
a)
Ri = R
i =1
b) Ri is a connected region, i = 1, 2, …N,
c) Ri ∩ Rj = ∅ for all i and j, i≠j,
d) P(Ri) = TRUE for i = 1, 2, …N,
e) P(Ri ∪ Rj) = FALSE for i≠j
where P(Ri) is a logical predicate over the points in set Ri and
∅ is the empty set.
General formulation
Condition a) indicates that the segmentation must be
complete (all points assigned a region).
Condition c) indicates that the regions must be disjoint.
Condition d) states that all pixels in a segmented region
must satisfy the assumed predicate.
Condition e) indicates that distinct regions must be different
according to predicate P. An example predicate:
z ( x , y ) − mi ≤ 2σi
(
xiT x j = xi x j cos xi , x j )
• and Euclidean distance:
( )
d xi ,x j = (xi ( k ) − x j ( k ))2
k
Image segmentation example
© Univ. of Washington
Region splitting
Initially, the image is subdivided into a set of arbitrary
disjoint regions, then splits of the regions take place in
attempt to satisfy region uniformity criteria (a-e).
An example split algorithm works as follows:
R1 R2
R1 R2 R3 R4
R41 R42
R3
R41 R42 R43 R44
R43 R44
DEMO
MATLAB
(quad tree)
Region splitting and merging
c( s ,t ) = f ( x , y )w( x − s , y − t ) ∀( s ,t )
x y
[ f ( x, y) − f ( x, y )][w( x − s, y − t ) − w ]
x y
γ ( s, t ) =
{ [ f ( x, y ) − f ( x, y)]2 [w( x − s, y − t ) − w ]2 }1 / 2
x y x y
Template matching