40
Hough Transform 600.658 - Seminar on Shape Analysis and Retrieval CS658: Seminar on Shape Analysis and Retrieval Hough Transform 1 of 40

Hough Transform - The New Age of Discoverymisha/Fall04/GHT1.pdf · Hough transform is a method for estimating the parameters of a shape from its boundary points ... For circle: center

  • Upload
    hacong

  • View
    220

  • Download
    1

Embed Size (px)

Citation preview

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 detectingarbitrary shapes

Hough transform is a method for estimating the parameters ofa shape from its boundary points

The idea can be generalized to estimate “parameters” ofarbitrary shapes

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 2 of 40

Outline

1 Hough Transform for Analytical ShapesVoting in Parameter SpaceUsing Directional InformationError Compensation: Smoothing

2 Generalizing to Non-Analytical Shapes

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 3 of 40

Analytical ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

Outline

1 Hough Transform for Analytical ShapesVoting in Parameter SpaceUsing Directional InformationError Compensation: Smoothing

2 Generalizing to Non-Analytical Shapes

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 4 of 40

Analytical ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

Straight line

[2]

Normal parameterization:x cos θ + y sin θ = ρ

Points in picture ↔ sinusoids inparameter space

Points in parameter space ↔ lines inpicture

Sinusoids corresponding to co-linearpoints intersect at an unique point

Example

Line: 0.6x + 0.4y = 2.4Sinusoids intersect at: ρ = 2.4, θ = 0.9273

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 5 of 40

Analytical ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

Straight line

[2]

Normal parameterization:x cos θ + y sin θ = ρ

Points in picture ↔ sinusoids inparameter space

Points in parameter space ↔ lines inpicture

Sinusoids corresponding to co-linearpoints intersect at an unique point

Example

Line: 0.6x + 0.4y = 2.4Sinusoids intersect at: ρ = 2.4, θ = 0.9273

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 6 of 40

Analytical ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

Straight line

[2]

Normal parameterization:x cos θ + y sin θ = ρ

Points in picture ↔ sinusoids inparameter space

Points in parameter space ↔ lines inpicture

Sinusoids corresponding to co-linearpoints intersect at an unique point

Example

Line: 0.6x + 0.4y = 2.4Sinusoids intersect at: ρ = 2.4, θ = 0.9273

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 7 of 40

Analytical ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

Straight line

Normal parameterization:x cos θ + y sin θ = ρ

Points in picture ↔ sinusoids inparameter space

Points in parameter space ↔ lines inpicture

Sinusoids corresponding to co-linearpoints intersect at an unique point

Example

Line: 0.6x + 0.4y = 2.4Sinusoids intersect at: ρ = 2.4, θ = 0.9273

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 8 of 40

Analytical ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

Outline

1 Hough Transform for Analytical ShapesVoting in Parameter SpaceUsing Directional InformationError Compensation: Smoothing

2 Generalizing to Non-Analytical Shapes

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 9 of 40

Analytical ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

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 toget parameters for detected lines

Same general idea applies to otheranalytical 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 ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

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 toget parameters for detected lines

Same general idea applies to otheranalytical 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 ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

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 toget parameters for detected lines

Same general idea applies to otheranalytical 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 ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

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 toget parameters for detected lines

Threshold at A(ρ̂, θ̂) = 30

Same general idea applies to otheranalytical 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 ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

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 toget parameters for detected lines

Threshold at A(ρ̂, θ̂) = 20

Same general idea applies to otheranalytical 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 ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

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 toget parameters for detected lines

Threshold at A(ρ̂, θ̂) = 15

Same general idea applies to otheranalytical 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 ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

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 toget parameters for detected lines

Threshold at A(ρ̂, θ̂) = 15

Same general idea applies to otheranalytical 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 ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

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 toget parameters for detected lines

Threshold at A(ρ̂, θ̂) = 15

Same general idea applies to otheranalytical 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 ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

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 toget parameters for detected lines

Threshold at A(ρ̂, θ̂) = 15

Same general idea applies to otheranalytical 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 ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

Outline

1 Hough Transform for Analytical ShapesVoting in Parameter SpaceUsing Directional InformationError Compensation: Smoothing

2 Generalizing to Non-Analytical Shapes

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 19 of 40

