14
1 CAP5415 Computer Vision Spring 2003 Khurram Hassan-Shafique Sobel Edge Detector Detecting Edges in Image Image I - - - 1 0 1 2 0 2 1 0 1 - - - 1 2 1 0 0 0 1 2 1 * * I dx d I dy d 2 2 + I dy d I dx d Threshold Edges

CAP5415 Computer Vision Spring 2003 Khurram Hassan …u.cs.biu.ac.il/~kapaho/IP/EdgeDetection.pdf · Khurram Hassan-Shafique Sobel Edge Detector Detecting Edges in Image Image I

Embed Size (px)

Citation preview

Page 1: CAP5415 Computer Vision Spring 2003 Khurram Hassan …u.cs.biu.ac.il/~kapaho/IP/EdgeDetection.pdf · Khurram Hassan-Shafique Sobel Edge Detector Detecting Edges in Image Image I

1

CAP5415 Computer VisionSpring 2003

Khurram Hassan-Shafique

� Sobel Edge Detector

Detecting Edges in Image

Image I

���

���

−−−

101

202

101

���

���

−−− 121

000

121

*

*

Idx

d

Idy

d

22

���

�+�

� Idy

dI

dx

d

ThresholdEdges

Page 2: CAP5415 Computer Vision Spring 2003 Khurram Hassan …u.cs.biu.ac.il/~kapaho/IP/EdgeDetection.pdf · Khurram Hassan-Shafique Sobel Edge Detector Detecting Edges in Image Image I

2

Sobel Edge Detector

Idx

d

Idy

d

I

Sobel Edge Detector

I

22

���

�+�

�=∆ Idy

dI

dx

d

100=≥∆ Threshold

Page 3: CAP5415 Computer Vision Spring 2003 Khurram Hassan …u.cs.biu.ac.il/~kapaho/IP/EdgeDetection.pdf · Khurram Hassan-Shafique Sobel Edge Detector Detecting Edges in Image Image I

3

Marr and Hildreth Edge Operator

� Smooth by Gaussian

� Use Laplacian to find derivatives

IGS *σ= 2

22

2

2

1 σσ σπ

yx

eG+−

=

Sy

Sx

S2

2

2

22

∂∂+

∂∂=∆

Marr and Hildreth Edge Operator

( ) IGIGS ** 222σσ ∆=∆=∆

2

22

22

22

3

2 22

1 σσ σσπ

yx

eyx

G+−

���

� +−−=∆

Page 4: CAP5415 Computer Vision Spring 2003 Khurram Hassan …u.cs.biu.ac.il/~kapaho/IP/EdgeDetection.pdf · Khurram Hassan-Shafique Sobel Edge Detector Detecting Edges in Image Image I

4

Marr and Hildreth Edge Operator2

22

22

22

3

2 22

1 σσ σσπ

yx

eyx

G+−

���

� +−−=∆

0.0008 0.0066 0.0215 0.031 0.0215 0.0066 0.00080.0066 0.0438 0.0982 0.108 0.0982 0.0438 0.00660.0215 0.0982 0 -0.242 0 0.0982 0.02150.031 0.108 -0.242 -0.7979 -0.242 0.108 0.031

0.0215 0.0982 0 -0.242 0 0.0982 0.02150.0066 0.0438 0.0982 0.108 0.0982 0.0438 0.00660.0008 0.0066 0.0215 0.031 0.0215 0.0066 0.0008

X

Y

Marr and Hildreth Edge Operator

Zero CrossingsDetection

I ImageσG2* ∆

IG *2σ∆ Edge Image

IG *2σ∆ Zero Crossings

Page 5: CAP5415 Computer Vision Spring 2003 Khurram Hassan …u.cs.biu.ac.il/~kapaho/IP/EdgeDetection.pdf · Khurram Hassan-Shafique Sobel Edge Detector Detecting Edges in Image Image I

5

1=σ

6=σ

3=σ

Quality of an Edge Detector

� Robustness to Noise

� Localization

� Too Many/Too less Responses

Poor robustness to noise Poor localization Too many responses

True Edge

Page 6: CAP5415 Computer Vision Spring 2003 Khurram Hassan …u.cs.biu.ac.il/~kapaho/IP/EdgeDetection.pdf · Khurram Hassan-Shafique Sobel Edge Detector Detecting Edges in Image Image I

6

Canny Edge Detector� Criterion 1: Good Detection: The optimal

detector must minimize the probability of false positives as well as false negatives.

� Criterion 2: Good Localization: The edges detected must be as close as possible to the true edges.

� Single Response Constraint: The detector must return one point only for each edge point.

Canny Edge Detector� Difficult to find closed-form solutions.

Page 7: CAP5415 Computer Vision Spring 2003 Khurram Hassan …u.cs.biu.ac.il/~kapaho/IP/EdgeDetection.pdf · Khurram Hassan-Shafique Sobel Edge Detector Detecting Edges in Image Image I

7

Canny Edge Detector� Convolution with derivative of Gaussian

� Non-maximum Suppression

