Lecture 3 EdgeDetection
Lecture 3 EdgeDetection
Fall 2012
Lecture-3
What is an object?
How can we find it?
Image derivatives
f f x f x f f x n 1 f x
lim
x 0
x x
f x , y
Approximation f x , y f x , ym f x , y f x n , y m 1 f x n , y m
n 1 m n
x x y x
f x 1 1 1
fy
Convolution kernels 1
Alper Yilmaz, Mubarak Shah Fall 2012UCF
Image Derivatives
1
Image I I x I * 1 1 Iy I *
1
Increasing noise
(x2 y2
g ( x, y) e 2 2
Scale of Gaussian
As increases, more pixels are involved in average
As increases, image is more blurred
As increases, noise is more effectively
Alper Yilmaz, Mubaraksuppressed
Shah Fall 2012UCF
Gaussian Smoothing (Examples)
Gradient operators
Prewit
Sobel
Laplacian of Gaussian (Marr-Hildreth)
Gradient of Gaussian (Canny)
Compute derivatives
In x and y directions
Find gradient magnitude
Threshold gradient magnitude
1 0 1
2 0 2 d
I
1 0 1 dx
*
Image I d
2
d
2 Threshold Edges
I I
dx dy
1 1 d
* 2 I
0 0 0
dy
1 2 1
d
I
dx
d
I
dy
2
d
2
d
I I
dx dy
Threshold 100
Gaussian smoothing
x2 y2
smoothed image image
Gaussian filter g
1
e
2 2
S g * I 2
Find Laplacian
second order second order
is used for gradient (derivative)
derivative in x derivative in y
2 2 is used for Laplacian
2 S S S
x 2 y 2
Alper Yilmaz, Mubarak Shah Fall 2012, UCF
Marr Hildreth Edge Detector
x2 y2
1 x2 y2
2 g 2 e 2 2
2 3
2
Standard
deviation
x
-3 -2 -1 0 1 2 3
2 3
2
Y
0.0008 0.0066 0.0215 0.031 0.0215 0.0066 0.0008
0.0066 0.0438 0.0982 0.108 0.0982 0.0438 0.0066
0.0215 0.0982 0 -0.242 0 0.0982 0.0215
0.031 0.108 -0.242 -0.7979 -0.242 0.108 0.031 X
0.0215 0.0982 0 -0.242 0 0.0982 0.0215
0.0066 0.0438 0.0982 0.108 0.0982 0.0438 0.0066
0.0008 0.0066 0.0215 0.031 0.0215 0.0066 0.0008
2 S 2 g * I 2 g * I I * 2 g
Requires n2 multiplications
2 S I g xx ( x ) g ( y ) I g yy ( y ) g ( x )
Requires 4n multiplications
Image + 2 S
gyy(y) g(x)
Alper Yilmaz, Mubarak Shah Fall 2012, UCF
Example
I
I * 2 g Zero crossings of 2 S
6
Alper Yilmaz, Mubarak Shah Fall 2012, UCF
Algorithm
Compute LoG
2 g ( x, y )
Use 2D filter g ( x ), g xx ( x ), g ( y ), g yy ( y)
Use 4 1D filters
Find zero-crossings from each row
Find slope of zero-crossings
Apply threshold to slope and mark edges
Alper Yilmaz, Mubarak Shah Fall 2012, UCF
Quality of an Edge
Robust to noise
Localization
Too many or too less responses
Smoothing 1
x2 y2
g ( x, y) 2 2
e
S I g ( x, y) g ( x, y) I 2
Derivative
S g I g I g
gx
g gx g
gx gx I y
S I g I y
g
y y
Alper Yilmaz, Mubarak Shah Fall 2012, UCF
Canny Edge Detector
Derivative of Gaussian
g x ( x, y)
g y ( x, y)
g ( x, y)
I Sx
Sy
Sx
We wish to mark points along the curve where the magnitude is largest. We can do this by
looking for a maximum along a slice normal to the curve (non-maximum suppression).
These points should form a curve. There are then two algorithmic issues: at which point is
the maximum, and where is the next one?
Alper Yilmaz, Mubarak Shah Fall 2012, UCF
Canny Edge Detector
Non-Maximum Suppression
S S x2 S 2
y M
Connectedness
x x x
Gradient High
magnitude
low
regular
M M 25
Hysteresis
High 35
Low 15
Alper Yilmaz, Mubarak Shah Fall 2012, UCF
Suggested Reading