Analytical ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

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 − r2 = 0 p = (a, b, r),x = (x , y)dfdx (x,p) = 0dydx = tan

[φ(x)− π

2

]φ(x) is the gradient direction

Update A(p) if f (x,p) = 0 and dfdx (x,p) = 0

dydx = tan

[φ(x)− θ − π

2

]CS658: Seminar on Shape Analysis and Retrieval Hough Transform 20 of 40

Analytical ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

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 − r2 = 0 p = (a, b, r),x = (x , y)dfdx (x,p) = 0dydx = tan

[φ(x)− π

2

]φ(x) is the gradient direction

Update A(p) if f (x,p) = 0 and dfdx (x,p) = 0

dydx = tan

[φ(x)− θ − π

2

]CS658: Seminar on Shape Analysis and Retrieval Hough Transform 21 of 40

Analytical ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

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 − r2 = 0 p = (a, b, r),x = (x , y)dfdx (x,p) = 0dydx = tan

[φ(x)− π

2

]φ(x) is the gradient direction

Update A(p) if f (x,p) = 0 and dfdx (x,p) = 0

dydx = tan

[φ(x)− θ − π

2

]CS658: Seminar on Shape Analysis and Retrieval Hough Transform 22 of 40

Analytical ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

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 − r2 = 0 p = (a, b, r),x = (x , y)dfdx (x,p) = 0dydx = tan

[φ(x)− π

2

]φ(x) is the gradient direction

Update A(p) if f (x,p) = 0 and dfdx (x,p) = 0

dydx = tan

[φ(x)− θ − π

2

]CS658: Seminar on Shape Analysis and Retrieval Hough Transform 23 of 40

Analytical ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

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 − r2 = 0 p = (a, b, r),x = (x , y)dfdx (x,p) = 0dydx = tan

[φ(x)− π

2

]φ(x) is the gradient direction

Update A(p) if f (x,p) = 0 and dfdx (x,p) = 0

dydx = tan

[φ(x)− θ − π

2

]CS658: Seminar on Shape Analysis and Retrieval Hough Transform 24 of 40

Analytical ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

Outline

1 Hough Transform for Analytical ShapesVoting in Parameter SpaceUsing Directional InformationError Compensation: Smoothing

2 Generalizing to Non-Analytical Shapes

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 25 of 40

Analytical ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

Compensating for errors

Errors can cause A(p′) to beincremented, where p′ is closeto the actual parameter p

Compensate for the uncertaintyof measurement in parameterspace

Smooth the accumulator byincrementing counts of nearbycells accroding to somepoint-spread function h

Equivalent to convolving A ∗ h

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 26 of 40

Analytical ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

Compensating for errors

[1]

Errors can cause A(p′) to beincremented, where p′ is closeto the actual parameter p

Compensate for the uncertaintyof measurement in parameterspace

Smooth the accumulator byincrementing counts of nearbycells accroding to somepoint-spread function h

Equivalent to convolving A ∗ h

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 27 of 40

Analytical ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

Compensating for errors

[1]

Errors can cause A(p′) to beincremented, where p′ is closeto the actual parameter p

Compensate for the uncertaintyof measurement in parameterspace

Smooth the accumulator byincrementing counts of nearbycells accroding to somepoint-spread function h

Equivalent to convolving A ∗ h

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 28 of 40

Analytical ShapesNon-analytical Shapes

Reference

Voting in Parameter SpaceGradientSmoothing

Compensating for errors

[1]

Errors can cause A(p′) to beincremented, where p′ is closeto the actual parameter p

Compensate for the uncertaintyof measurement in parameterspace

Smooth the accumulator byincrementing counts of nearbycells accroding to somepoint-spread function h

Equivalent to convolving A ∗ h

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 29 of 40

Analytical ShapesNon-analytical Shapes

Reference

The R-tableComposite ShapesIncrementation Strategies

Outline

1 Hough Transform for Analytical ShapesVoting in Parameter SpaceUsing Directional InformationError Compensation: Smoothing

2 Generalizing to Non-Analytical Shapes

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 30 of 40

Analytical ShapesNon-analytical Shapes

Reference

The R-tableComposite ShapesIncrementation 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 animage, obtain r from the table and update A(x + r)

i φi Rφi

