You are on page 1of 22

0 - 0 - 1 1

2007 Texas Instruments Inc,


Content developed in partnership with
Tel-Aviv University
From MATLAB

and Simulink

to
Real Time with TI DSPs
Edge Detection
Slide Slide 2 2
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
Edge Detection?
The ability to measure gray-level transitions in a
meaningful way.
(R.C. Gonzales & R. E. Woods Di gi tal Image Processi ng, 2
nd

Edition, Prentice-Hall, 2001)
Slide Slide 3 3
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
Gray-Level Transition
Ideal
Ramp
Slide Slide 4 4
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
The First Derivative
Ori gi nal
Fi rst Deri vati ve
Slide Slide 5 5
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
Detecting the Edge (1)
( ) y x I ,
( )
x
y x I

,
x
Ori gi nal
Fi rst Deri vati ve
TRSH
x
( )
Detected Edge TRSH
x
y x I
>

,
Slide Slide 6 6
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
Detecting the Edge (2)
Ori gi nal Fi rst Deri vati ve
( ) y x I ,
( )
x
y x I

,
( )
Detected Not Edge TRSH
x
y x I
<

,
TRSH
Slide Slide 7 7
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
Gradient Operators
The gradient of the image I(x,y) at location (x,y), is
the vector:
The magnitude of the gradient:
The direction of the gradient vector:
( )
( )
1
1
1
1
]
1

1
]
1


y
y x I
x
y x I
G
G
I
y
x
,
,
[ ]
2 2
y x
G G I I +
( )

,
_


y
x
G
G
y x
1
tan ,
Slide Slide 8 8
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
The Meaning of the Gradient
It represents the direction of the strongest variation
in intensity
( ) 0

y x
G I
x
,
The direction of the edge at location (x,y) is
perpendicular to the gradient vector at that point
( )
2



y x
G I
y
,
Vertical Horizontal Generic
Edge Strength:
Edge Direction:
[ ]
( )

,
_

x
y
y x
G
G
y x
G G I
1
2 2
tan ,
Slide Slide 9 9
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
Calculating the Gradient
For each pixel the
gradient is calculated,
based on a 3x3
neighborhood around
this pixel.
z
1
z
2
z
3
z
4
z
5
z
6
z
7
z
8
z
9
Slide Slide 10 10
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
The Sobel Edge Detector
-1 -2 -1
0 0 0
1 2 1
-1 0 1
-2 0 2
-1 0 1
( ) ( )
3 2 1 9 8 7
2 2 z z z z z z G
x
+ + + +
( ) ( )
7 4 1 9 6 3
2 2 z z z z z z G
y
+ + + +
Slide Slide 11 11
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
The Prewitt Edge Detector
-1 -1 -1
0 0 0
1 1 1
-1 0 1
-1 0 1
-1 0 1
( ) ( )
3 2 1 9 8 7
z z z z z z G
x
+ + + +
( ) ( )
7 4 1 9 6 3
z z z z z z G
y
+ + + +
Slide Slide 12 12
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
The Roberts Edge Detector
0 0 0
0 -1 0
0 0 1
0 0 0
0 0 -1
0 1 0
5 9
z z G
x

6 8
z z G
y

The Roberts Edge Detector is in fact a 2x2 operator
Slide Slide 13 13
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
The Canny Method
Two Possible Implementations:
1. The image is convolved with a Gaussian filter before gradient
evaluation
2. The image is convolved with the gradient of the Gaussian
Filter.
( )
2 2
2
2
2
y x r
e r h
r
+

Slide Slide 14 14
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
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.
Slide Slide 15 15
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
The Edge Detection Block
The Edge Detection Block supports the four methods
described in the pervious slides
Slide Slide 16 16
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
Hands-On
Simulation
Implementation using the DSK6416
Slide Slide 17 17
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
Simulation
Image File
MATLAB


Display
Edge
Detection
Slide Slide 18 18
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
Edge Detection Simulation
Slide Slide 19 19
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
DSK6416
Image
File
MATLAB
Display
Edge
Detection
Script
RGB
to
Grayscale
RTDX RTDX
Edge Detection on Stills Images
Slide Slide 20 20
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
Edge Detection Using the DSK6416
Slide Slide 21 21
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
Video
in
Video
out
DM6437 DVDP
Edge
Detection
Video Screen Camera
Edge Detection on Video
Slide Slide 22 22
2007 Texas Instruments Inc, 2007 Texas Instruments Inc,
Edge Detection Real Time Model for the
DM6437 DVDP

You might also like