Edge Detection

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 21

From MATLAB® and Simulink® to

Real Time with TI DSPs

Edge Detection

Content developed in partnership with


Tel-Aviv University

© 2007 Texas Instruments Inc,

0-1
Edge Detection?

“The ability to measure gray-level transitions in a


meaningful way.”

(R.C. Gonzales & R. E. Woods – Digital Image Processing, 2nd


Edition, Prentice-Hall, 2001)

© 2007 Texas Instruments Inc, Slide 2


Gray-Level Transition

Ideal Ramp

© 2007 Texas Instruments Inc, Slide 3


Detecting the Edge (1)
Original First Derivative

I x, y 
 TRSH  Edge Detected
I x, y  I  x , y  x
x

TRSH

x x
© 2007 Texas Instruments Inc, Slide 5
Detecting the Edge (2)

Original First Derivative

I x, y 
I x, y  I  x , y   TRSH  Edge Not Detected
x
x

TRSH

© 2007 Texas Instruments Inc, Slide 6


Gradient Operators
• The gradient of the image I(x,y) at location (x,y), is
the vector:
 I x, y 
Gx   x 
I      
G
 y 
I  x , y  
 y 

• The magnitude of the gradient: I   I  G 2


x  G y2 

• The direction of the gradient vector:  x, y   tan 1  Gx 


 
 Gy 

© 2007 Texas Instruments Inc, Slide 7


The Meaning of the Gradient
• It represents the direction of the strongest
variation in intensity
Vertical Horizontal Generic

Edge Strength: I  G x I  G y 
I  Gx2  G y2 
Edge Direction:  x, y   0  x, y   
 G 
 x, y   tan 1  y 
2  Gx 

The direction of the edge at location (x,y) is


perpendicular to the gradient vector at that point

© 2007 Texas Instruments Inc, Slide 8


Calculating the Gradient

For each pixel the


gradient is calculated,
based on a 3x3
neighborhood around
this pixel. z1 z2 z3
z4 z5 z6
z7 z8 z9

© 2007 Texas Instruments Inc, Slide 9


The Sobel Edge Detector

-1 -2 -1 -1 0 1

0 0 0 -2 0 2

1 2 1 -1 0 1

Gx  z7  2z8  z9   z1  2z2  z3  Gy  z3  2z6  z9   z1  2z4  z7 

© 2007 Texas Instruments Inc, Slide 10


The Prewitt Edge Detector

-1 -1 -1 -1 0 1

0 0 0 -1 0 1

1 1 1 -1 0 1

Gx  z7  z8  z9   z1  z2  z3  Gy  z3  z6  z9   z1  z4  z7 

© 2007 Texas Instruments Inc, Slide 11


The Roberts Edge Detector

0 0 0 0 0 0

0 -1 0 0 0 -1

0 0 1 0 1 0

Gx  z9  z5 Gy  z8  z6

The Roberts Edge Detector is in fact a 2x2 operator

© 2007 Texas Instruments Inc, Slide 12


The Canny Method
Two Possible Implementations:

1. The image is convolved with a Gaussian filter before gradient


evaluation

r2

hr   e 2 2

r x y
2 2

2. The image is convolved with the gradient of the Gaussian


Filter.

© 2007 Texas Instruments Inc, Slide 13


The Edge Detection Algorithm

• The gradient is calculated (using any of the four


methods described in the previous slides), for each
pixel in the picture.

• If the absolute value exceeds a threshold, the pixel


belongs to an edge.

• The Canny method uses two thresholds, and enables


the detection of two edge types: strong and weak
edge. If a pixel's magnitude in the gradient image,
exceeds the high threshold, then the pixel
corresponds to a strong edge. Any pixel connected to
a strong edge and having a magnitude greater than
the low threshold corresponds to a weak edge.
© 2007 Texas Instruments Inc, Slide 14
The Edge Detection Block
• The Edge Detection Block supports the four methods
described in the pervious slides

© 2007 Texas Instruments Inc, Slide 15


Hands-On

• Simulation

• Implementation using the DSK6416

© 2007 Texas Instruments Inc, Slide 16


Simulation

MATLAB®
Display
Image File Edge
Detection

© 2007 Texas Instruments Inc, Slide 17


Edge Detection Simulation

© 2007 Texas Instruments Inc, Slide 18


Edge Detection on Stills Images

MATLAB
Display
Image
Script
File
RGB
to
Grayscale

RTDX RTDX

Edge
Detection
DSK6416
© 2007 Texas Instruments Inc, Slide 19
Edge Detection Using the DSK6416

© 2007 Texas Instruments Inc, Slide 20


Edge Detection on Video

Video Video
in Edge out
Camera Detection Video Screen

DM6437 DVDP
© 2007 Texas Instruments Inc, Slide 21
Edge Detection Real Time Model for the
DM6437 DVDP

© 2007 Texas Instruments Inc, Slide 22

You might also like