Download as pdf or txt
Download as pdf or txt
You are on page 1of 40

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

Hough Transform for Analytical Shapes


Voting in Parameter Space
Using Directional Information
Error Compensation: Smoothing

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

Hough Transform for Analytical Shapes


Voting in Parameter Space
Using Directional Information
Error Compensation: Smoothing

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

Hough Transform for Analytical Shapes


Voting in Parameter Space
Using Directional Information
Error Compensation: Smoothing

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, )
= A(
+1
Accumulator: A(
, )
, )
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, )
= A(
+1
Accumulator: A(
, )
, )
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, )
= A(
+1
Accumulator: A(
, )
, )
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, )
= A(
+1
Accumulator: A(
, )
, )
Threshold the accumulator values to
get parameters for detected lines
= 30
Threshold at A(
, )

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, )
= A(
+1
Accumulator: A(
, )
, )
Threshold the accumulator values to
get parameters for detected lines
= 20
Threshold at A(
, )

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, )
= A(
+1
Accumulator: A(
, )
, )
Threshold the accumulator values to
get parameters for detected lines
= 15
Threshold at A(
, )

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, )
= A(
+1
Accumulator: A(
, )
, )
Threshold the accumulator values to
get parameters for detected lines
= 15
Threshold at A(
, )

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, )
= A(
+1
Accumulator: A(
, )
, )
Threshold the accumulator values to
get parameters for detected lines
= 15
Threshold at A(
, )

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, )
= A(
+1
Accumulator: A(
, )
, )
Threshold the accumulator values to
get parameters for detected lines
= 15
Threshold at A(
, )

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

Hough Transform for Analytical Shapes


Voting in Parameter Space
Using Directional Information
Error Compensation: Smoothing

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)

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

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

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

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

(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

Hough Transform for Analytical Shapes


Voting in Parameter Space
Using Directional Information
Error Compensation: Smoothing

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

Hough Transform for Analytical Shapes


Voting in Parameter Space
Using Directional Information
Error Compensation: Smoothing

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

Ri

0
1
2
...

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

Ri

0
1
2
...

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

Ri

0
1
2
...

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

Ri

0
1
2
...

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

You might also like