0% found this document useful (0 votes)
14 views35 pages

11 Edge Detection Combined

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)
14 views35 pages

11 Edge Detection Combined

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/ 35

Edge detection

 Gradient-based edge operators


 Prewitt
 Sobel
 Roberts
 Laplacian zero-crossings
 Canny edge detector
 Hough transform for detection of straight lines
 Circle Hough Transform

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 1
Gradient-based edge detection
 Idea (continous-space): local gradient magnitude indicates edge strength

 Digital image:
use finite differences
to approximate
derivatives

 Edge templates

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 2
Practical edge detectors
 Edges can have any orientation
 Typical edge detection scheme uses K=2 edge templates
 Some use K>2

e1  x, y 
Combination,
e.g., edge
s [x, y ] e2  x, y  ∑ ek  x, y 
2
magnitude
k
M  x, y 
or
Max k ek  x, y 

eK  x, y  α  x, y 
(edge orientation)

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 3
Gradient filters (K=2)

 0 0 0   0 −1 0   [0 ] 1   [1] 0 
 −1
Central
 [0 ] 1   0
 [0 ] 0  Roberts    
Difference
 0  −1 0   0 −1 
0 0   0 1 0 

 −1 0 1   −1 −1 −1 
Prewitt  −1 [0 ] 1   0
 [0 ] 0 

 −1 0 1   1 1 1 

 −1 0 1   −1 −2 −1 
Sobel  −2 [0 ] 2   0
 [0 ] 0 

 −1 0 1   1 2 1 

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 4
Kirsch operator (K=8)
 +5 +5 +5   −3 +5 +5   −3 −3 +5   −3 −3 −3 
 −3 0 −3   −3 0 +5   −3 0 +5   −3 0 +5 
Kirsch  []  []  []  [] 
 −3 −3 −3   −3 −3 −3   −3 −3 +5   −3 +5 +5 

 −3 −3 −3   −3 −3 −3   +5 −3 −3   +5 +5 −3 
 −3 0 −3   +5 0 −3   +5
 []  []  [0 ] −3   +5 [0 ] −3 
 +5 +5 +5   +5 +5 −3   +5 −3 −3   −3 −3 −3 

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 5
Prewitt operator example

Magnitude of
image filtered with
 −1 0 1 
 −1
 [0 ] 1 
 −1 0 1 
(log display)

Magnitude of
image filtered with
Original
1024x710  −1 −1 −1 
 0 
 [0 ] 0 
 1 1 1 
(log display)

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 6
Prewitt operator example (cont.)

Sum of squared threshold = 900 threshold = 4500 threshold = 7200


horizontal and
vertical gradients
(log display)

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 7
Sobel operator example

Sum of squared threshold = 1600 threshold = 8000 threshold = 12800


horizontal and
vertical gradients
(log display)

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 8
Roberts operator example

Magnitude of
image filtered with

Magnitude of
Original image filtered with
1024x710

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 9
Roberts operator example (cont.)

Sum of squared threshold = 100 threshold = 500 threshold = 800


diagonal gradients
(log display)

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 10
Edge orientation
Central Gradient scatter plot
Difference
 0 0 0 
 −1
[0 ] 1 

y-component

 0 0 0 
 0 −1 0 
 0
 [0 ] 0 
 0 1 0 

x-component

Roberts
 [0 ] 1 
 

y-component
 −1 0 
 [1] 0 
 
 0 −1 

x-component

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 11
Edge orientation
Prewitt Gradient scatter plot
 −1 0 1 
 −1 1 
 [0 ]

y-component
 −1 0 1 
 −1 −1 −1 
 0
 [0 ] 0 
 1 1 1 

x-component

Sobel
 −1 0 1 
 −2
 [0 ] 2 

y-component
 −1 0 1 
 −1 −2 −1 
 0
 [0 ] 0 
 1 2 1 

x-component

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 12
Edge orientation
Gradient scatter plot

y-component
5x5 “consistent”
gradient operator
[Ando, 2000]

x-component

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 13
Gradient consistency problem

Calculate this value


using gradient field

Same result,
regardless of path?

Known
gray
value

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 14
Laplacian operator
 Detect edges by considering second derivative

 Isotropic (rotationally invariant) operator


 Zero-crossings mark edge location
Detect
zero crossing

Edge profile f(x) f’(x) f”(x)

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 16
Approximations of Laplacian operator by 3x3 filter
 0 1 0 
 1 1 1 
   
1  −4  1  1  −8
   1 
   
 0 1 0 
 1 1 1 

8 15

6
10
4
|H|

|H|
5
2

