Computer Vision
Edge Detection
Origin of Edges
surface normal discontinuity
depth discontinuity
surface color discontinuity
illumination discontinuity
• Edges are caused by a variety of factors
2
3
Profiles of image intensity edges
4
5
6
7
8
9
10
Image gradient
• The gradient of an image f(x,y):
• The gradient points in the direction of most rapid change in intensity
T
h
e
p
i
c
t
u
r
e
c
a
n
'
t
b
e
d
i
s
p
l
a
y
e
d
.
n The gradient direction is given by:
n The edge strength is given by the gradient magnitude
11
The discrete gradient
• How can we differentiate a digital image f[x,y]?
• Option 1: reconstruct a continuous image, then take gradient
• Option 2: take discrete derivative (finite difference)
12
13
14
15
16
17
18
Some Gradient Maks
Possible filters to find gradients along vertical and horizontal directions:
Averaging provides noise
suppression
This gives more importance to the
center point.
19
Image gradient
• An example using Prewitt filter
20
Effect of noise
• Consider a single row or column of the image
• Plotting intensity as a function of position gives a signal
21
22
Solution: Smooth first
Look for peaks in 23
Effect of Smoothing
Note: Sometimes, sum of absolute values of gradients is used as an
indicator of edge strength. 24
Effect of Smoothing
Note: Sometimes, sum of absolute values of gradients is used as an
indicator of edge strength. 25
Smoothing with Gaussian filter
26
Derivative of Gaussian
• This saves us one operation:
27
Derivative of Gaussian
• Apply these filters to get horizontal and vertical gradient images.
• Calculate the gradient magnitude image and look for the peaks in
gradient magnitude image.
28
An example
Zero Crossings for Edge Detection
• Consider
Laplacian of Gaussian
operator
Zero-crossings of bottom graph 30
2D edge detection filters
Laplacian of Gaussian
Gaussian derivative of Gaussian
• The Laplacian operator:
31
Edge Detection
n The Laplacian of an image f(x,y) is a second-order
derivative defined as
¶2 f ¶2 f
Ñ f = 2 + 2
2
¶x ¶y
Digital approximations for Laplacian operator:
32
Edge Detection
One simple method to find zero-
crossings is black/white thresholding:
1. Set all positive values to white
2. Set all negative values to black
3. Determine the black/white
transitions.
33
Edge Detection
n The Laplacian of a Gaussian (LoG) filter
Digital approximations of (inverted) LoG:
34
Example
original 35
Example
LoG 36
Difference of Gaussian (DoG) operator
• Laplacian of Gaussian can be approximated by the difference
between two Gaussians.
37
Example
(a) (b) (b)-(a)
38
The Canny edge detector
n original image
39
The Canny edge detector
n norm of the gradient
40
The Canny edge detector
n thresholding
41
The Canny edge detector
n thinning
(non-maximum suppression) 42
Non-maximum suppression
• Check if pixel is local maximum along gradient direction
• requires checking interpolated pixels p and r
43
Non-maximum suppression
44
Edge linking: Hysteresis thresholding
• The threshold used to find starting point may be large in following
the edge.
• This leads to broken edge curves.
• The trick is to use two thresholds: A large one when starting an edge
chain, a small one while following it.
45
Edge linking: Hysteresis thresholding
46