0% found this document useful (0 votes)
26 views

Lecture-4-Edge-detection-Part-I (2)

Uploaded by

Kush Aggarwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Lecture-4-Edge-detection-Part-I (2)

Uploaded by

Kush Aggarwal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

CAP5415

Computer Vision
Yogesh S Rawat
[email protected]
HEC-241

9/14/2021 Lecture 3 –Edge Detection 1


Edge Detection

Lecture 4

9/14/2021 Lecture 3 –Edge Detection 2


Outline
• What is edge detection?
• Why we need edge detection?
• Challenges
• Noise
• How to detect edges?
• Prewit
• Sobel
• Marr-Hildreth
• Canny

9/14/2021 Lecture 3 –Edge Detection 3


Edge Detection
• Identify sudden changes in an image
• Semantic and shape information
• Marks the border of an object
• More compact than pixels

9/14/2021 Lecture 3 –Edge Detection 4


Origins of Edges
• Edges are caused by a variety of factors

surface normal discontinuity

depth discontinuity

surface color discontinuity

illumination discontinuity

9/14/2021 Lecture 3 –Edge Detection 5


Types of edges
• Edge models

9/14/2021 Lecture 3 –Edge Detection 6


Why edge detection?
• Extract useful information from images
• Recognizing objects
• Recover geometry

9/14/2021 Lecture 3 –Edge Detection 7


Closeup of edges

9/14/2021 Lecture 3 –Edge Detection 8


Source: D. Hoiem
Closeup of edges

9/14/2021 Lecture 3 –Edge Detection 9


Source: D. Hoiem
Closeup of edges

9/14/2021 Lecture 3 –Edge Detection 10


Source: D. Hoiem
Closeup of edges

9/14/2021 Lecture 3 –Edge Detection 11


Source: D. Hoiem
Characterizing edges
• An edge is a place of rapid change in the image intensity function

intensity function
image (along horizontal scanline) first derivative

edges correspond to
9/14/2021 Slide Credit: James Hays Lecture 3 –Edge Detection extrema of derivative 12
Intensity profile

Intensity
Intensity derivative

9/14/2021 Lecture 3 –Edge Detection 13


Source: D. Hoiem
With a little Gaussian noise

Intensity derivative x

9/14/2021 Lecture 3 –Edge Detection 14


Source: D. Hoiem
Effects of Noise
• Consider a single row or column of the image
• Plotting intensity as a function of position gives a signal

Where is the edge?

9/14/2021 Lecture 3 –Edge Detection 15


Credit to Seitz.
Effects of noise
• Difference filters respond strongly to noise
• Image noise results in pixels that look very different from their neighbors
• Generally, the larger the noise the stronger the response
• What can we do about it?

9/14/2021 Lecture 3 –Edge Detection 16


Source: D. Forsyth
Solution: smooth first
f

f*g

d
( f  g)
dx

d
To find edges, look for peaks in ( f  g)
dx
9/14/2021 Lecture 3 –Edge Detection 17
Source: S. Seitz
Derivative theorem of convolution
d d
• Convolution is differentiable: ( f  g) = f  g
dx dx
• This saves us one operation:

d
g
dx

d
f g
dx

9/14/2021 Lecture 3 –Edge Detection 18


Source: S. Seitz
Solution: Smoothing

1 pixel 3 pixels 7 pixels

• Smoothing removes noise, but blurs edge.

9/14/2021 Lecture 3 –Edge Detection 19


Evaluate Edge Detection
GT  RM TP
precision = =
RM RM
GT  RM TP
recall = =
GT GT Ground Truth (GT)
Results of Method (RM)
True Positives (TP)
True Negatives (TN)

False Negatives (FN)

False Positives (FP)


9/14/2021 Lecture 3 –Edge Detection 20
Design Criteria for Edge Detection
• Good detection: find all real edges, ignoring noise or other artifacts
• Good localization
• as close as possible to the true edges
• one point only for each true edge point

True Poor robustness Poor Too many


edge to noise localization responses
9/14/2021 Lecture 3 –Edge Detection 21
45 years of boundary detection
[Pre deep learning]

Source: Arbelaez, Maire, Fowlkes, and Malik. TPAMI 2011 (pdf)


Prewitt and Sobel Edge Detector
• Compute derivatives
• In x and y directions
• Find gradient magnitude
• Threshold gradient magnitude
Discrete derivative - revisit

df
= f ( x) − f ( x − 1) = f ( x) Backward difference
dx

df
= f ( x) − f ( x + 1) = f ( x) Forward difference
dx

df
= f ( x + 1) − f ( x − 1) = f ( x) Central difference
dx

9/14/2021 CAP5415 - Lecture 3 [Filtering] 24


Derivative Masks

Backward difference [-1 1]


Forward difference [1 -1]
Central difference [-1 0 1]

9/14/2021 CAP5415 - Lecture 3 [Filtering] 25


Image derivative
Given function f ( x, y )
 f ( x, y ) 
 x   f x 
Gradient vector f ( x, y ) =  f ( x, y )  =  
   fy 
 y 

Gradient magnitude f ( x, y) = f x2 + f y2

fx
Gradient direction  = tan −1

fy

9/14/2021 CAP5415 - Lecture 3 [Filtering] 26


Example

a. Original image
b. Laplacian operator
c. Horizontal derivative
d. Vertical derivative

9/14/2021 CAP5415 - Lecture 3 [Filtering] 27


Prewitt Edge Detector
average derivative
image smoothing in x blurred filtering in x edges in x
1 1
1 1
  1 −1
and 1 0 − 1
1 1
1 0 − 1
 
1 0 − 1

average derivative
image smoothing in y blurred filtering in y edges in y

1 1 1 1 1 1 1
1 1 1  −1 0 0 0
  and    
− 1 − 1 − 1
Sobel Edge Detector
average derivative
image smoothing in x blurred filtering in x edges in x
1 1 
 2 2 1 −1
  and
1 1 1 0 − 1 
 2 0 − 2
 
1 0 − 1

average derivative
image smoothing in y blurred filtering in y edges in y

1 2 1 1 1 2 1
1 2 1  −1 0 0 0 
  and   
− 1 − 2 − 1
Sobel Edge Detector

1 0 − 1 
 2 0 − 2 d
  I
1 0 − 1 dx
*
Threshold Edges
Image I d  d 
2

 I  +  I 
2

 dx   dy 

1 1 d
* 2 I
0 0 0  dy
 
− 1 − 2 − 1
Sobel Edge Detector

d
I
dx

d
I
dy
Sobel Edge Detector

2
d  d 
2

 =  I  +  I 
 dx   dy 

  Threshold = 100
Sobel vs Prewitt

Source: Arbelaez, Maire, Fowlkes, and Malik. TPAMI 2011 (pdf)


Questions?

Sources for this lecture include materials from works by Mubarak Shah,
Abhijit Mahalanobis, and D. Lowe
Other sources from James Hays, Lana Lazebnik, Steve Seitz, David Forsyth, David Lowe, Fei-Fei Li, and Derek Hoiem

9/14/2021 Lecture 3 –Edge Detection 34

You might also like