Sei sulla pagina 1di 34

Alper Yilmaz, Mubarak Shah, Fall 2011

UCF
CAP 5415 Computer Vision
Fall 2012
Hough Transform
Lecture-18
Sections 4.2, 4.3 Fundamentals
of Computer Vision
Image Feature Extraction
Edges (edge pixels)
Sobel, Roberts, Prewit
Laplacian of Gaussian
Canny
Interest Points
Harris
SIFT
Descriptors
SIFT
HOG
Alper Yilmaz, Fall 2004 UCF
Shape Features
Straight Lines
Circles and Ellipses
Arbitrary Shapes
Alper Yilmaz, Fall 2004 UCF
How to Fit A Line?
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
c mx y + =
How to Fit A Line?
Least squares Fit (over constraint)
RANSAC (constraint)
Hough Transform (under constraint)
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
Least Squares Fit
Standard linear solution to estimating
unknowns.
If we know which points belong to which line
Or if there is only one line
( ) c m x f c mx y , , = + =
( ) | |

=
i
i i
c m x f y E
2
, , Minimize
Take derivatives wrt m and c set them to 0
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
Line Fitting
c mx y + =
c mx y
c mx y
c mx y
n n
+ =
+ =
+ =

2 2
1 1

D
A
n
B
n
c
m
x
x
x
y
y
y
(

(
(
(
(

=
(
(
(
(



1
1
1
1
2
1
2
1
AD B=
( ) ( ) ( )
( ) B A A A D
D A A A A B A A A
AD A B A
T T
T T T T
T T
1
1 1


=
=
=
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
RANSAC: Random Sampling and
Consensus
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
1. Randomly select two points to fit a line
2. Find the error between the estimated solution and all
other points. If the error is less than tolerance, then
quit, else go to step (1).
Line Fitting: Segmentation
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
Several Lines
How do we Know which points belong to
which lines?
Hough Transform
METHOD AND MEANS FOR
RECOGNIZING COMPLEX PATTERNS,
Paul V. C. Hough et al
Inventors: Paul V. C. Hough, Paul V. C. Hough
Current U.S. Classification: 382/281; 342/176;
342/190; 382/202
http://www.google.com/patents?vid=3069654
Alper Yilmaz, Fall 2004 UCF
Line Fitting: Hough Transform
Alper Yilmaz, Mubarak Shah, Fall
2011 UCF
Line equation
Rewrite this equation
For particular edge point i this becomes
This is an equation of a line in (c,m) space.
intercept - is slope, is y c m c mx y + =
y m x c + = ) (
i i
y m x c + = ) (
Line Fitting: Hough Transform
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
i i
y m x c + = ) (
Hough Transform Algorithm for
Fitting Straight Lines
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
Polar Form of Equation of Line
u u sin cos y x p + =
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
Problematic for vertical lines
mand c grow to infinity
y m x c
j i
+ = ) (
Use from gradient u
Image Gradient
Alper Yilmaz, Fall 2004 UCF
x
y
y x
y x
S
S
S S
S S
1
2 2
tan
) (
) , (

= =
+ =
u direction
magnitude
Vector Gradient
( ) y x
' '
,
( ) y x,
( ) y x
' ' ' '
,
Hough Transform for Polar Form
of Equation of Line
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
Line Fitting
p
u
Alper Yilmaz, Mubarak Shah, Fall
2011 UCF
Line Fitting
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
Line Fitting Examples
noisy
ideal
very noisy
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
Noise Factor
This is the number of
votes that the real line
of 20 points gets with
increasing noise
Noise Factor
as the noise increases in
a picture without a line,
the number of points in
the max cell goes up, too
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
Difficulties
What is the increments for u and p.
too large? We cannot distinguish between
different lines
too small? noise causes lines to be missed
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
Circle Fitting
Similar to line fitting
Three unknowns
Construct a 3D accumulator array A
Dimensions: x
0
, y
0
, r
Fix one of the parameters and loop for the others
Increment corresponding entry in A.
Find the local maxima in A
0 ) ( ) (
2 2 2
= + r y y x x
o o
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
More Practical Circle Fitting
Use the tangent direction u at the edge point
Compute x
0
, y
0
given x, y, r
u
u
u
sin
cos
0
0
r y y
r x x
=
=
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
Alper Yilmaz, Fall 2004 UCF
Examples
Generalized Hough Transform
Used for shapes with no analytical expression
Requires training
Object of known shape
Generate model
R-table
Similar approach to line and circle fitting during
detection
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
Generating R-table
Compute centroid
For each edge compute its distance
to centroid
Find edge orientation (gradient angle)
Construct a table of angles and r
values
(x
o
,y
o
)
(x,y)
(

=
(

'
'
=
0
0
y y
x x
y
x
r
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
Generating R-table
(x
o
,y
o
)
(x,y)
(x,y)
1
2
1
2
3
4
r1, r2, r3
r14, r21, r23
r41, r42, r33
r10, r12, r13
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
r1
Detecting shape
known
Edge points (x,y)
Gradient angle at every edge point u
R-table of the shape needs to be determined
For each edge point find u store it in
corresponding row of R-table
Create an accumulator array of 2D (x,y)
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
Rotation and Scale Invariance
Rotation around Z-axis
Scaling
Rotation+scaling
o o
o o
cos sin
sin cos
y x y
y x x
+ =
'
=
'
sy y
sx x
=
'
=
'
( )
( ) o o
o o
cos sin
sin cos
y x s y
y x s x
+ =
'
=
'
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
Rotation and Scale Invariance
Replace equations 4.13 and 4.14 in
Algorithm 4.8 by following and loop for scale
and rotation angles.
Alpr Yilmaz, Mubarak Shah, Fall 2011 UCF
Alper Yilmaz, Mubarak Shah, Fall 2011
UCF

Potrebbero piacerti anche