Image Segmentation © 2002-2003 by Yu Hen Hu ECE533 Digital Image Processing What is Image Segmentation?  Segmentation: » Split or separate an image into regions » To.

Download Report

Transcript Image Segmentation © 2002-2003 by Yu Hen Hu ECE533 Digital Image Processing What is Image Segmentation?  Segmentation: » Split or separate an image into regions » To.

Image
Segmentation
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
1
What is Image Segmentation?

Segmentation:
» Split or separate an image into
regions
» To facilitate recognition,
understanding, and region of
interests (ROI) processing

20
40
60
20
40
60
Ill-defined problem
» The definition of a region is contextdependent
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
2
Outline

Discontinuity Detection
» Point, edge, line
Edge Linking and boundary detection
 Thresholding
 Region based segmentation
 Segmentation by morphological
watersheds
 Motion segmentation

© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
3
Point Detection
Apply detection mask, followed
by threshold detection
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
4
Line Detection
Useful for
detecting lines
with width = 1.
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
5
Edge Detection
Points and lines are special cases of
edges.
 Edge detection is difficult since it is not
clear what amounts to an edge!

© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
6
Edge Detection
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
7
Impact of Noise
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
8
First & Second Derivatives of Edges
Gx  f / x 
f     

G y  f / y 
f  Gx2  G y2  Gx  G y : magnitudeof gradient
 Gy 
 : directionof gradient,
 Gx 
 ( x, y )  tan1 
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
9
Edge Detection Operators
Figure 10.8, 10.9
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
10
Approximate Gradient with L1 Norm
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
11
Effects of Smoothing
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
12
Emphasizing Diagonal Edges
Use diagonal
Sobel operator
shown in figure
10.9(d)
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
13
Laplacian and Mexican Hat
2 f 2 f
 f  2  2
x
y
2
LoG operator
© 2002-2003 by Yu Hen Hu

 h( r )    e
2
2

 r 2 / 2 2
ECE533 Digital Image Processing

2
2
    r e r / 2 
4
2
2
14
Comparison of Edge Detection
original
Sobel
LoG
Threshold LoG
Zero-crossing
Gradient method:
suitable for abrupt gray level
transition, sensitive to noise
2nd order derivative:
good for smooth edges
Gaussian smooth
operator
© 2002-2003 by Yu Hen Hu
Laplacian
operator
ECE533 Digital Image Processing
15
Boundary Extraction



Edge detection
classifies individual
pixels to be on an edge
or not.
Isolated edge pixels is
more likely to be noise
rather than a true edge.
Adjacent or connected
edge pixels should be
linked together to form
boundary of regions that
segment the image.
© 2002-2003 by Yu Hen Hu

Edge linking methods:
»
»
»
»
Local processing
Hough transform
Graphic theoretic method
Dynamic programming
ECE533 Digital Image Processing
16
Local Processing Edge Linking
An edge pixel will be
linked to another
edge pixel within its
own neighborhood if
they meet two
criteria:
f ( x, y )  f ( xo , yo )  E
 ( x, y )   ( xo , yo )  A
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
17
Global Processing Edge Linking:
Hough Transform
Find a subset of n points on an
image that lie on the same straight
line.
Write each line formed by a pair of
these points as
yi = axi + b
Then plot them on the parameter
space (a, b):
b = xi a + yi
All points (xi, yi) on the same line will
pass the same parameter space
point (a, b).
Quantize the parameter space and
tally # of times each points fall into
the same accumulator cell. The cell
count = # of points in the same line.
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
18
Hough Transform in (r, ) plane
To avoid infinity slope,
use polar coordinate to
represent a line.
x cos  y sin   r
Q points on the same
straight line gives Q
sinusoidal curves in (r,
) plane intersecting at
the same (ri, i) cell.
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
19
Example
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
20
Example
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
21
Threshold Segmentation
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
22
Effect of Illumination on Thresholding
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
23
Threshold Example
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
24
Needs of Adaptive Threshold
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
25
Needs of Local Threshold
Properly and improperly segmented
subimages from Fig. 10.30.
Further division of the sub-image,
and result of adaptive thresholding
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
26
Threshold: Hypothesis Testing

Question:

» Does this pixel with
intensity z belong to a
region (edge) or not?

Hypothesis
» H0: Null. It does not
» H1: Alt. It does

Likelihood
Maximum likelihood:
» Pixel z belongs to a region if
p(z|H1) > p(z|H0)

Bayesian:
P2 p(z|H1) > P1 p(z|H0)

Sufficient statistic:
z>T
» p(z|zH0) = p1(z)
» p(z| z H1) = p2(z)

Prior
» P1 = p(zH0) ,
» P2 = p(zH1)
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
27
Uni-model Gaussian Example

Given
pi ( z ) 

   z   i 2 
1

exp
2

2 
 2 i

Set
P1 p1(T) = P2 p2(T)
and solve for T.
Take log on both sides
and simplify to
AT2 + BT + C = 0
© 2002-2003 by Yu Hen Hu
A   12   22

B  2 1 22   2 12

 P 
C   12  22   22 12  2 12 22 ln 2 1 
  1 P2 
If  1   2   , then
T
1   2
2
 P2 
2

 ln 
1   2  P1 
ECE533 Digital Image Processing
28
Clustering Problem Statement

Given a set of vectors {xk; 1  k  K}, find a set of
M clustering centers {w(i); 1  i  c} such that
each xk is assigned to a cluster, say, w(i*),
according to a distance (distortion, similarity)
measure d(xk, w(i)) such that the average
distortion
1 c K
D   I ( xk , i)d ( xk ,W (i))
K i 1 k 1

is minimized.
I(xk,i) = 1 if x is assigned to cluster i with cluster
center w(I); and = 0 otherwise -- indicator function.
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
29
k-means Clustering Algorithm
Initialization: Initial cluster center w(i); 1  i  c, D(–1)= 0, I(xk,i)
= 0, 1  i  c, 1  k  K;
Repeat
(A) Assign cluster membership (Expectation step)
Evaluate d(xk, w(i));
1  i  c, 1  k  K
I(xk,i) = 1 if d(xk, w(i)) < d(xk, w(j)), j  i;
= 0; otherwise.
1kK
N
(B) Evaluate distortion D:
D(iter)   I ( xk , i)d ( xk , w(i)) 1  k  K
k 1
(C) Update code words according to new assignment
(Maximization)
N
W (i)   I ( xk , i) xk ,
k 1
N
N i   I ( xk , i),
1 i  c
k 1
(D) Check for convergence
if 1–D(Iter–1)/D(Iter) < e , then convergent = TRUE,
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
30
A Numerical Example
x = {1, 2,0,2,3,4},
W={2.1, 2.3}
Assign membership
2.1: {1, 2, 0, 2}
2.3: {3, 4}
Distortion
D = (1 2.1)2 + (22.1)2
+ (0 2.1)2 + (2 2.1)2 +
(3 2.3)2 + (4 2.3)2
© 2002-2003 by Yu Hen Hu
3. Update W to minimize
distortion
W1 = (12+0+2)/4 = .25
W2 = (3+4)/2 = 3.5
4. Reassign membership
.25: {1, 2, 0}
3.5: {2, 3, 4}
5. Update W:
w1 = (1 2+0)/3 = 1
w2 = (2+3+4)/3 = 3.
Converged.
ECE533 Digital Image Processing
31
Thresholding Example
Threshdemo.m
© 2002-2003 by Yu Hen Hu
ECE533 Digital Image Processing
32