You are on page 1of 21

Hough Transform

Image and Parameter Spaces

y  mx  c y
Equation of Line: y  mx  c
Find: (m, c)

Consider point: ( xi , yi ) ( xi , yi )
x
yi  mx i  c or c   xi m  yi Image Space

m
Parameter space also called Hough Space

(m, c)
c
Parameter Space
Line Detection by Hough Transform
m

Algorithm:

• Quantize Parameter Space (m, c)


(m, c)
• Create Accumulator Array A(m, c) c
• Set A(m, c)  0 m, c Parameter Space
A(m, c)
• For each image edge ( xi , yi ) increment: 1 1
1 1
A(m, c)  A(m, c) 1 1 1
2
• If (m, c)lies on the line: 1 1
1 1
c   xi m  yi 1 1

• Find local maxima in A(m, c)


Better Parameterization

NOTE:   m   y
Large Accumulator ( 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

Finding Straight Line Segments

• y = mx + c is not suitable
• The equation generally used is: ρ = r sin  + c cos 

c

ρ
ρ is the distance from the line to origin

r  is the angle the perpendicular makes


with the column axis

5
Image space Votes

Horizontal axis is θ,
vertical is ρ.
Image votes
space
Real World Example

Original Edge Detection Found Lines

Parameter Space
Hough Transform
• The Hough transform is a method for detecting
lines or curves specified by a parametric function.

• If the parameters are p1, p2, … pn, then the Hough


procedure uses an n-dimensional accumulator array
in which it accumulates votes for the correct parameters
of the lines or curves found on the image.

image accumulator
c

m
y = mx + c

13
Procedure to Accumulate Lines
•Set accumulator array A to all zero.
Set point list array PTLIST to all NIL.

• For each pixel in the image


{
•compute gradient magnitude GMAG
• if GMAG > gradient_threshold
{
• compute quantized tangent angle thetaQ
• compute quantized distance to origin rhoQ
• increment A(rhoQ, thetaQ)
• update PTLIST(rhoQ,thetaQ)
}}
14
Example
gray-tone image rhoQ thetaQ
0 0 0 100 100 - - 3 3 - - - 0 0 -
0 0 0 100 100 - - 3 3 - - - 0 0 -
0 0 0 100 100 3 3 3 3 - 90 90 40 20 -
100 100 100 100 100 3 3 3 3 - 90 90 90 40 -
100 100 100 100 100 - - - - - - - - - -
Accumulator A PTLIST
360 - - - - - - - 360 - - - - - - - (3,1)
. - - - - - - - . - - - - - - - (3,2)
6 - - - - - - - 6 - - - - - - - (4,1)
3 4 - 1 - 2 - 5 3 * - * - * - * (4,2)
0 - - - - - - - 0 - - - - - - - (4,3)
distance
angle 0 10 20 30 40 …90 (1,3)(1,4)(2,3)(2,4)

15
How do you extract the line segments
from the accumulators?
pick the bin of A with highest value V
while V > value_threshold {

order the corresponding pointlist from PTLIST

merge in high gradient neighbors within 10 degrees

create line segment from final point list

zero out that bin of A

pick the bin of A with highest value V }


16
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)


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?


Generalized Hough Transform
• Model Shape NOT described by equation
Generalized Hough Transform
Find Object Center ( xc , yc ) given edges ( xi , yi , i )
Create Accumulator Array A( xc , yc )
Initialize: A( xc , yc )  0 ( xc , yc )
For each edge point ( xi , yi , i )
For each entry rki in table, compute:

xc  xi  rki cos  ki
yc  yi  rki sin  ki
Increment Accumulator: A( xc , yc )  A( xc , yc )  1
Find Local Maxima in A( xc , yc )
Hough Transform: Comments

• Works on Disconnected Edges

• Relatively insensitive to occlusion

• Effective for simple shapes (lines, circles, etc)

• Trade-off between work in Image Space and Parameter Space

• Handling inaccurate edge locations:

• Increment Patch in Accumulator rather than a single point

You might also like