Professional Documents
Culture Documents
∪R R
n
(a) i
i0
• Region-based segmentation
– partition an image into regions that are similar according to a set
of predefined criteria.
Detection of Discontinuities
• Detect the three basic types of gray-level discontinuities
– points , lines , edges
• Use the image sharpening techniques
– The first order derivatives produce thicker edges
– The second order derives have a strong response to fine detail,
such as thin lines and isolated points, and noise
– Laplasian operation
• Can be done by running a mask through the image
R w1 z1 w2 z2 ... w9 z9
9
wk zk
k 1
4
Point Detection
Steps for point dection
1. Apply Laplacian filter to the image
to obtain R(x, y)
2. Create binary image by threshold
1, if | R(x, y) | T
g(x, y)
0, otherwise
where T is a nonnegative threshold
5
Example
6
Line Detection
• A special mask is needed to detect a special type of line
• Examples:
– Horizontal mask has high response when a line passed through
the middle row of the mask.
7
Multiple Lines Detection
• Apply every masks on the image, find the maximum response.
Example:
Let R1, R2, R3, R4 denotes the response of the horizontal, +45 degree,
vertical and -45 degree masks, respectively. if, at a certain point in the
image |Ri| > |Rj|, for all ji, that point is said to be more likely associated
with a line in the direction of mask i.
8
Edge Detection
9
Example of edges in an image
• An image may all the three types of edges
First and Second derivatives at the edge
11
Noise Images
• First column: images and gray-
level profiles of a ramp edge
corrupted by random Gaussian
noise of mean 0 and = 0.0,
0.1, 1.0 and 10.0, respectively.
12
Steps in edge detection
1. Image smoothing for noise reduction
2. Detection of edge points. Points on an edge
3. Edge localization
13
Image gradient
• Gradient is a vector f
g x x
f f
g y
y
• The magnitude of the gradient
f f
2
g x2 g y2
2
M (x, y) mag(f )
x y
• The direction of the gradient vector
gy
(x, y) tan
1
gx
• The direction of an edge at (x, y) is perpendicular to the direction
of the gradient vector at that point
14
Example
f
x 2
f , M (x, y) 2 2,
f 2
y
(x, y) tan 1 (2 / 2) 45o
Gradient Operators and Masks
f
gx f (x 1, y) f (x, y)
x
f
gy f (x, y 1) f (x, y)
y
Roberts cross-gradient operators
f (x, y)
gx z 9 z5
x
f (x, y)
gy z 8 z6
y
Prewitt operators
f
gx (z 7 z 8 z 9 ) (z1 z 2 z 3 )
x
f
gy (z 3 z 6 z 9 ) (z 1 z 4 z 7 )
y
Sobel operators
f
gx (z7 2z8 z 9 ) (z1 2z 2 z 3 )
x
f
gy (z3 2z6 z9 ) (z1 2z 4 z 7 )
y
16
Prewitt and Sobel masks for Diagonal edges
17
Example
18
Example
Example
20
Example
Laplacian
Laplacian operator
2 f ( x, y) 2 f ( x, y)
f
2
x 2
y 2
2 f [ f (x 1, y) f (x 1, y)
f (x, y 1) f (x, y 1) 4 f (x, y)]
22
Laplacian of Gaussian
• Laplacian combined with smoothing as a precursor to
find edges via zero-crossing.
x2 y2
G ( x, y ) e 2 2
2G 2G
G ( x, y )
2
x y
x2 y2
x 2 y 2 2 2
2
e
2
4
g ( x , y ) 2 G ( x, y ) f ( x , y 0
23
Marr-Hildreth edge detection algorithm
1. Filter the input with an n by an Gaussian lowpass filter
2. Compute the Laplacian of the image of step 1
3. Find the zero crossing of the image from step
Approximate the zero crossing from LoG image to threshold the LoG image by
setting all its positive values to white and all negative values to black. the zero
crossing occur between positive and negative values of the thresholded LoG.
Zero crossing vs. Gradient
• Attractive
– Zero crossing produces thinner edges
– Noise reduction
• Drawbacks
– Zero crossing creates closed loops. (spaghetti effect)
– sophisticated computation.
• Gradient is more frequently used.
25
Example
26
Image Segmentation II
1. Threshold
2. Region-based segmentation
3. Segmentation using watersheds
4. Segmentation with Matlab
Thresholding
• Problem: how to determine the threshold value of
segmentation?
• Histogram
a, if f (x, y) T2
1, if f (x, y) T g(x, y) , if T f (x, y) T
g(x, y) b 1 2
0, if f (x, y) T
c, if f (x, y) T2
The role of noise in image thresholding
• When noise is small, the method work, otherwise it may
not work. Noise reduction has to be done before
choosing threshold value
The Role of Illumination
Illumination plays an important role
f(x,y) = i(x,y) r(x,y)
Approach:
1.g(x,y) = ki(x,y)
30
Basic Global Thresholding
Based on visual inspection of histogram
1. Select an initial estimate for T.
2. Segment the image using T. This will produce two
groups of pixels: G1 consisting of all pixels with gray
level values > T and G2 consisting of pixels with gray
level values T
3. Compute the average gray level values m1 and m2 for
the pixels in regions G1 and G2
4. Compute a new threshold value T = 0.5 (m1 + m2)
5. Repeat steps 2 through 4 until the difference in T in
successive iterations is smaller than a predefined
parameter To.
31
Basic Global Thresholding
Use T midway between the max and min gray levels
generate binary image
[m G P1 (k ) m(k )]2
(k )
2
, k 0,1, 2,..., L 1
P1 (k )[1 P1 (k )]
B
K K
mG Pi m i , 2
B
( k 1 , . .. , k K ) Pi [ m i m G ] 2
i 1 i1
4. Obain theresold
k * , ..., k *
1 K 1
s u c h th a t B2 ( k 1* , ..., k K* 1 ) m a x { B2 ( k 1 , ..., k K 1 )}
k
5. Threshold image
a 1 if f ( x , y ) k 1*
a 2 if k 1* f ( x , y ) k 2*
g (x, y)
⁝
a K if f ( x , y ) k K*
Example
Basic Adaptive Thresholding
• Subdivide original image into small areas.
41
Example : Adaptive Thresholding
42
2. Region-Based Segmentation
• Basic Formulation
n
() Ri R
i1
ex. P(Ri) = TRUE if all pixel in Ri have the same gray level
43
Two basic approaches
• Region Growing
– start with a set of “seed” points
– growing by appending to each seed those neighbors that have
similar properties such as specific ranges of gray level
e.g
TRUE if the absolute difference of the
intensites between the seed and
Q
the pixel at (x,y) is T
FALSE otherwise
45
Region splitting and merging
Quadtree
1. Split into 4 disjoint quadrants any region Ri for which
P(Ri) = FALSE
2. Merge any adjacent region Rj and Rk for which
P(Ri Rk ) = TRUE
3. Stop when no further merging or splitting is possible.
Example
TRUE if a and 0 m b
Q
FALSE otherwise
where m and the mean and standard deviation
of pixels in a quadregion
Example
58