part 7: image segmentation -...
TRANSCRIPT
2010-05-12
Digital Image Processing
Achim J. Lilienthal
AASS Learning Systems Lab, Dep. Teknik
Room T1209
Part 7: Image Segmentation
Course Book Chapter 10
Achim J. Lilienthal
Contents
1. Image Segmentation
2. Edge Detection
z Edge Model
z Edge Detectors
z Prewitt, Sobel, Laplacian of a Gaussian
z Canny Edge Detector
z Edge Detection in Colour Images
3. Edge Linking and Boundary Detection
4. Thresholding
Achim J. Lilienthal
Contents
5. Colour Segmentation
6. Region-Based Segmentation
7. Watershed Segmentation
8. Motion-Based Segmentation
Achim J. Lilienthal
Image Segmentation
Contents
Achim J. Lilienthal
Image Segmentation
z Segmentation
y full segmentation
x individual objects are separated from the background
and given individual ID numbers (labels)
y partial segmentation
x the amount of data is reduced (usually by separating objects
from background) to speed up the further processing
! segmentation is often the most difficult problem
to solve in the process; there is no universal solution!
! the problem can be made much easier if solved
in cooperation with the constructor of the imaging system
(choice of sensors, illumination, background etc.)
1
Achim J. Lilienthal
Image Segmentation
z Approaches to Segmentation
y edge-based
x search for edges in the image
x edges can be linked to obtain borders between regions
y region-based
x search for consistent regions
x thresholding, classification, region growing/splitting & merging, …
y motion-based
x separate moving foreground objects from background model
z Common Idea
y search for discontinuities and/or similarities in the image
1
Achim J. Lilienthal
Edge Detection
Contents
Achim J. Lilienthal
Edge Detection
z Discontinuities
y points, lines, edges
y edge detection is the most common approach
used for image segmentation
z Edge Detection
2
edge detection
Achim J. Lilienthal
Edge Detection
z Edge Detection
y edge is a "local" concept
y should ideally correspond
to a region boundary
("global" concept)
y ideally pixels at an
orthogonal step transition
z Edge Model
y strong change of intensity (colour)
= steep regions in a relief map (3D)
2
Achim J. Lilienthal
Edge Detection
z Edge Model
y magnitude of the
first derivative to detect
the presence of an edge
x edge point if 1st derivative
is greater than a threshold
y second derivative shows
two peaks
x connection of the
peaks crosses near
the edge midpoint
x edge = zero crossing
of the 2nd derivative
2
zero-crossing
Achim J. Lilienthal
Edge Detection
z Edge Detection – Morphology
y simple edge detector for binary images
(top-hat transformation)
2
fbfh )(
Achim J. Lilienthal
Edge Detection
z Edge Detection in Grey Level Images
y remove noise
x necessary because the first and
the second derivative are very
sensitive to image noise
2
Achim J. Lilienthal
Edge Detection
z Edge Detection in Grey Level Images
y remove noise
x mean, Gaussian, median filter, ...
x dilemma
• large filter
removes noise but also edges
• small filter
keeps edges but not
effcient in removing noise
y edge detection/enhancement
x 1st or 2nd derivative, apply threshold
y edge localisation
2
Achim J. Lilienthal
Edge Detection
z Edge Detectors
y Prewitt and Sobel
x 2 masks approximate | Gx | and | Gy | in
y Prewitt
2
yx GGy
f
x
ff
10-1
10-1
10-1
-1-1-1
000
111
Achim J. Lilienthal
Edge Detection
z Edge Detectors
y Prewitt and Sobel
x 2 masks approximate | Gx | and | Gy | in
y Sobel
2
yx GGy
f
x
ff
10-1
20-2
10-1
-1-2-1
000
121
Achim J. Lilienthal
Edge Detection
z Sobel Edge Detector
2
Sobel
Sobel
Achim J. Lilienthal
Edge Detection
z Edge Detectors
y Laplacian
x approximation to
2
2
2
2
22
y
f
x
f
010
1-41
010111
1-81
111
Achim J. Lilienthal
Edge Detection
z Edge Detectors
y Laplacian of a Gaussian (LoG)
x Gaussian used for smoothing
x combined with the Laplacian 2nd derivative of the Gaussian
x "mexican hat" function
2
2
2
24
222
r
er
rh
Achim J. Lilienthal
Edge Detection
z Laplacian of a Gaussian (LoG) Edge Detector
2
LoG
Achim J. Lilienthal
Edge Detection
z Laplacian of a Gaussian (LoG) Edge Detector
y LoG implemented as two different masks
x masks are typically smaller
y plain determination of the zero-crossings
2
LoG zero-crossingsbinary imageoriginal image
Achim J. Lilienthal
Edge Detection
z Laplacian of a Gaussian (LoG) Edge Detector
y Gauss filter width:
x 5x5 pixels
x 9x9 pixels
x 12x12 pixels
2
Achim J. Lilienthal
Edge Detection
z Canny Edge Detector – Gradient Estimation
1. noise reduction
y 2D Gaussian kernel used for smoothing
2. edge detection/enhancement
y 2-D first derivative operator
y for example: Sobel operator
y edges in the image cause
ridges in the gradient image
2
yx GGy
f
x
ff
Achim J. Lilienthal
Edge Detection
z Edge Detectors
y Prewitt and Sobel
x 2 masks approximate | Gx | and | Gy | in
y Sobel
2
yx GGy
f
x
ff
10-1
20-2
10-1
1-2-1
000
121
Achim J. Lilienthal
Edge Detection
z Canny Edge Detector – Gradient Estimation
1. noise reduction
y 2D Gaussian kernel used for smoothing
2. edge detection/enhancement
y 2-D first derivative operator
y for example: Sobel operator
y edges in the image cause
ridges in the gradient image
3. determine the intensity gradient
y can be calculated from Gx and Gy
y alternatively using more filter masks to
detect horizontal, vertical, diagonal edges, ...
2
yx GGy
f
x
ff
x
y
G
G1tan
Achim J. Lilienthal
Edge Detection
z Canny Edge Detector – Non-Maximum Suppression
4. non-maximum suppression (thinning of edges)
y delete all but the local maximum of edge intensity
y implementation:
• identify the 4 closest pixels perpendicular
to the edge direction = A, B, C, D
• estimate gradient next to the origin O
along the gradient direction by
linear interpolation between A and B P,
linear interpolation between C and D Q
• set O to zero if the magnitude of the
gradient is not higher than the magnitude
of the gradient at P and Q (non-maximum)
2
A B
C D
P
Q
Achim J. Lilienthal
Edge Detection
z Canny Edge Detector – Hysteresis Thresholding
5. tracing edges through the image
y higher intensity gradients are more likely to be edges
y pixels with a low |gradient| connected to pixels with high |gradient|
are likely to be edges (trace faint sections of edges)
y implementation: thresholding with hysteresis
• two thresholds Thigh and Tlow
• set all pixels below Tlow to zero
• mark edges above Thigh
• trace through the image (using the gradient information)
following the edges applying the lower threshold Tlow
• discard short connected edge sections
y allows to trace faint sections of lines if there is a starting point
2
Achim J. Lilienthal
Edge Detection
z Canny Edge Detector – Parameter Selection
y size of the Gaussian filter
x smaller filter less blurring, allows for detection of smaller edges
x larger filter for detection of larger, smoother edges
y hysteresis thresholds
x Thigh high enough so that most noise edges are eliminated
x Tlow high enough so that pixels > Tlow are still meaningful edge pixels
• express Thigh and Tlow as absolute magnitudes
• express Thigh and Tlow as fractions of the maximum gradient
magnitude in the image
2
Achim J. Lilienthal
Edge Detection
z Canny Edge Detector – Parameter Selection
2
Gauss 5x5,
Thigh = 255,
Tlow = 1
Gauss 5x5,
Thigh = 255,
Tlow = 220
Gauss 5x5,
Thigh = 128,
Tlow = 1
Gauss 9x9,
Thigh = 128,
Tlow = 1
Achim J. Lilienthal
Edge Detection
z Canny Edge Detector – Parameter Selection
2
= 1, Thigh = 0.5, Tlow = 0.05
no non-maximum suppressionfrom http://matlabserver.cs.rug.nl
Achim J. Lilienthal
Edge Detection
z Canny Edge Detector – Parameter Selection
2
= 5, Thigh = 0.5, Tlow = 0.05
no non-maximum suppressionfrom http://matlabserver.cs.rug.nl
Achim J. Lilienthal
Edge Detection
z Canny Edge Detector – Parameter Selection
2
= 1, Thigh = 0.5, Tlow = 0.05,
non-maximum suppressionfrom http://matlabserver.cs.rug.nl
Achim J. Lilienthal
Edge Detection
z Canny Edge Detector – Parameter Selection
2
= 5, Thigh = 0.5, Tlow = 0.05,
non-maximum suppressionfrom http://matlabserver.cs.rug.nl
Achim J. Lilienthal
Edge Detection
z Canny Edge Detector – Parameter Selection
2
= 20, Thigh = 0.5, Tlow = 0.05,
non-maximum suppressionfrom http://matlabserver.cs.rug.nl
Achim J. Lilienthal
Edge Detection
z Canny Edge Detector – Parameter Selection
2
= 5, Thigh = 0.3, Tlow = 0.05,
non-maximum suppressionfrom http://matlabserver.cs.rug.nl
Achim J. Lilienthal
Edge Detection
z Canny Edge Detector – Parameter Selection
2
= 2, Thigh = 0.2, Tlow = 0.1,
non-maximum suppressionfrom http://matlabserver.cs.rug.nl
Achim J. Lilienthal
Edge Detection
z Canny Edge Detector – Examples
2
Gauss 5x5,
Thigh = 200,
Tlow = 1
Gauss 7x7,
Thigh = 200,
Tlow = 1
from http://www.cee.hw.ac.uk/hipr/html/canny.html