0 0
2 2
0 2 0 2
0 0
-2 -2 -2 -2
ω ω ωy ωx
y x

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 17
Zero crossings of Laplacian

 Sensitive to very fine detail and noise  blur image first


 Responds equally to strong and weak edges
 suppress zero-crossings with low gradient magnitude

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 18
Laplacian of Gaussian
 Filtering of image with Gaussian and Laplacian operators can be combined into
convolution with Laplacian of Gaussian (LoG) operator
σ= 2
0.02
x2 + y2
1  x +y  − 2 2
LoG (x, y )= − 4 
1− 2 
e 2σ 2 0

πσ  2σ  -0.02

-0.04

-0.06

-0.08

-0.1
4
2 4
0 2
0
-2
-2
Y -4 -4 X

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 19
Discrete approximation of Laplacian of Gaussian
σ= 2
0 0 1 2 2 2 1 0 0

0 2 3 5 5 5 3 2 0 10 200
1 3 5 3 0 3 5 3 1
0 150
2 5 3 -12 -23 -12 3 5 2
-10
100

|H|
2 5 0 -23 -40 -23 0 5 2
-20
2 5 3 -12 -23 -12 3 5 2
50
1 3 5 3 0 3 5 3 1 -30

0 2 3 5 5 5 3 2 0 -40 0
4
0 0 1 2 2 2 1 0 0 2 4 2
0 2 0 2
0 0
-2 -2
-2 -2
Y -4 -4 X ωy ωx

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 20
Zero crossings of LoG

σ= 2 σ =2 2 σ =4 2 σ =8 2

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 21
Zero crossings of LoG – gradient-based threshold

σ= 2 σ =2 2 σ =4 2 σ =8 2

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 22
Canny edge detector
1. Smooth image with a Gaussian filter
2. Approximate gradient magnitude and angle (use Sobel, Prewitt . . .)

∂f ∂f 
2 2
∂f  ∂f 
M  x, y  ≈   +   α  x, y  ≈ tan 
−1

 ∂x   ∂ y   ∂y ∂x 

3. Apply nonmaxima suppression to gradient magnitude


4. Double thresholding to detect strong and weak edge pixels
5. Reject weak edge pixels not connected with strong edge pixels

[Canny, IEEE Trans. PAMI, 1986]

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 23
Canny nonmaxima suppression
 Quantize edge normal to one of four directions:
horizontal, -45o, vertical, +45o
 If M[x,y] is smaller than either of its neighbors in edge normal direction
 suppress; else keep.

[Canny, IEEE Trans. PAMI, 1986]

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 24
Canny thresholding and suppression of weak edges
 Double-thresholding of gradient magnitude

 Typical setting:
 Region labeling of edge pixels
 Reject regions without strong edge pixels

[Canny, IEEE Trans. PAMI, 1986]

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 25
Canny edge detector

σ= 2 σ =2 2 σ =4 2

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 26
Hough transform
 Problem: fit a straight line (or curve) to a set of edge pixels
 Hough transform (1962): generalized template matching technique
 Consider detection of straight lines y = mx + c

x m

edge pixel

y
c
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 28
Hough transform (cont.)
 Subdivide (m,c) plane into discrete “bins,” initialize all bin counts by 0
 Draw a line in the parameter space [m,c] for each edge pixel [x,y] and increment
bin counts along line.
 Detect peak(s) in [m,c] plane
x m

detect peak

y
c
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 29
Hough transform (cont.)
 Alternative parameterization avoids infinite-slope problem
x ρ
θ
edge pixel
ρ

−−ππ π
x cosθ + y sin θ = ρ 2 2 θ
y

 Similar to Radon transform

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 30
Hough transform example

100

200

300

400

500

600

700

800
200 400 600 800

Original image

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 31
Hough transform example

100

200

300

400

500

600

700

800
200 400 600 800

Original image

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 32
Hough transform example

100

200

300

400

500

600

700

800
200 400 600 800

Original image

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 33
Hough transform example
-4000 1500

-2000
ρ 1000
0

500
2000
De-skewed
Paper Paper
(3264x2448)

4000 0
-50 0 50
θ
-81.8 deg

-81.8 deg

Global thresholding

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 34
Circle Hough Transform
 Find circles of fixed radius r
x x0
Circle center

edge pixel

y
y0
 Equivalent to convolution (template matching) with a circle

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 35
Circle Hough Transform for unknown radius
 3-d Hough transform for parameters (x0 , y0 ,r )
 2-d Hough transform aided by edge orientation  “spokes” in parameter space

x x0

Circle center

edge pixel

y
y0

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 36
Example: circle detection by Hough transform
Prewitt edge detection Detected circles
Original
coins image

Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Edge Detection 37

You might also like