0 0 {r|x0 − r = xB , xB ∈ B, φ(xB) = 0}1 ∆φ {r|x0 − r = xB , xB ∈ B, φ(xB) = ∆φ}2 2∆φ {r|x0 − r = xB , xB ∈ B, φ(xB) = 2∆φ}

. . . . . . . . .

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 31 of 40

Analytical ShapesNon-analytical Shapes

Reference

The R-tableComposite ShapesIncrementation 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 animage, obtain r from the table and update A(x + r)

i φi Rφi

0 0 {r|x0 − r = xB , xB ∈ B, φ(xB) = 0}1 ∆φ {r|x0 − r = xB , xB ∈ B, φ(xB) = ∆φ}2 2∆φ {r|x0 − r = xB , xB ∈ B, φ(xB) = 2∆φ}

. . . . . . . . .

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 32 of 40

Analytical ShapesNon-analytical Shapes

Reference

The R-tableComposite ShapesIncrementation 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 animage, obtain r from the table and update A(x + r)

i φi Rφi

0 0 {r|x0 − r = xB , xB ∈ B, φ(xB) = 0}1 ∆φ {r|x0 − r = xB , xB ∈ B, φ(xB) = ∆φ}2 2∆φ {r|x0 − r = xB , xB ∈ B, φ(xB) = 2∆φ}

. . . . . . . . .

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 33 of 40

Analytical ShapesNon-analytical Shapes

Reference

The R-tableComposite ShapesIncrementation 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 animage, obtain r from the table and update A(x + r)

i φi Rφi

0 0 {r|x0 − r = xB , xB ∈ B, φ(xB) = 0}1 ∆φ {r|x0 − r = xB , xB ∈ B, φ(xB) = ∆φ}2 2∆φ {r|x0 − r = xB , xB ∈ B, φ(xB) = 2∆φ}

. . . . . . . . .

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 34 of 40

Analytical ShapesNon-analytical Shapes

Reference

The R-tableComposite ShapesIncrementation 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 correspondingvectors r and rotate them by θ

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 35 of 40

Analytical ShapesNon-analytical Shapes

Reference

The R-tableComposite ShapesIncrementation Strategies

Hough transform for composite shapes

Let a shape S have two subparts S1 and S2 with respectivereference points x0, x0

1, and x02

Compute r1 = x0 − x01 and r2 = x0 − x0

2

R-table for composite shape:Rs(φ) = [Rs1(φ) + r1]∪̇[Rs2(φ) + r2]

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 36 of 40

Analytical ShapesNon-analytical Shapes

Reference

The R-tableComposite ShapesIncrementation Strategies

Hough transform for composite shapes

Let a shape S have two subparts S1 and S2 with respectivereference points x0, x0

1, and x02

Compute r1 = x0 − x01 and r2 = x0 − x0

2

R-table for composite shape:Rs(φ) = [Rs1(φ) + r1]∪̇[Rs2(φ) + r2]

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 37 of 40

Analytical ShapesNon-analytical Shapes

Reference

The R-tableComposite ShapesIncrementation Strategies

Hough transform for composite shapes

Let a shape S have two subparts S1 and S2 with respectivereference points x0, x0

1, and x02

Compute r1 = x0 − x01 and r2 = x0 − x0

2

R-table for composite shape:Rs(φ) = [Rs1(φ) + r1]∪̇[Rs2(φ) + r2]

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 38 of 40

Analytical ShapesNon-analytical Shapes

Reference

The R-tableComposite ShapesIncrementation Strategies

Incrementation Strategies

Increment the accumulator by a value depending on thegradient: A(p) = A(p) + g(∇x)

Increment by larger values if neighbouring points areincrementing the same reference point

Try to find progressively longer connected segments usingdynamic programming

Weigh different parts of a composite object differently

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 39 of 40

Analytical ShapesNon-analytical Shapes

Reference

References

D. H. BallardGeneralizing the Hough Transform to Detect Arbitrary ShapesPattern Recognition, 13(2):111-122, 1981.

R. O. Duda and P. E. HartUse of the Hough Transformation to Detect Lines and Curvesin PicturesCommunications of Association for Computing Machinery,15(1):11-15, 1972.

CS658: Seminar on Shape Analysis and Retrieval Hough Transform 40 of 40