0% found this document useful (0 votes)
3 views

lect34

Uploaded by

nnehasingh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

lect34

Uploaded by

nnehasingh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

Digital imag

e
processing
Lecture 34
The Canny Edge Detector

0 Optimal for step edges corrupted by white noise.

0 The Objective

1. Low error rate


The edges detected must be as close as possible to the true edge

2. Edge points should be well localized


The edges located must be as close as possible to the true edges

3. Single edge point response


The number of local maxima around the true edge should be
minimum

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

We form a smoothed image, f s ( x, y ) by


convolving G and f :
f s ( x, y ) G ( x, y ) f ( x, y )

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

Note: any of the filter mask pairs in Fig.10.14 can be used


to obtain g x and g 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

0 Smooth the input image with a Gaussian filter

0 Compute the gradient magnitude and angle images

0 Apply nonmaxima suppression to the gradient


magnitude image

0 Use double thresholding and connectivity analysis to


detect and link edges

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

0 Edge detection typically is followed by linking


algorithms designed to assemble edge pixels into
meaningful edges and/or region boundaries

0 Three approaches to edge linking


Local processing
Regional processing
Global processing

01/20/2025 12
Local Processing

0 Analyze the characteristics of pixels in a small


neighborhood about every point (x,y) that has been
declared an edge point

0 All points that similar according to predefined criteria are


linked, forming an edge of pixels.
Establishing similarity: (1) the strength (magnitude) and
(2) the direction of the gradient vector.
A pixel with coordinates (s,t) in Sxy is linked to the pixel at
(x,y) if both magnitude and direction criteria are satisfied.

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)

2. Form a binary image, g, whose value at any pair of


coordinates (x,y) is given by
 1 if M ( x, y )  TM and  ( x, y )  A TA
g ( x, y ) 
0 otherwise
TM : threshold A : specified angle direction
TA : a "band" of acceptable directions about A

01/20/2025 15
Local Processing: Steps (2)

3. Scan the rows of g and fill (set to 1) all gaps (sets of


0s) in each row that do not exceed a specified
length, K.

4. To detect gaps in any other direction, rotate g by


this angle and apply the horizontal scanning
procedure in step 3.

01/20/2025 16
01/20/2025 17
Regional Processing

0 The location of regions of interest in an image are known


or can be determined

0 Polygonal approximations can capture the essential shape


features of a region while keeping the representation of
the boundary relatively simple

0 Open or closed curve


Open curve: a large distance between two consecutive
points in the ordered sequence relative to the distance
between other points
01/20/2025 18
01/20/2025 19
Regional Processing: Steps
1. Let P be the sequence of ordered, distinct, 1-valued
points of a binary image. Specify two starting points, A
and B.
2. Specify a threshold, T, and two empty stacks, OPEN and
ClOSED.
3. If the points in P correspond to a closed curve, put A
into OPEN and put B into OPEN and CLOSES. If the
points correspond to an open curve, put A into OPEN
and B into CLOSED.
4. Compute the parameters of the line passing from the
last vertex in CLOSED to the last vertex in OPEN.
01/20/2025 20
Regional Processing: Steps
5. Compute the distances from the line in Step 4 to all the
points in P whose sequence places them between the
vertices from Step 4. Select the point, Vmax, with the
maximum distance, Dmax
6. If Dmax> T, place Vmax at the end of the OPEN stack as a
new vertex. Go to step 4.
7. Else, remove the last vertex from OPEN and insert it as
the last vertex of CLOSED.
8. If OPEN is not empty, go to step 4.
9. Else, exit. The vertices in CLOSED are the vertices of the
polygonal fit to the points in P.
01/20/2025 21
01/20/2025 22
01/20/2025 23

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy