# Canny Edge Detection and Hough Transform

Document Sample

```					                                                                                                                            2/21/2010

Optimal edge detection (Canny, 1986)
– Good Detection.  Filter responds to edge, not
noise.
Canny Edge Detection and Hough                                       – Good Localization: detected edge near true edge.
Transform                                                    Number of responses: One real edge should not
– Number of responses: One real edge should not
result in more than one detected edge
Chen Yu
Indiana University

Edge Images
Canny Edge Detector
1) Smooth image with a Gaussian
• optimizes the trade‐off between noise filtering and edge
Edge detection                              localization
and Thresholding
Image                                Noisy edge image
Incomplete boundaries
l    b   d       2) Compute the Gradient magnitude using approximations of
2) C          h G di        i d     i         i   i     f
Shrink and Expand                  partial derivatives

3)Thin edges by applying non‐maxima suppression to the
Thinning

4)Detect edges by double thresholding

1
2/21/2010

Thinning

Non‐maximum suppression:
Select the single maximum point across the width
of an edge.

2
2/21/2010

Pixel Selection

Hysteresis Thresholding                                      Hysteresis Thresholding
•       Two Issues with one threshold:
–     Allows noisy maxima to breakthrough if too low    • Idea: use a high threshold to start   edge curves and a low
threshold to continue them.
–     Kills off weak edges if too high

•       Solution: Exploit the fact that edge pixels are     • Start with a high threshold (strong edge).
normally connected
• Apply another threshold which is lower than the higher one.
1. Set 2 thresholds, tlow and thigh
2. If a pixel IN(i,j) is >= thigh, mark it as an edge   • Look for the other edges which are higher than the lower
3. Check its neighbors along the direction θ(i,j). If   threshold and connected to the strong edges
they are greater than tlow , mark them as edges
• Add them to the edge list
–       Allows a higher threshold to kill off noise,
while retaining valid contours from the image

3
2/21/2010

next edge point

Assume the marked
point is an edge
point.

k h            l
Take the normal to
point and use this to
predict continuation
points (either r or s).

Hough Transform
Example: Canny Edge Detection
gap is gone
• Elegant method for edge detection and 2D object recognition

Strong +           • Edges need not be connected
Original
connected
image
weak edges           Complete object need not be visible
• Complete object need not be visible

• Key Idea: Edges VOTE for the possible model

Strong                                                     Weak
edges                                                     edges
only

courtesy of G. Loy

4
2/21/2010

Image space and Hough space                                                      Image Space and Hough Space

Image and Parameter Spaces                                               Line Detection by Hough Transform
y
y  mx  c       y
Equation of Line:                                        y  mx  c         Algorithm:
Find:   ( m, c )
• Quantize Parameter Space            ( m, c )
( m, c )
Consider point:      ( xi , yi )                   ( xi , yi )              • Create Accumulator Array            A(m, c)
x
x         Set
• Set    A(m, c)  0 m, c                                         p
Parameter Space

yi  mxi  c or c   xi m  yi                Image Space
( xi , yi )
• For each image edge                  increment:       1
A(m, c)
1
m                                                                                               1               1
A(m, c)  A(m, c)  1                                1       1
Parameter space also called Hough Space                                                                                                           2
( m, c )
• If              lies on the line:                             1       1
1               1

( m, c )                        c   xi m  yi                    1                       1

c       • Find local maxima in           A(m, c)
Parameter Space

5
2/21/2010

Better Parameterization                                        Example
NOTE:        m                                      y
Large Accumulator (e.g. vertical lines)            ( xi , yi )
More memory and computations

Improvement: (Finite Accumulator Array Size)
x
Line equation:      x cos   y sin                Image Space

Here         0    2                        
0     max
Given points     ( xi , yi ) find (  , )                            ?

Hough Space Sinusoid
Hough Space


Mechanics of the Hough transform

• Difficulties
• How many lines?
– how big should the cells be?
– Count the peaks in the
(too big, and we merge quite
Hough array
different lines; too small, and
different lines; too small and
noise causes lines to be                   – Treat adjacent peaks as a
missed)                                      single peak

6
2/21/2010

Real World Example                      Finding Circles by Hough Transform

Equation of Circle:

( xi  a) 2  ( yi  b) 2  r 2

If radius is known:    (2D Hough Space)

Accumulator Array    A(a, b)
Original             Edge Detection    Found Lines

Parameter Space

Real World Circle Examples
Finding Circles by Hough Transform

Equation of Circle:

( xi  a) 2  ( yi  b) 2  r 2

If radius is not known: 3D Hough Space!
Use Accumulator array     A(a, b, r )

What is the surface in the Hough space?
Crosshair indicates results of Hough transform.

7
2/21/2010

Finding Coins
Original              Edges (note noise)       Finding Coins (Continued)
Penny          Quarters

Finding Coins (Continued)

Note that because the
quarters and penny
are different sizes, a
different Hough
different Hough
transform (with
separate
accumulators) was
used for each circle
size.

Coin finding sample images
from: Vivek Kwatra

8

```
DOCUMENT INFO
Shared By:
Categories:
Stats:
 views: 151 posted: 7/18/2010 language: English pages: 8
How are you planning on using Docstoc?