Professional Documents
Culture Documents
Chapter 6
Contents
Line fitting
• Hough Transform
• RANSAC (RANdom SAmple Consensus)
Department of Mechatronics
6-3 Chapter 6 – Fitting
Department of Mechatronics
6-4 Chapter 6 – Fitting
Department of Mechatronics
6-5 Chapter 6 – Fitting
Voting
• It’s not feasible to check all combinations of features by
fitting a model to each possible subset.
• Voting is a general technique where we let the features
vote for all models that are compatible with it.
– Cycle through features, cast votes for model parameters.
– Look for model parameters that receive a lot of votes.
• Noise & clutter features will cast votes too, but typically
their votes should be inconsistent with the majority of
“good” features.
• Ok if some features not observed, as model can span
multiple fragments.
Fitting Lines
• Given points that belong to a line,
what is the line?
• How many lines are there?
• Which points belong to which lines?
Department of Mechatronics
6-8 Chapter 6 – Fitting
b0
x m0 m
Image space Hough (parameter) space
Department of Mechatronics
6-9 Chapter 6 – Fitting
x0 x m
Image space Hough (parameter) space
• Connection between image (x,y) and Hough (m,b) spaces
– A line in the image corresponds to a point in Hough space.
– To go from image space to Hough space:
• Given a set of points (x,y), find all (m,b) such that y = mx + b
– What does a point (x0, y0) in the image space map to?
• Answer: the solutions of b = -x0m + y0
• This is a line in Hough space
Department of Mechatronics
6-10 Chapter 6 – Fitting
b = –x1m + y1
x0 x m
Image space Hough (parameter) space
• What are the line parameters for the line that contains both (x0,
y0) and (x1, y1)?
– It is the intersection of the lines b = –x0m + y0 and b = –x1m + y1
Department of Mechatronics
6-11 Chapter 6 – Fitting
x m
Image space Hough (parameter) space
Department of Mechatronics
6-12 Chapter 6 – Fitting
x cosθ + y sinθ = d
where 𝜃𝜃 ∈ [0, 𝜋𝜋) and d∈ R
Department of Mechatronics
6-14 Chapter 6 – Fitting
d
y
x θ
Image space edge coordinates Votes
Bright value = high vote count
Black = no votes
Department of Mechatronics
6-15 Chapter 6 – Fitting
Department of Mechatronics
6-16 Chapter 6 – Fitting
Department of Mechatronics
6-17 Chapter 6 – Fitting
Real-World Examples
Department of Mechatronics
6-18 Chapter 6 – Fitting
Department of Mechatronics
6-19 Chapter 6 – Fitting
d
y
x θ
Image space
Votes
edge coordinates
What difficulty does this present for an implementation?
Department of Mechatronics
6-20 Chapter 6 – Fitting
Department of Mechatronics
6-22 Chapter 6 – Fitting
Department of Mechatronics
6-23 Chapter 6 – Fitting
Department of Mechatronics
6-24 Chapter 6 – Fitting
RANSAC
RANSAC loop:
1. Randomly select a seed group of points on which to base
transformation estimate (e.g., a group of matches)
2. Compute transformation from seed group
3. Find inliers to this transformation
4. If the number of inliers is sufficiently large, re-compute
least-squares estimate of transformation on all of the
inliers
• Keep the transformation with the largest number of
inliers
Department of Mechatronics
6-25 Chapter 6 – Fitting
Department of Mechatronics
6-26 Chapter 6 – Fitting
Sample two
points
Department of Mechatronics
6-27 Chapter 6 – Fitting
Department of Mechatronics
6-28 Chapter 6 – Fitting
Total number of
points within a
threshold of line.
Department of Mechatronics
6-29 Chapter 6 – Fitting
“7 inlier points”
Total number of
points within a
threshold of line.
Department of Mechatronics
6-30 Chapter 6 – Fitting
Department of Mechatronics
6-31 Chapter 6 – Fitting
Department of Mechatronics
70
6-32 Chapter 6 – Fitting
Department of Mechatronics
6-33 Chapter 6 – Fitting
Department of Mechatronics
6-34 Chapter 6 – Fitting
2 2 3 5 6 7 11 17
3 3 4 7 9 11 19 35
4 3 5 9 13 17 34 72
5 4 6 12 17 26 57 146
6 4 7 16 24 37 97 293
7 4 8 20 33 54 163 588
8 5 9 26 44 78 272 1177
Department of Mechatronics
6-35 Chapter 6 – Fitting
After RANSAC
• RANSAC divides data into inliers and outliers and yields
estimate computed from minimal set of inliers.
• Improve this initial estimate with estimation over all
inliers (e.g. with standard least‐squares minimization).
• But this may change inliers, so alternate fitting with
re-classification as inlier/outlier.
Department of Mechatronics
6-36 Chapter 6 – Fitting
Department of Mechatronics
6-37 Chapter 6 – Fitting
Image space
Dana H. Ballard, Generalizing the Hough Transform to Detect Arbitrary Shapes, 1980
Department of Mechatronics
6-38 Chapter 6 – Fitting
Department of Mechatronics
6-39 Chapter 6 – Fitting
Model shape
Department of Mechatronics
6-40 Chapter 6 – Fitting
Displacement vectors
for model points
Department of Mechatronics
6-41 Chapter 6 – Fitting
Range of voting
locations for test point
Department of Mechatronics
6-42 Chapter 6 – Fitting
Range of voting
locations for test point
Department of Mechatronics
6-43 Chapter 6 – Fitting
Department of Mechatronics
6-44 Chapter 6 – Fitting
Displacement vectors
for model points
Department of Mechatronics
6-45 Chapter 6 – Fitting
Range of voting
locations for test point
Department of Mechatronics
6-46 Chapter 6 – Fitting
Department of Mechatronics
6-47 Chapter 6 – Fitting
Extensions
Department of Mechatronics
6-48 Chapter 6 – Fitting
Extensions
Extension 2
– Give more votes for stronger edges (use magnitude of gradient)
Extension 3
– Change the sampling of (d,θ ) to give more/less resolution
Extension 4
– The same procedure can be used with circles, squares, or any other
shape…
Department of Mechatronics
6-49 Chapter 6 – Fitting
Department of Mechatronics
6-50 Chapter 6 – Fitting
Department of Mechatronics
6-51 Chapter 6 – Fitting
Department of Mechatronics
6-52 Chapter 6 – Fitting
Department of Mechatronics
6-56 Chapter 6 – Fitting
b
a
Image space Hough space
Department of Mechatronics
6-57 Chapter 6 – Fitting
Department of Mechatronics
6-58 Chapter 6 – Fitting
Department of Mechatronics
6-59 Chapter 6 – Fitting
Department of Mechatronics
6-60 Chapter 6 – Fitting