Professional Documents
Culture Documents
Lect 06
Lect 06
Spring 2008
New Mexico Tech
Fundamentals
► First-order derivative
f
f '( x) f ( x 1) f ( x)
x
► Second-order derivative
2 f
f ( x 1) f ( x 1) 2 f ( x)
x 2
12/26/20 4
12/26/20 5
Characteristics of First and Second Order
Derivatives
► First-order derivatives generally produce thicker edges in
image
► The Laplacian
2
f 2
f
f ( x, y ) 2 2
2
x y
f ( x 1, y ) f ( x 1, y ) f ( x, y 1) f ( x, y 1)
4 f ( x, y )
9
1 if | R( x, y ) | T R wk zk
g ( x, y ) k 1
0 otherwise
12/26/20 7
12/26/20 8
Line Detection
12/26/20 9
12/26/20 10
Detecting 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/26/20 11
12/26/20 12
Edge Detection
12/26/20 13
12/26/20 14
12/26/20 15
12/26/20 16
Basic Edge Detection by Using First-Order
Derivative
f
g x x
f grad ( f )
g y f
y
The magnitude of f
M ( x, y ) mag(f ) g x 2 g y 2
The direction of f
gx
( x, y ) tan
1
g y
The direction of the edge
12/26/20 17
- 90
Basic Edge Detection by Using First-Order
Derivative
f
g x x
Edge normal: f grad ( f )
g y f
y
Edge unit normal: f / mag(f )
2e 2 e 2
x y
x2 y 2 x2 y 2
x 2
1 y 1
2
4 2 e 2 2
4 2 e 2 2
x2 y 2
x y
2 2 2
12/26/20 e
2 2 29
4
12/26/20 30
Marr-Hildreth Algorithm
g ( x , y ) G ( x , y ) f ( x, y )
2
12/26/20 31
12/26/20 32
The Canny Edge Detector
► The Objective
12/26/20 33
The Canny Edge Detector: Algorithm (1)
12/26/20 34
The Canny Edge Detector: Algorithm(2)
12/26/20 35
The Canny Edge Detector: Algorithm(3)
Hysteresis thresholding:
g NH ( x, y ) g N ( x, y ) TH
g NL ( x, y ) g N ( x, y ) TL
and
g NL ( x, y ) g NL ( x, y ) g NH ( x, y )
12/26/20 38
The Canny Edge Detector: Algorithm(5)
Depending on the value of TH , the edges in g NH ( x, y )
typically have gaps. Longer edges are formed using
the following procedure:
(a). Locate the next unvisited edge pixel, p, in g NH ( x, y ).
(b). Mark as valid edge pixel all the weak pixels in g NL ( x, y )
that are connected to p using 8-connectivity.
(c). If all nonzero pixel in g NH ( x, y ) have been visited go to
step (d), esle return to (a).
(d). Set to zero all pixels in g NL ( x, y ) that were not marked as
12/26/20
valid edge pixels. 39
The Canny Edge Detection: Summary
12/26/20 40
12/26/20
TL 0.04; TH 0.10; 4 and a mask of size 25 25 41
12/26/20 42
TL 0.05; TH 0.15; 2 and a mask of size 13 13
12/26/20 43
12/26/20 44
Edge Linking and Boundary Detection
12/26/20 45
Local Processing
12/26/20 46
Local Processing
Let S xy denote the set of coordinates of a neighborhood
centered at point (x, y ) in an image. An edge pixel with
coordinate (s, t ) in S xy is similar in magnitude to the pixel
at (x, y ) if
M ( s , t ) M ( x, y ) E
1 if M ( x, y ) TM and ( x, y ) A TA
g ( x, y )
0 otherwise
TM : threshold A : specified angle direction
TA : a "band" of acceptable directions about A
12/26/20 48
Local Processing: Steps (2)
3. Scan the rows of g and fill (set to 1) all gaps (sets of 0s)
in each row that do not exceed a specified length, K.
12/26/20 49
12/26/20 50
Regional Processing
12/26/20 58
12/26/20 59
12/26/20 60
Edge-linking Based on the Hough Transform
12/26/20 61
12/26/20 62
12/26/20 63
Thresholding
1 if f ( x, y ) T (object point)
g ( x, y )
0 if f ( x, y ) T (background point)
T : global thresholding
Multiple thresholding
a if f ( x, y ) T2
g ( x, y ) b if T1 f ( x, y ) T2
c if f ( x, y ) T1
12/26/20 64
12/26/20 65
The Role of Noise in Image Thresholding
12/26/20 66
The Role of Illumination and Reflectance
12/26/20 67
Basic Global Thresholding
12/26/20 68
12/26/20 69
Optimum Global Thresholding Using Otsu’s
Method
► Principle: maximizing the between-class variance
=
P1 (1 P1 )
mG P1 m
2
=
P1 (1 P1 )
12/26/20 72
Optimum Global Thresholding Using Otsu’s
Method
1 if f ( x, y ) k *
g ( x, y )
0 if f ( x, y ) k *
B2
Separability measure 2
G
12/26/20 73
Otsu’s Algorithm: Summary
12/26/20 75
12/26/20 76
Using Image Smoothing to Improve Global Thresholding
12/26/20 77
Using Edges to Improve Global Thresholding
12/26/20 78
Using Edges to Improve Global Thresholding
12/26/20 79
12/26/20 80
12/26/20 81
Multiple Thresholds
k 1
1
where Pk pi and mk ip i
iCk Pk iCk
12/26/20 82
12/26/20 83
Variable Thresholding: Image Partitioning
12/26/20 84
12/26/20 85
12/26/20 86
Variable Thresholding Based on Local Image
Properties
Let xy and mxy denote the standard deviation and mean value
of the set of pixels contained in a neighborhood S xy , centered
at coordinates (x, y ) in an image. The local thresholds,
Txy a xy bmxy
If the background is nearly constant,
Txy a xy bm
1 if f ( x, y ) Txy
g ( x, y )
0 if f ( x, y) Txy
12/26/20 87
Variable Thresholding Based on Local Image
Properties
A modified thresholding
e.g .,
true if f ( x, y ) a xy AND f ( x, y ) bmxy
Q( xy , mxy )
false otherwise
12/26/20 88
a=30
b=1.5
mxy = mG
12/26/20 89
Variable Thresholding Using Moving Averages
12/26/20 90
Variable Thresholding Using Moving Averages
12/26/20 91
Variable Thresholding Using Moving Averages
1 if f ( x, y ) Txy
g ( x, y )
0 if f ( x, y ) Txy
Txy bmxy
12/26/20 92
N = 20
b=0.5
12/26/20 93
12/26/20 94
Region-Based Segmentation
► Region Growing
12/26/20 95
Region-Based Segmentation
12/26/20 96
Region Growing based on 8-connectivity
1. Find all connected components in S ( x, y) and erode each
connected components to one pixel; label all such pixels
found as 1. All other pixels in S are labeled 0.
2. Form an image f Q such that, at a pair of coordinates (x,y),
let fQ ( x, y ) 1 if the Q is satisfied otherwise f Q ( x, y ) 0.
3. Let g be an image formed by appending to each seed point
in S all the 1-value points in f Q that are 8-connected to that
seed point.
4. Label each connencted component in g with a different region
label. This is the segmented image obtained by region growing.
12/26/20 97
TRUE if the absolute difference of the intensities
Q between the seed and the pixel at (x,y) is T
FALSE otherwise
12/26/20 98
12/26/20 99
4-connectivity
12/26/20 100
8-connectivity
12/26/20 101
12/26/20 102
12/26/20 103
Region Splitting and Merging
12/26/20 107
Segmentation Using Morphological
Watersheds
► Three types of points in a topographic interpretation:
Points belonging to a regional minimum
Points at which a drop of water would fall to a single
minimum. (The catchment basin or watershed of that
minimum.)
Points at which a drop of water would be equally likely
to fall to more than one minimum. (The divide lines
or watershed lines.)
Watershed lines
12/26/20 108
Segmentation Using Morphological
Watersheds: Backgrounds
http://www.icaen.uiowa.edu/~dip/LECTURE/Segmentation3.html#watershed
12/26/20 109
Watershed Segmentation: Example
► The objective is to find watershed lines.
► The idea is simple:
Suppose that a hole is punched in each regional minimum and that
the entire topography is flooded from below by letting water rise
through the holes at a uniform rate.
When rising water in distinct catchment basins is about the merge, a
dam is built to prevent merging. These dam boundaries correspond
to the watershed lines.
12/26/20 110
12/26/20 111
12/26/20 112
Watershed Segmentation Algorithm
12/26/20 113
Watershed Segmentation: Examples
Watershed
algorithm is
often used on
the gradient
image instead
of the original
image.
12/26/20 114
Watershed Segmentation: Examples
12/26/20 116
Watershed Segmentation: Examples
12/26/20 117
Use of Motion in Segmentation
12/26/20 118
K-means Clustering
12/26/20 119
K-Means Clustering
12/26/20 120
K-Means Clustering
12/26/20 121
K-Means Clustering
12/26/20 122
K-Means Clustering
12/26/20 123
K-Means Clustering
12/26/20 124
K-Means Clustering
12/26/20 125
K-Means Clustering
12/26/20 126
K-Means Clustering
12/26/20 127
Clustering
► Example
D. Comaniciu and P.
Meer, Robust Analysis
of Feature Spaces:
Color Image
Segmentation, 1997.
12/26/20 128