� Hysteresis Thresholding

Canny Edge Detector� Smooth by Gaussian

� Compute x and y derivatives

� Compute gradient magnitude and orientation

IGS *σ= 2

22

2

2

1 σσ σπ

yx

eG+−

=

[ ]Tyx

T

SSSy

Sx

S =��

���

∂∂

∂∂=∆

22yx SSS +=∆

x

y

S

S1tan−=θ

Page 8: CAP5415 Computer Vision Spring 2003 Khurram Hassan …u.cs.biu.ac.il/~kapaho/IP/EdgeDetection.pdf · Khurram Hassan-Shafique Sobel Edge Detector Detecting Edges in Image Image I

8

Canny Edge Operator

( ) IGIGS ** σσ ∆=∆=∆T

y

G

x

GG �

���

∂∂

∂∂=∆ σσ

σ

T

Iy

GI

x

GS �

���

∂∂

∂∂=∆ ** σσ

Canny Edge Detector

xS

yS

I

Page 9: CAP5415 Computer Vision Spring 2003 Khurram Hassan …u.cs.biu.ac.il/~kapaho/IP/EdgeDetection.pdf · Khurram Hassan-Shafique Sobel Edge Detector Detecting Edges in Image Image I

9

Canny Edge Detector

I

22yx SSS +=∆

25=≥∆ ThresholdS

We wish to mark points along the curve where the magnitude is biggest.We can do this by looking for a maximum along a slice normal to the curve(non-maximum suppression). These points should form a curve. There arethen two algorithmic issues: at which point is the maximum, and where is thenext one?

Non-Maximum Suppression

Page 10: CAP5415 Computer Vision Spring 2003 Khurram Hassan …u.cs.biu.ac.il/~kapaho/IP/EdgeDetection.pdf · Khurram Hassan-Shafique Sobel Edge Detector Detecting Edges in Image Image I

10

Non-Maximum Suppression� Suppress the pixels in ‘Gradient Magnitude

Image’ which are not local maximum

( ) ( ) ( )edgean tonormaldirection thealong

in of neighbors theare and Sx,yy,xy,x ∆′′′′′′

( ) ( ) ( ) ( )( ) ( )

′′′′∆>∆

′′∆>∆∆=

otherwise0,,&

,, if,

, yxSyxS

yxSyxSyxS

yxM

( )yx ′′,

( )yx,

( )yx ′′′′ ,

Non-Maximum Suppression

0

12

3

41420tan41422- :3

41422tan :2

41422tan41420 :1

41420tan41420 :0

.�

.

.�

.�

.

.�

.-

−≤<≥

<<≤<

x

y

S

S�=tan

Page 11: CAP5415 Computer Vision Spring 2003 Khurram Hassan …u.cs.biu.ac.il/~kapaho/IP/EdgeDetection.pdf · Khurram Hassan-Shafique Sobel Edge Detector Detecting Edges in Image Image I

11

Non-Maximum Suppression

22yx SSS +=∆ M

25=≥ ThresholdM

Hysteresis Thresholding

Page 12: CAP5415 Computer Vision Spring 2003 Khurram Hassan …u.cs.biu.ac.il/~kapaho/IP/EdgeDetection.pdf · Khurram Hassan-Shafique Sobel Edge Detector Detecting Edges in Image Image I

12

Hysteresis Thresholding� If the gradient at a pixel is above ‘High’ , declare

it an ‘edge pixel’

� If the gradient at a pixel is below ‘Low’ , declare it a ‘non-edge-pixel’

� If the gradient at a pixel is between ‘Low’ and ‘High’ then declare it an ‘edge pixel’ if and only if it is connected to an ‘edge pixel’ directly or via pixels between ‘Low’ and ‘ High’

Hysteresis Thresholding

M 25=≥ ThresholdM

15

35

==

Low

High

Page 13: CAP5415 Computer Vision Spring 2003 Khurram Hassan …u.cs.biu.ac.il/~kapaho/IP/EdgeDetection.pdf · Khurram Hassan-Shafique Sobel Edge Detector Detecting Edges in Image Image I

13

Finding Connected Components� Scan the binary image left to right top to bottom

� If there is an unlabeled pixel p with a value of ‘1’� assign a new label to it

� Recursively check the neighbors of pixel p and assign the same label if they are unlabeled with a value of ‘1’ .

� Stop when all the pixels with value ‘1’ have been labeled.

Connectedness

Page 14: CAP5415 Computer Vision Spring 2003 Khurram Hassan …u.cs.biu.ac.il/~kapaho/IP/EdgeDetection.pdf · Khurram Hassan-Shafique Sobel Edge Detector Detecting Edges in Image Image I

14

Suggested Reading� Chapter 8, David A. Forsyth and Jean Ponce,

"Computer Vision: A Modern Approach“

� Chapter 4, Emanuele Trucco, Alessandro Verri, "Introductory Techniques for 3-D Computer Vision"

� Chapter 2, Mubarak Shah, “Fundamentals of Computer Vision”