An Introduction to
Computer Vision
Lecture 08 Edge Detection
Edge and line detection Why detect edges? • Edges (lines) convey meaning. • Useful when trying to
– reconstruct scenes, – segment objects, – determine boundaries, – identify features, …
An Introduction to
2
Computer Vision
Detecting Edge Features 1st order edge detection methods:
1. Determine gradient of image Perform nonmaximal suppression Threshold
An Introduction to
3
Computer Vision
2nd order edge detection methods:
– Locate zero crossings in 2nd derivative using Laplacian. 3. 2.
.
We will look at two of the important ones: A first order method: – Canny: widely regarded as the best edge detector.Edge Detection Methods
An Introduction to
4
Computer Vision
There are many different edge detection algorithms.
.
A second order method.
– MarrHildreth: a 2nd order edge detector.
.Canny Edge Detector
An Introduction to
5
Computer Vision
Steps:
1. Convolve image with Gaussian Compute gradient ∇I Perform nonmaximal suppression on ∇I in direction ∠∇I. Hysteresis thresholding using ∇I to measure edge strength. 3. 4. 2.
To overcome this problem the image is first convolved with a smooth low pass kernel such as a Gaussian.Smoothing
An Introduction to
6
Computer Vision
Typically images have noise that shows up strongly in the differentiation process that is used for 1st order edge detection.
image Gaussian kernel filtered image
.
Compute Gradient
An Introduction to
7
Computer Vision
.
Compute Gradient
An Introduction to
8
Computer Vision
Subsample the distributions at pixel centre points to obtain an explicit kernel K. (Is the kernel separable?)
.
3. Determine gradient of image Perform nonmaximal suppression Threshold
An Introduction to
9
Computer Vision
Nonmaximal suppression is applied based on the algorithm covered in the previous lecture. 2.NonMaximal suppression 1st order edge detection methods:
1.
.
• Threshold at klow to find weak edges.
Klow Classified as not edges Weak edges
Khigh Strong edges
Edge pixel intensity
.
An Introduction to
10
Computer Vision
• Accept all weak edges that are “connected” to strong edges.
Remember the definition of connectedness for binary objects? Normally use 8connected for edge connection.Hysteresis Thresholding • Two thresholds khigh and klow • Threshold at khigh to find strong edges.
Canny Edge Detector
An Introduction to
11
Computer Vision
Original image
Magnitude of gradient
Magnitude of gradient after nonmaximal suppression
.
Canny Edge Detector
An Introduction to
12
Computer Vision
weak edges
strong edges
strong edges & connected weak edges
.
Original image
An Introduction to
13
Computer Vision
.
Output of Canny Edge Detector
An Introduction to
14
Computer Vision
.
3.MarrHildreth algorithm
An Introduction to
15
Computer Vision
The MarrHildreth algorithm uses second order derivative information. Convolve image with Gaussian Compute the Laplacian ∇2 IG Compute the zero crossings of ∇2 IG
. 2. Steps:
1.
2nd Derivative
An Introduction to
16
Computer Vision
• You know the 2nd derivative is the derivative of the derivative. • For an image I
∂ I
2
∂x
∂y
2
=∂
=∂
(∂I ∂x) ∂x
⎛ ∂I ⎞ ⎜ ∂y ⎟ ∂y ⎝ ⎠
∂ I
2
2
.
.
2nd derivative kernel.2nd Derivative
An Introduction to
17
Computer Vision
The 2nd derivative can be determined from the 1st derivative or can be calculated directly from the image using a 2nd derivative kernel.
an exception is the Laplacian.2nd Order Derivative Operators
An Introduction to
18
Computer Vision
• In practice higher order derivatives are seldom used.
∂ I ∂ I ∇ I= 2 + 2 ∂x ∂y
2 2 2
Requires two separate filters to be run over image data
. • The Laplacian is the sum of the 2nd derivatives.
the ∇2 G operator will be implemented as a linear convolution direction on an image I
∂G ∂G ∇ G ∗I = 2 ∗I + 2 ∗I ∂x ∂y
2 2 2
.Laplacian of Gaussian
An Introduction to
19
Computer Vision
•
The LoG (Laplacian of Gaussian) operator measures the strength of the 2nd derivative in both directions after the image has been smoothed by a Gaussian G
∇2(G * I) = ∇2G * I
• ∇2G is the LoG operator.
Similarly to the derivative of a smoothed image.
Laplacian of Gaussian
An Introduction to
20
Computer Vision
Derivatives and Laplacian of a 2D Gaussian G. intensity axis (a) not to scale G
K ∂G
y
a
∂x
y x
x a
a
K ∂G
∂y
y
x x
y
K ∇ 2G
∂ 2G ∂ 2G = 2 + 2 ∂x ∂y
Not separable
.
Separable kernel
• This is the DoG (Difference of Gaussians) operator – also called the Mexican Hat Operator.
.Difference of Gaussians
An Introduction to
21
Computer Vision

=
• LoG can be approximated by a difference of 2 Gaussians.
MarrHildreth Edge Detector
An Introduction to
22
Computer Vision
• The MarrHildreth operator locates edges at the zero crossings in the LoG of the image ∇2G * I • This is looking for zeros in the 2nd derivative
.
MarrHildreth Edge Detector
An Introduction to
23
Computer Vision
• Advantages:
– Edges found in all orientations simultaneously – Zero crossings easy to find: simply look for a sign change – Zero crossings always define closed curves. this is handy for segmenting objects in an image
• Disadvantages:
– 2nd derivative is very sensitive to noise – Not all edges form closed contours
.
Original image
An Introduction to
24
Computer Vision
.
Output of MarrHildreth
An Introduction to
25
Computer Vision
.
Output of Canny Edge Detector
An Introduction to
26
Computer Vision
.