lect34
lect34
e
processing
Lecture 34
The Canny Edge Detector
0 The Objective
01/20/2025 2
The Canny Edge Detector: Algorithm (1)
Let f ( x, y ) denote the input image and
G ( x, y ) denote the Gaussian function:
x2 y 2
2 2
G ( x, y ) e
01/20/2025 3
The Canny Edge Detector: Algorithm(2)
Compute the gradient magnitude and direction (angle):
M ( x, y ) g x 2 g y 2
and
( x, y ) arctan( g y / g x )
where g x f s / x and g y f s / y
01/20/2025 4
The Canny Edge Detector: Algorithm(3)
The gradient M ( x, y) typically contains wide ridge around
local maxima. Next step is to thin those ridges.
Nonmaxima suppression:
Let d1 , d 2 , d3 , and d 4 denote the four basic edge directions for
a 3 3 region: horizontal, -45o , vertical,+45 , respectively.
1. Find the direction d k that is closest to ( x, y ).
2. If the value of M ( x, y) is less than at least one of its two
neighbors along d k , let g N ( x, y) 0 (suppression);
otherwise, let g N ( x, y) M ( x, y)
01/20/2025 5
01/20/2025 6
The Canny Edge Detector: Algorithm(4)
The final operation is to threshold g N ( x, y) to reduce
false edge points.
Hysteresis thresholding:
g NH ( x, y) g N ( x, y) TH
g NL ( x, y) g N ( x, y) TL
and
g NL ( x, y) g NL ( x, y ) g NH ( x, y )
01/20/2025 7
The Canny Edge Detector: Algorithm(5)
Depending on the value of TH , the edges in g NH ( x, y )
typically have gaps. Longer edges are formed using
the following procedure:
(a). Locate the next unvisited edge pixel, p, in g NH ( x, y ).
(b). Mark as valid edge pixel all the weak pixels in g NL ( x, y)
that are connected to p using 8-connectivity.
(c). If all nonzero pixel in g NH ( x, y) have been visited go to
step (d), esle return to (a).
(d). Set to zero all pixels in g NL ( x, y) that were not marked as
valid edge pixels.
01/20/2025 8
The Canny Edge Detection: Summary
01/20/2025 9
01/20/2025 TL 0.04; TH 0.10; 4 and a mask of size 25 25 10
TL 0.05; TH 0.15; 2 and a mask of size 13 13
01/20/2025 11
Edge Linking and Boundary Detection
01/20/2025 12
Local Processing
01/20/2025 13
Local Processing
Let S xy denote the set of coordinates of a neighborhood
centered at point (x, y) in an image. An edge pixel with
coordinate (s, t ) in S xy is similar in magnitude to the pixel
at (x, y ) if
M ( s, t ) M ( x, y ) E
An edge pixel with coordinate (s, t ) in S xy is similar in angle
to the pixel at (x, y ) if
( s , t ) ( x, y ) A
01/20/2025 14
Local Processing: Steps (1)
1. Compute the gradient magnitude and angle arrays,
M(x,y) and ( x, y ), of the input image f(x,y)
01/20/2025 15
Local Processing: Steps (2)
01/20/2025 16
01/20/2025 17
Regional Processing