Hough Transform
600.658 - Seminar on Shape Analysis and Retrieval
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
1 of 40
Detection of arbitrary shapes
Partial shape matching can also be viewed as detecting
arbitrary shapes
Hough transform is a method for estimating the parameters of
a shape from its boundary points
The idea can be generalized to estimate “parameters” of
arbitrary shapes
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
2 of 40
Outline
1
Hough Transform for Analytical Shapes
Voting in Parameter Space
Using Directional Information
Error Compensation: Smoothing
2
Generalizing to Non-Analytical Shapes
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
3 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Outline
1
Hough Transform for Analytical Shapes
Voting in Parameter Space
Using Directional Information
Error Compensation: Smoothing
2
Generalizing to Non-Analytical Shapes
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
4 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Straight line
Normal parameterization:
x cos θ + y sin θ = ρ
Points in picture ↔ sinusoids in
parameter space
Points in parameter space ↔ lines in
picture
Sinusoids corresponding to co-linear
points intersect at an unique point
[2]
Example
Line: 0.6x + 0.4y = 2.4
Sinusoids intersect at: ρ = 2.4, θ = 0.9273
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
5 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Straight line
Normal parameterization:
x cos θ + y sin θ = ρ
Points in picture ↔ sinusoids in
parameter space
Points in parameter space ↔ lines in
picture
Sinusoids corresponding to co-linear
points intersect at an unique point
[2]
Example
Line: 0.6x + 0.4y = 2.4
Sinusoids intersect at: ρ = 2.4, θ = 0.9273
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
6 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Straight line
Normal parameterization:
x cos θ + y sin θ = ρ
Points in picture ↔ sinusoids in
parameter space
Points in parameter space ↔ lines in
picture
Sinusoids corresponding to co-linear
points intersect at an unique point
[2]
Example
Line: 0.6x + 0.4y = 2.4
Sinusoids intersect at: ρ = 2.4, θ = 0.9273
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
7 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Straight line
Normal parameterization:
x cos θ + y sin θ = ρ
Points in picture ↔ sinusoids in
parameter space
Points in parameter space ↔ lines in
picture
Sinusoids corresponding to co-linear
points intersect at an unique point
Example
Line: 0.6x + 0.4y = 2.4
Sinusoids intersect at: ρ = 2.4, θ = 0.9273
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
8 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Outline
1
Hough Transform for Analytical Shapes
Voting in Parameter Space
Using Directional Information
Error Compensation: Smoothing
2
Generalizing to Non-Analytical Shapes
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
9 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Quantize parameter space and vote into bins
Let ρ ∈ [−R, R] and θ ∈ [0, π)
For each edge point (xi , yi ), calculate:
ρ̂ = xi cos θ̂ + yi sin θ̂
∀θ̂ ∈ [0, π)
Accumulator: A(ρ̂, θ̂) = A(ρ̂, θ̂) + 1
Threshold the accumulator values to
get parameters for detected lines
Same general idea applies to other
analytical shapes
O(nd1 ) computation, instead of O(n2 )
Can we do better?
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
10 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Quantize parameter space and vote into bins
Let ρ ∈ [−R, R] and θ ∈ [0, π)
For each edge point (xi , yi ), calculate:
ρ̂ = xi cos θ̂ + yi sin θ̂
∀θ̂ ∈ [0, π)
Accumulator: A(ρ̂, θ̂) = A(ρ̂, θ̂) + 1
Threshold the accumulator values to
get parameters for detected lines
Same general idea applies to other
analytical shapes
O(nd1 ) computation, instead of O(n2 )
Can we do better?
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
11 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Quantize parameter space and vote into bins
Let ρ ∈ [−R, R] and θ ∈ [0, π)
For each edge point (xi , yi ), calculate:
ρ̂ = xi cos θ̂ + yi sin θ̂
∀θ̂ ∈ [0, π)
Accumulator: A(ρ̂, θ̂) = A(ρ̂, θ̂) + 1
Threshold the accumulator values to
get parameters for detected lines
Same general idea applies to other
analytical shapes
O(nd1 ) computation, instead of O(n2 )
Can we do better?
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
12 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Quantize parameter space and vote into bins
Let ρ ∈ [−R, R] and θ ∈ [0, π)
For each edge point (xi , yi ), calculate:
ρ̂ = xi cos θ̂ + yi sin θ̂
∀θ̂ ∈ [0, π)
Accumulator: A(ρ̂, θ̂) = A(ρ̂, θ̂) + 1
Threshold the accumulator values to
get parameters for detected lines
Threshold at A(ρ̂, θ̂) = 30
Same general idea applies to other
analytical shapes
O(nd1 ) computation, instead of O(n2 )
Can we do better?
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
13 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Quantize parameter space and vote into bins
Let ρ ∈ [−R, R] and θ ∈ [0, π)
For each edge point (xi , yi ), calculate:
ρ̂ = xi cos θ̂ + yi sin θ̂
∀θ̂ ∈ [0, π)
Accumulator: A(ρ̂, θ̂) = A(ρ̂, θ̂) + 1
Threshold the accumulator values to
get parameters for detected lines
Threshold at A(ρ̂, θ̂) = 20
Same general idea applies to other
analytical shapes
O(nd1 ) computation, instead of O(n2 )
Can we do better?
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
14 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Quantize parameter space and vote into bins
Let ρ ∈ [−R, R] and θ ∈ [0, π)
For each edge point (xi , yi ), calculate:
ρ̂ = xi cos θ̂ + yi sin θ̂
∀θ̂ ∈ [0, π)
Accumulator: A(ρ̂, θ̂) = A(ρ̂, θ̂) + 1
Threshold the accumulator values to
get parameters for detected lines
Threshold at A(ρ̂, θ̂) = 15
Same general idea applies to other
analytical shapes
O(nd1 ) computation, instead of O(n2 )
Can we do better?
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
15 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Quantize parameter space and vote into bins
Let ρ ∈ [−R, R] and θ ∈ [0, π)
For each edge point (xi , yi ), calculate:
ρ̂ = xi cos θ̂ + yi sin θ̂
∀θ̂ ∈ [0, π)
Accumulator: A(ρ̂, θ̂) = A(ρ̂, θ̂) + 1
Threshold the accumulator values to
get parameters for detected lines
Threshold at A(ρ̂, θ̂) = 15
Same general idea applies to other
analytical shapes
O(nd1 ) computation, instead of O(n2 )
Can we do better?
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
16 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Quantize parameter space and vote into bins
Let ρ ∈ [−R, R] and θ ∈ [0, π)
For each edge point (xi , yi ), calculate:
ρ̂ = xi cos θ̂ + yi sin θ̂
∀θ̂ ∈ [0, π)
Accumulator: A(ρ̂, θ̂) = A(ρ̂, θ̂) + 1
Threshold the accumulator values to
get parameters for detected lines
Threshold at A(ρ̂, θ̂) = 15
Same general idea applies to other
analytical shapes
O(nd1 ) computation, instead of O(n2 )
Can we do better?
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
17 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Quantize parameter space and vote into bins
Let ρ ∈ [−R, R] and θ ∈ [0, π)
For each edge point (xi , yi ), calculate:
ρ̂ = xi cos θ̂ + yi sin θ̂
∀θ̂ ∈ [0, π)
Accumulator: A(ρ̂, θ̂) = A(ρ̂, θ̂) + 1
Threshold the accumulator values to
get parameters for detected lines
Threshold at A(ρ̂, θ̂) = 15
Same general idea applies to other
analytical shapes
O(nd1 ) computation, instead of O(n2 )
Can we do better?
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
18 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Outline
1
Hough Transform for Analytical Shapes
Voting in Parameter Space
Using Directional Information
Error Compensation: Smoothing
2
Generalizing to Non-Analytical Shapes
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
19 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Use what you have already got!
More parameters ⇒ More computation and storage
Gradient information reduces one more free parameter
For circle: center lies r units along the gradient
Rotation affects the gradient direction only
f (x, p) = (x − a)2 + (y − b)2 − r 2 = 0
x = (x, y )
df
dx (x, p) = 0
dy
dx = tan φ(x)
−
π
2
φ(x) is the gradient direction
Update A(p) if f (x, p) = 0 and
dy
π
dx = tan φ(x) − θ − 2
CS658: Seminar on Shape Analysis and Retrieval
p = (a, b, r ),
df
dx (x, p)
Hough Transform
=0
20 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Use what you have already got!
More parameters ⇒ More computation and storage
Gradient information reduces one more free parameter
For circle: center lies r units along the gradient
Rotation affects the gradient direction only
f (x, p) = (x − a)2 + (y − b)2 − r 2 = 0
x = (x, y )
df
dx (x, p) = 0
dy
dx = tan φ(x)
−
π
2
φ(x) is the gradient direction
Update A(p) if f (x, p) = 0 and
dy
π
dx = tan φ(x) − θ − 2
CS658: Seminar on Shape Analysis and Retrieval
p = (a, b, r ),
df
dx (x, p)
Hough Transform
=0
21 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Use what you have already got!
More parameters ⇒ More computation and storage
Gradient information reduces one more free parameter
For circle: center lies r units along the gradient
Rotation affects the gradient direction only
f (x, p) = (x − a)2 + (y − b)2 − r 2 = 0
x = (x, y )
df
dx (x, p) = 0
dy
dx = tan φ(x)
−
π
2
φ(x) is the gradient direction
Update A(p) if f (x, p) = 0 and
dy
π
dx = tan φ(x) − θ − 2
CS658: Seminar on Shape Analysis and Retrieval
p = (a, b, r ),
df
dx (x, p)
Hough Transform
=0
22 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Use what you have already got!
More parameters ⇒ More computation and storage
Gradient information reduces one more free parameter
For circle: center lies r units along the gradient
Rotation affects the gradient direction only
f (x, p) = (x − a)2 + (y − b)2 − r 2 = 0
x = (x, y )
df
dx (x, p) = 0
dy
dx = tan φ(x)
−
π
2
φ(x) is the gradient direction
Update A(p) if f (x, p) = 0 and
dy
π
dx = tan φ(x) − θ − 2
CS658: Seminar on Shape Analysis and Retrieval
p = (a, b, r ),
df
dx (x, p)
Hough Transform
=0
23 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Use what you have already got!
More parameters ⇒ More computation and storage
Gradient information reduces one more free parameter
For circle: center lies r units along the gradient
Rotation affects the gradient direction only
f (x, p) = (x − a)2 + (y − b)2 − r 2 = 0
x = (x, y )
df
dx (x, p) = 0
dy
dx = tan φ(x)
−
π
2
φ(x) is the gradient direction
Update A(p) if f (x, p) = 0 and
dy
π
dx = tan φ(x) − θ − 2
CS658: Seminar on Shape Analysis and Retrieval
p = (a, b, r ),
df
dx (x, p)
Hough Transform
=0
24 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Outline
1
Hough Transform for Analytical Shapes
Voting in Parameter Space
Using Directional Information
Error Compensation: Smoothing
2
Generalizing to Non-Analytical Shapes
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
25 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Compensating for errors
Errors can cause A(p0 ) to be
incremented, where p0 is close
to the actual parameter p
Compensate for the uncertainty
of measurement in parameter
space
Smooth the accumulator by
incrementing counts of nearby
cells accroding to some
point-spread function h
Equivalent to convolving A ∗ h
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
26 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Compensating for errors
Errors can cause A(p0 ) to be
incremented, where p0 is close
to the actual parameter p
Compensate for the uncertainty
of measurement in parameter
space
[1]
Smooth the accumulator by
incrementing counts of nearby
cells accroding to some
point-spread function h
Equivalent to convolving A ∗ h
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
27 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Compensating for errors
Errors can cause A(p0 ) to be
incremented, where p0 is close
to the actual parameter p
Compensate for the uncertainty
of measurement in parameter
space
[1]
Smooth the accumulator by
incrementing counts of nearby
cells accroding to some
point-spread function h
Equivalent to convolving A ∗ h
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
28 of 40
Analytical Shapes
Non-analytical Shapes
Reference
Voting in Parameter Space
Gradient
Smoothing
Compensating for errors
Errors can cause A(p0 ) to be
incremented, where p0 is close
to the actual parameter p
Compensate for the uncertainty
of measurement in parameter
space
[1]
Smooth the accumulator by
incrementing counts of nearby
cells accroding to some
point-spread function h
Equivalent to convolving A ∗ h
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
29 of 40
Analytical Shapes
Non-analytical Shapes
Reference
The R-table
Composite Shapes
Incrementation Strategies
Outline
1
Hough Transform for Analytical Shapes
Voting in Parameter Space
Using Directional Information
Error Compensation: Smoothing
2
Generalizing to Non-Analytical Shapes
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
30 of 40
Analytical Shapes
Non-analytical Shapes
Reference
The R-table
Composite Shapes
Incrementation Strategies
The R-table
Any shape is specified by the set of boundary points B = {xB }
For a shape, define p as: p = {x0 , s, θ}
For each xB , compute r = x0 − xB , and store as function of φ
For each edge pixel x (with gradient direction φ(x)) in an
image, obtain r from the table and update A(x + r)
i
φi
Rφi
0
1
2
...
0
∆φ
2∆φ
...
{r|x0 − r = xB , xB ∈ B, φ(xB ) = 0}
{r|x0 − r = xB , xB ∈ B, φ(xB ) = ∆φ}
{r|x0 − r = xB , xB ∈ B, φ(xB ) = 2∆φ}
...
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
31 of 40
Analytical Shapes
Non-analytical Shapes
Reference
The R-table
Composite Shapes
Incrementation Strategies
The R-table
Any shape is specified by the set of boundary points B = {xB }
For a shape, define p as: p = {x0 , s, θ}
For each xB , compute r = x0 − xB , and store as function of φ
For each edge pixel x (with gradient direction φ(x)) in an
image, obtain r from the table and update A(x + r)
i
φi
Rφi
0
1
2
...
0
∆φ
2∆φ
...
{r|x0 − r = xB , xB ∈ B, φ(xB ) = 0}
{r|x0 − r = xB , xB ∈ B, φ(xB ) = ∆φ}
{r|x0 − r = xB , xB ∈ B, φ(xB ) = 2∆φ}
...
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
32 of 40
Analytical Shapes
Non-analytical Shapes
Reference
The R-table
Composite Shapes
Incrementation Strategies
The R-table
Any shape is specified by the set of boundary points B = {xB }
For a shape, define p as: p = {x0 , s, θ}
For each xB , compute r = x0 − xB , and store as function of φ
For each edge pixel x (with gradient direction φ(x)) in an
image, obtain r from the table and update A(x + r)
i
φi
Rφi
0
1
2
...
0
∆φ
2∆φ
...
{r|x0 − r = xB , xB ∈ B, φ(xB ) = 0}
{r|x0 − r = xB , xB ∈ B, φ(xB ) = ∆φ}
{r|x0 − r = xB , xB ∈ B, φ(xB ) = 2∆φ}
...
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
33 of 40
Analytical Shapes
Non-analytical Shapes
Reference
The R-table
Composite Shapes
Incrementation Strategies
The R-table
Any shape is specified by the set of boundary points B = {xB }
For a shape, define p as: p = {x0 , s, θ}
For each xB , compute r = x0 − xB , and store as function of φ
For each edge pixel x (with gradient direction φ(x)) in an
image, obtain r from the table and update A(x + r)
i
φi
Rφi
0
1
2
...
0
∆φ
2∆φ
...
{r|x0 − r = xB , xB ∈ B, φ(xB ) = 0}
{r|x0 − r = xB , xB ∈ B, φ(xB ) = ∆φ}
{r|x0 − r = xB , xB ∈ B, φ(xB ) = 2∆φ}
...
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
34 of 40
Analytical Shapes
Non-analytical Shapes
Reference
The R-table
Composite Shapes
Incrementation Strategies
Transformations of the R-table
Let R(φ) be the R-table for a shape S
Scale: Ts [R(φ)] = sR(φ)
Scale all the vectors r by s
Rotation: Tθ [R(φ)] = Rot{R[(φ − θ)mod2π], θ}
Change the indices φ to (φ − θ)mod2π, find corresponding
vectors r and rotate them by θ
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
35 of 40
Analytical Shapes
Non-analytical Shapes
Reference
The R-table
Composite Shapes
Incrementation Strategies
Hough transform for composite shapes
Let a shape S have two subparts S1 and S2 with respective
reference points x0 , x01 , and x02
Compute r1 = x0 − x01 and r2 = x0 − x02
R-table for composite shape:
˙ s2 (φ) + r2 ]
Rs (φ) = [Rs1 (φ) + r1 ]∪[R
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
36 of 40
Analytical Shapes
Non-analytical Shapes
Reference
The R-table
Composite Shapes
Incrementation Strategies
Hough transform for composite shapes
Let a shape S have two subparts S1 and S2 with respective
reference points x0 , x01 , and x02
Compute r1 = x0 − x01 and r2 = x0 − x02
R-table for composite shape:
˙ s2 (φ) + r2 ]
Rs (φ) = [Rs1 (φ) + r1 ]∪[R
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
37 of 40
Analytical Shapes
Non-analytical Shapes
Reference
The R-table
Composite Shapes
Incrementation Strategies
Hough transform for composite shapes
Let a shape S have two subparts S1 and S2 with respective
reference points x0 , x01 , and x02
Compute r1 = x0 − x01 and r2 = x0 − x02
R-table for composite shape:
˙ s2 (φ) + r2 ]
Rs (φ) = [Rs1 (φ) + r1 ]∪[R
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
38 of 40
Analytical Shapes
Non-analytical Shapes
Reference
The R-table
Composite Shapes
Incrementation Strategies
Incrementation Strategies
Increment the accumulator by a value depending on the
gradient: A(p) = A(p) + g (∇x)
Increment by larger values if neighbouring points are
incrementing the same reference point
Try to find progressively longer connected segments using
dynamic programming
Weigh different parts of a composite object differently
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
39 of 40
Analytical Shapes
Non-analytical Shapes
Reference
References
D. H. Ballard
Generalizing the Hough Transform to Detect Arbitrary Shapes
Pattern Recognition, 13(2):111-122, 1981.
R. O. Duda and P. E. Hart
Use of the Hough Transformation to Detect Lines and Curves
in Pictures
Communications of Association for Computing Machinery,
15(1):11-15, 1972.
CS658: Seminar on Shape Analysis and Retrieval
Hough Transform
40 of 40
© Copyright 2026 Paperzz