Hough Transform
16-385 Computer Vision (Kris Kitani)
Carnegie Mellon University
Hough Transform 16-385 Computer Vision (Kris Kitani) Carnegie - - PowerPoint PPT Presentation
Hough Transform 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University motivation Original image Edge detection Thresholding How do we find image boundaries (lines)? Hough Transform Generic framework for detecting a shape/object
16-385 Computer Vision (Kris Kitani)
Carnegie Mellon University
Edge detection Thresholding Original image
How do we find image boundaries (lines)?
y = mx + b y − mx = b
x y m b
variables parameters parameters variables
(1, 1)
a line becomes a point Image space Parameter space
y = mx + b y − mx = b
x y m b
variables parameters parameters variables
(1, 1)
a point becomes a line Image space Parameter space
y = mx + b y − mx = b
x y m b
variables parameters parameters variables
(1, 1)
Image space Parameter space
(3, 3)
two points become ?
y = mx + b y − mx = b
x y m b
variables parameters parameters variables
(1, 1)
Image space Parameter space
(3, 3)
two points become ?
y = mx + b y − mx = b
x y m b
variables parameters parameters variables
(1, 1)
Image space Parameter space
(3, 3) (−2, −2)
three points become ?
y = mx + b y − mx = b
x y m b
variables parameters parameters variables
(1, 1)
Image space Parameter space
(3, 3) (−2, −2)
four points become ?
(1, −1)
y = mx + b y − mx = b
x y m b
variables parameters parameters variables
(1, 1)
Image space Parameter space
(3, 3) (−2, −2)
four points become ?
(1, −1)
x y m b
(1, 1)
Image space Parameter space
(3, 3) (−2, −2) (1, −1)
Is your method robust to measurement noise? Is your method robust to outliers?
y x ) , ( c m
Parameter Space
1 1 1 1 1 1 2 1 1 1 1 1 1
) , ( c m A
Algorithm: 1.Quantize Parameter Space 2.Create Accumulator Array 3.Set
For each element in If lies on the line: Increment
) , ( c m ) , ( c m A c m c m A , ) , ( ∀ = ) , (
i i y
x 1 ) , ( ) , ( + = c m A c m A ) , ( c m ) , ( c m A
i i
y m x c + − = ) , ( c m A
1 1 1 1 1 1 2 1 1 1 1 1 1
) , ( c m A
What’s wrong with the parameterization ?
) , ( c m
How big does the accumulator need to be?
1 1 1 1 1 1 2 1 1 1 1 1 1
) , ( c m A
What’s wrong with the parameterization ?
) , ( c m
How big does the accumulator need to be?
The space of m is huge! The space of c is huge!
1 1 1 1 1 1 2 1 1 1 1 1 1
) , ( c m A
What’s wrong with the parameterization ?
) , ( c m
How big does the accumulator need to be?
The space of m is huge! The space of c is huge!
∞ ≤ ≤ ∞ − m
Given points find
max
2 ρ ρ π θ ≤ ≤ ≤ ≤
(Finite Accumulator Array Size)
) , (
i i y
x ) , ( θ ρ ) , (
i i y
x
y
x
Image Space
ρ θ
Hough Space
Hough Space Sinusoid
Use normal form:
x cos θ + y sin θ = ρ
0.25π 0.5π 0.75π
1 2 3 4
y = mx + b
x y
variables parameters
(1, 1)
a point becomes a wave Image space Parameter space
x cos θ + y sin θ = ρ
parameters variables
ρ θ
0.25π 0.5π 0.75π
1 2 3 4
y = mx + b
x y
variables parameters
(1, 1)
a line becomes a point Image space Parameter space
x cos θ + y sin θ = ρ
0.25π 0.5π 0.75π
1 2 3 4
y = mx + b
x y
variables parameters
(1, 1)
a line becomes a point Image space Parameter space
x cos θ + y sin θ = ρ
0.25π 0.5π 0.75π
1 2 3 4
y = mx + b
x y
variables parameters
(1, 1)
a line becomes a point Image space Parameter space
x cos θ + y sin θ = ρ
0.25π 0.5π 0.75π
1 2 3 4
y = mx + b
x y
variables parameters
(1, 1)
a line becomes a point Image space Parameter space
x cos θ + y sin θ = ρ
0.25π 0.5π 0.75π
1 2 3 4
y = mx + b x y
variables parameters
(1, 1)
a line becomes a point Image space Parameter space
x cos θ + y sin θ = ρ
0.25π 0.5π 0.75π
1 2 3 4
y = mx + b x y
variables parameters
(1, 1)
a line becomes a point Image space Parameter space
x cos θ + y sin θ = ρ
0.25π 0.5π 0.75π
1 2 3 4
y = mx + b x y
variables parameters
(1, 1)
a line becomes a point Image space Parameter space
x cos θ + y sin θ = ρ
Wait …why is rho negative?
0.25π 0.5π 0.75π
1 2 3 4
y = mx + b x y
variables parameters
(1, 1)
a line becomes a point Image space Parameter space same line through the point
x cos θ + y sin θ = ρ
There are two ways to write the same line: Positive rho version: x cos θ + y sin θ = ρ x cos(θ + π) + y sin(θ + π) = −ρ Negative rho version:
x
y
(1, 1)
x
y
(1, 1)
θ
θ + π
ρ
−ρ
sin(θ) = − sin(θ + π) cos(θ) = − cos(θ + π)
Recall:
0.25π 0.5π 0.75π
1 2 3 4
y = mx + b x y
variables parameters
(1, 1)
a line becomes a point Image space Parameter space same line through the point
x cos θ + y sin θ = ρ
0.25π 0.5π 0.75π
1 2 3 4
y = mx + b
x y
variables parameters
(1, 1)
Image space Parameter space
(3, 3)
two points become ?
0.25π 0.5π 0.75π
1 2 3 4
y = mx + b
x y
variables parameters
(1, 1)
Image space Parameter space
(3, 3) (−2, −2)
three points become ?
0.25π 0.5π 0.75π
1 2 3 4
y = mx + b
x y
variables parameters
(1, 1)
Image space Parameter space
(3, 3) (−2, −2)
four points become ?
(1, −1)
For θ = 0 to 180 ρ = x cos θ + y sin θ H(θ, ρ) = H(θ, ρ) + 1 end end
is a local maximum
ρ = x cos θ + y sin θ
NOTE: Watch your coordinates. Image origin is top left!
Image space Votes
(in polar parameter space)
can you guess the shape?
line rectangle circle
(in polar parameter space)
In practice, measurements are noisy…
Image space Votes
Image space Votes
Too much noise …
More noise, less votes (in the right bin)
Maximum number of votes 5 10 15 Noise level 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09
Number of votes for a line of 20 points with increasing noise
Maximum number of votes 3 6 9 12 Number of noise points 20 40 60 80 100 120 140 160 180 200
More noise, more votes (in the wrong bin)
Original Edges Hough Lines parameter space