Lecture 11. Image Segmentation · 12/9/2010 3 3 Image Segmentation Segmentation is to subdivide an...
Transcript of Lecture 11. Image Segmentation · 12/9/2010 3 3 Image Segmentation Segmentation is to subdivide an...
Digital Image ProcessingDigital Image Processing
Lecture 11. Image SegmentationLecture 11. Image Segmentation
Autumn 2010Autumn 2010
12/9/2010 2
FundamentalsFundamentals
► 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
12/9/2010 3
3
Image SegmentationImage Segmentation
►► Segmentation is to subdivide an image into its component Segmentation is to subdivide an image into its component
regions or objects.regions or objects.
►► Segmentation should stop when the objects of interest in Segmentation should stop when the objects of interest in
an application have been isolated.an application have been isolated.
►► Segmentation algorithms generally are based on one of 2 Segmentation algorithms generally are based on one of 2
basis properties of intensity valuesbasis properties of intensity values
�� discontinuity : to partition an image based on sharp changes indiscontinuity : to partition an image based on sharp changes in
intensity (such as edges)intensity (such as edges)
�� similarity : to partition an image into regions that are ssimilarity : to partition an image into regions that are similar imilar
according to a set according to a set
of predefined criteria.of predefined criteria.
12/9/2010 4
4
Detection of DiscontinuitiesDetection of Discontinuities
►► detect the three basic types of graydetect the three basic types of gray--level discontinuitieslevel discontinuities
�� points , lines , edgespoints , lines , edges
►► the common way is to run a mask through the image the common way is to run a mask through the image
12/9/2010 5
BackgroundBackground
► First-order derivative
► Second-order derivative
'( ) ( 1) ( )f
f x f x f xx
∂= = + −
∂
2
2( 1) ( 1) 2 ( )
ff x f x f x
x
∂= + + − −
∂
12/9/2010 6
12/9/2010 7
Characteristics of First and Second Order Characteristics of First and Second Order
DerivativesDerivatives
► 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
12/9/2010 8
8
Point DetectionPoint Detection
►► a point has been detected at the location on which the a point has been detected at the location on which the
mask is centered ifmask is centered if
|R| |R| ≥≥ TT
►► where where
�� T is a nonnegative threshold T is a nonnegative threshold
�� R is the sum of products of the coefficients with the gray levelR is the sum of products of the coefficients with the gray levels s
contained in the region encompassed by the mask.contained in the region encompassed by the mask.
12/9/2010 9
9
Point DetectionPoint Detection
►► Note that the mask is the same as the mask of Note that the mask is the same as the mask of LaplacianLaplacian
Operation (in chapter 3)Operation (in chapter 3)
►► The only differences that are considered of interest are The only differences that are considered of interest are
those large enough (as determined by T) to be considered those large enough (as determined by T) to be considered
isolated points. isolated points.
|R| |R| ≥≥ TT
12/9/2010 10
12/9/2010 11
Line DetectionLine 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
12/9/2010 12
12/9/2010 13
Detecting Line in Specified DirectionsDetecting 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.
12/9/2010 14
12/9/2010 15
Edge DetectionEdge Detection
► Edges are those places in an image that correspond to object boundaries.
► Edges are pixels where the brightness function changes abruptly
► Edge models
12/9/2010 16
Edge DetectionEdge Detection
► Edge information in an image is found by looking at the relationship a pixel has with its neighborhoods.
► If a pixel’s gray-level value is similar to those around it, there is probably not an edge at that point.
► If a pixel’s has neighbors with widely varying gray levels, it may present an edge point.
12/9/2010 17
17
Ideal and Ramp EdgesIdeal and Ramp Edges
because of optics, sampling, image acquisition imperfection
12/9/2010 18
12/9/2010 19
12/9/2010 20
12/9/2010 21
Basic Edge Detection by Using FirstBasic Edge Detection by Using First--Order Order
DerivativeDerivative
12/9/2010 22
12/9/2010 23
12/9/2010 24
12/9/2010 25
12/9/2010 26
12/9/2010 27
12/9/2010 28
12/9/2010 29
Advanced Techniques for Edge DetectionAdvanced Techniques for Edge Detection
► The Marr-Hildreth edge detector2 2
2
2 2 2 2
2 2
2 2 2 2
2 2
2
2 22
2 2
2 22 2
2 2
2 24 2 4 2
2
( , ) , : space constant.
Laplacian of Gaussian (LoG)
( , ) ( , )( , )
1 1
x y
x y x y
x y x y
G x y e
G x y G x yG x y
x y
x ye e
x y
x ye e
x
σ
σ σ
σ σ
σ
σ σ
σ σ σ σ
+−
+ +− −
+ +− −
=
∂ ∂∇ = +
∂ ∂
∂ − ∂ −= +
∂ ∂
= − + −
=
2 2
2
2 2
24
x yy
e σσ
σ
+− + −
12/9/2010 30
12/9/2010 31
MarrMarr--HildrethHildreth AlgorithmAlgorithm
1. Filter the input image with an nxn Gaussian lowpassfilter. N is the smallest odd integer greater than or equal to 6
2. Compute the Laplacian of the image resulting from step1
3. Find the zero crossing of the image from step 2
[ ]2( , ) ( , ) ( , )g x y G x y f x y= ∇
σ
12/9/2010 32
12/9/2010 33
The Canny Edge DetectorThe Canny Edge Detector
► Optimal for step edges corrupted by white noise.
► The Objective
1. Low error rateThe edges detected must be as close as possible to the true edge
2. Edge points should be well localizedThe edges located must be as close as possible to the true edges
3. Single edge point responseThe number of local maxima around the true edge should beminimum
12/9/2010 34
The Canny Edge Detector: Algorithm (1)The Canny Edge Detector: Algorithm (1)
2 2
22
Let ( , ) denote the input image and
( , ) denote the Gaussian function:
( , )
We form a smoothed image, ( , ) by
convolving and :
( , ) ( , ) ( , )
x y
s
s
f x y
G x y
G x y e
f x y
G f
f x y G x y f x y
σ
+−
=
=
12/9/2010 35
The Canny Edge Detector: Algorithm(2)The Canny Edge Detector: Algorithm(2)
2 2
Compute the gradient magnitude and direction (angle):
( , )
and
( , ) arctan( / )
where / and /
Note: any of the filter mask pairs in Fig.10.14 can be u
x y
y x
x s y s
M x y g g
x y g g
g f x g f y
α
= +
=
= ∂ ∂ = ∂ ∂
sed
to obtain and x y
g g
12/9/2010 36
The Canny Edge Detector: Algorithm(3)The Canny Edge Detector: Algorithm(3)
1 2 3 4
The gradient ( , ) typically contains wide ridge around
local maxima. Next step is to thin those ridges.
Nonmaxima suppression:
Let , , , and denote the four basic edge directions for
a 3 3 regi
M x y
d d d d
× oon: horizontal, -45 , vertical,+45 , respectively.
1. Find the direction that is closest to ( , ).
2. If the value of ( , ) is less than at least one of its two
neighbors along , let ( , ) 0
k
k N
d x y
M x y
d g x y
α
=
o
(suppression);
otherwise, let ( , ) ( , )
Ng x y M x y=
12/9/2010 37
12/9/2010 38
The Canny Edge Detector: Algorithm(4)The Canny Edge Detector: Algorithm(4)
The final operation is to threshold ( , ) to reduce
false edge points.
Hysteresis thresholding:
( , ) ( , )
( , ) ( , )
and
( , ) ( ,
N
NH N H
NL N L
NL NL
g x y
g x y g x y T
g x y g x y T
g x y g x
= ≥
= ≥
= ) ( , )
NHy g x y−
12/9/2010 39
The Canny Edge Detector: Algorithm(5)The Canny Edge Detector: Algorithm(5)
Depending on the value of , the edges in ( , )
typically have gaps. Longer edges are formed using
the following procedure:
(a). Locate the next unvisited edge pixel, , in ( , ).
(b). Mark as vali
H NH
NH
T g x y
p g x y
d edge pixel all the weak pixels in ( , )
that are connected to using 8-connectivity.
(c). If all nonzero pixel in ( , ) have been visited go to
step (d), esle return to (a).
(d). Set
NL
NH
g x y
p
g x y
to zero all pixels in ( , ) that were not marked as
valid edge pixels.
NLg x y
12/9/2010 40
The Canny Edge Detection: SummaryThe Canny Edge Detection: Summary
► Smooth the input image with a Gaussian filter
► Compute the gradient magnitude and angle images
► Apply nonmaxima suppression to the gradient magnitude image
► Use double thresholding and connectivity analysis to detect and link edges
12/9/2010 410.04; 0.10; 4 and a mask of size 25 25L HT T σ= = = ×
12/9/2010 42
0.05; 0.15; 2 and a mask of size 13 13L H
T T σ= = = ×
12/9/2010 43
12/9/2010 44
12/9/2010 45
Edge Linking and Boundary DetectionEdge Linking and Boundary Detection
► Edge detection typically is followed by linking algorithms designed to assemble edge pixels into meaningful edges and/or region boundaries
12/9/2010 46
Local ProcessingLocal Processing
► Analyze the characteristics of pixels in a small neighborhood about every point (x,y) that has been declared an edge point
► All points that similar according to predefined criteria are linked, forming an edge of pixels.
Establishing similarity: (1) the strength (magnitude) and (2) the direction of the gradient vector.
A pixel with coordinates (s,t) in Sxy is linked to the pixel at (x,y) if both magnitude and direction criteria are satisfied.
12/9/2010 47
Local ProcessingLocal Processing
Let denote the set of coordinates of a neighborhood
centered at point ( , ) in an image. An edge pixel with
coordinate ( , ) in is similar in to the pixel
at ( , ) if
( ,
xy
xy
S
x y
s t S magnitude
x y
M s ) ( , )
t M x y E− ≤
An edge pixel with coordinate ( , ) in is similar in
to the pixel at ( , ) if
( , ) ( , )
xys t S angle
x y
s t x y Aα α− ≤
12/9/2010 48