Upload
dinhmien
View
222
Download
0
Embed Size (px)
Citation preview
Alper Yilmaz, Mubarak Shah, Fall 2011 UCF
CAP 5415 Computer VisionFall 2013
Hough TransformLecture-17Sections 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
cmxy
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
cmxfcmxy ,,
i
ii cmxfyE 2,, Minimize
Take derivatives wrt m and c set them to 0Alper Yilmaz, Mubarak Shah, Fall 2011
UCF
Line Fitting
cmxy
cmxy
cmxycmxy
nn
22
11
D
A
n
B
n
cm
x
xx
y
yy
1111
2
1
2
1
ADB
BAAAD
DAAAABAAA
ADABA
TT
TTTT
TT
1
11
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 line2. 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 ycmcmxy
ymxc )(
ii ymxc )(
Line Fitting: Hough Transform
Alper Yilmaz, Mubarak Shah, Fall 2011 UCF
ii ymxc )(
Hough Transform Algorithm for Fitting Straight Lines
Alper Yilmaz, Mubarak Shah, Fall 2011 UCF
Polar Form of Equation of Line
sincos yxp
Alper Yilmaz, Mubarak Shah, Fall 2011 UCF
Problematic for vertical linesm and c grow to infinity
ymxc ji )(
Use from gradient
Image Gradient
Alper Yilmaz, Fall 2004 UCF
x
y
yx
yx
SS
SS
SS
1
22
tan
)(
),(
direction
magnitude
VectorGradient yx ,
yx ,
yx ,
Hough Transform for Polar Form of Equation of Line
Alper Yilmaz, Mubarak Shah, Fall 2011 UCF
Line Fitting
p
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 lineof 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 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: x0, y0, r
Fix one of the parameters and loop for the others Increment corresponding entry in A. Find the local maxima in A
0)()( 222 ryyxx oo
Alper Yilmaz, Mubarak Shah, Fall 2011 UCF
More Practical Circle Fitting
Use the tangent direction at the edge point
Compute x0, y0 given x, y, r
sincos
0
0
ryyrxx
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
(xo,yo)
(x,y)
0
0
yyxx
yx
r
Alper Yilmaz, Mubarak Shah, Fall 2011 UCF
Generating R-table
(xo,yo)
(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 – R-table of the shape needs to be determined
For each edge point find 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
cossinsincos
yxyyxx
syysxx
cossinsincos
yxsyyxsx
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