You are on page 1of 26

An Introduction to

Computer Vision

Lecture 08
Edge Detection
Edge and line detection An Introduction to
Computer Vision
2

Why detect edges?


• Edges (lines) convey meaning.
• Useful when trying to
– reconstruct scenes,
– segment objects,
– determine boundaries,
– identify features, …
Detecting Edge Features An Introduction to
Computer Vision
3

1st order edge detection methods:


1. Determine gradient of image
2. Perform non-maximal suppression
3. Threshold

2nd order edge detection methods:


– Locate zero crossings in 2nd derivative using Laplacian.
Edge Detection Methods An Introduction to
Computer Vision
4

There are many different edge detection algorithms. We


will look at two of the important ones:
A first order method:
– Canny: widely regarded as the best edge detector.
A second order method.
– Marr-Hildreth: a 2nd order edge detector.
Canny Edge Detector An Introduction to
Computer Vision
5

Steps:
1. Convolve image with Gaussian
2. Compute gradient ∇I
3. Perform non-maximal suppression on ||∇I|| in direction ∠∇I.
4. Hysteresis thresholding using ||∇I|| to measure edge strength.
Smoothing An Introduction to
Computer Vision
6

Typically images have noise that shows up strongly in the


differentiation process that is used for 1st order edge detection.

To overcome this problem the


image is first convolved with
a smooth low pass kernel
such as a Gaussian.

image
Gaussian kernel
filtered image
Compute Gradient An Introduction to
Computer Vision
7
Compute Gradient An Introduction to
Computer Vision
8

Sub-sample the distributions at pixel centre points to


obtain an explicit kernel K. (Is the kernel separable?)
Non-Maximal suppression An Introduction to
Computer Vision
9

1st order edge detection methods:


1. Determine gradient of image
2. Perform non-maximal suppression
3. Threshold

Non-maximal suppression is applied based on the algorithm


covered in the previous lecture.
Hysteresis Thresholding An Introduction to
Computer Vision
10

• Two thresholds khigh and klow


• Threshold at khigh to find strong edges.
• Threshold at klow to find weak edges.
• Accept all weak edges that are “connected” to strong edges.

Remember the definition of connectedness for binary


objects? Normally use 8-connected for edge connection.

Klow Khigh
Classified as not edges Weak edges Strong edges
Edge pixel intensity
Canny Edge Detector An Introduction to
Computer Vision
11

Original image Magnitude of gradient

Magnitude of gradient after


non-maximal suppression
Canny Edge Detector An Introduction to
Computer Vision
12

weak edges strong edges

strong edges &


connected weak edges
Original image An Introduction to
Computer Vision
13
14
Output of Canny Edge Detector An Introduction to
Computer Vision
Marr-Hildreth algorithm An Introduction to
Computer Vision
15

The Marr-Hildreth algorithm uses second order derivative


information.

Steps:
1. Convolve image with Gaussian
2. Compute the Laplacian ∇2 IG
3. Compute the zero crossings of ∇2 IG
2nd Derivative An Introduction to
Computer Vision
16

• You know the 2nd derivative is the derivative of the


derivative.
• For an image I

∂ I 2

∂x 2 =∂ (∂I )
∂x ∂x

∂ I 2
=∂ ⎛⎜ ∂I ⎞⎟
∂y 2
∂y ⎝ ∂y ⎠
2nd Derivative An Introduction to
Computer Vision
17

The 2nd derivative can be determined from the 1st derivative


or can be calculated directly from the image using a 2nd
derivative kernel.

2nd derivative kernel.


2nd Order Derivative Operators An Introduction to 18
Computer Vision

• In practice higher order derivatives are seldom used, an


exception is the Laplacian.
• The Laplacian is the sum of the 2nd derivatives,

∂ I ∂ I 2 2
∇ I= 2 + 2
2

∂x ∂y

Requires two separate filters to be run over image data


19
Laplacian of Gaussian An Introduction to
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, the ∇2 G operator will be
implemented as a linear convolution direction on an image I

∂G ∂G 2 2
∇ G ∗I = 2 ∗I + 2 ∗I
2

∂x ∂y
Laplacian of Gaussian An Introduction to
Computer Vision
20

Derivatives and Laplacian of a 2D Gaussian G,


intensity axis (a) not to scale

G
a
K ∂G y x
∂x a
K ∂G
y ∂y
x
a y x

y x

∂ 2G ∂ 2G
K ∇ 2G = 2 + 2
∂x ∂y
Not separable
Difference of Gaussians An Introduction to
Computer Vision
21

- =

• LoG can be approximated by a difference of 2 Gaussians.

Separable kernel

• This is the DoG (Difference of Gaussians) operator – also called the


Mexican Hat Operator.
Marr-Hildreth Edge Detector An Introduction to
Computer Vision
22

• The Marr-Hildreth operator locates edges at the zero crossings in the


LoG of the image ∇2G * I
• This is looking for zeros in the 2nd derivative
Marr-Hildreth Edge Detector An Introduction to
Computer Vision
23

• 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
Computer Vision
24
Output of Marr-Hildreth An Introduction to
Computer Vision
25
26
Output of Canny Edge Detector An Introduction to
Computer Vision

You might also like