06 Hough Transform (Cont. Chpter 10)
06 Hough Transform (Cont. Chpter 10)
06 Hough Transform (Cont. Chpter 10)
Hough Transform
Section: 10.2.7
2
Fitting
• Want to associate a model with observed features
3
Why lines? Because they are usually good features to
detect objects. Why not use the way we did earlier
Example: Line fitting with kernels? Because it was too noisy and unreliable.
It in fact only fits for being a pre-processing step.
• Why fit lines?
Many objects characterized by presence of straight lines
5
Hough Transform is a voting technique.
Voting
• It’s not feasible to check all combinations of features by
fitting a model to each possible subset.
• Noise & clutter features will cast votes too, but typically
their votes should be inconsistent with the majority of
“good” features.
6
Fitting lines: Hough transform
• Given points that belong to a line, what is the line?
• How many lines are there?
• Which points belong to which lines?
7
Finding lines in an image: Hough space
y b
b0
x m0 m
image space Hough (parameter) space
x0 x m
image space Hough (parameter) space
• What does a point (x0, y0) in the image space map to?
b = –x1m + y1
x0 x m
image space Hough (parameter) space
x m
image space Hough (parameter) space
How can we use this to find the most likely parameters (m,b) for
the most prominent line in the image space?
• Let each edge point in image space vote for a set of possible
parameters in Hough space
• Accumulate votes in discrete set of bins; parameters with the
most votes indicate line in image space.
The size of the bins determines how much approximation in the fitted line 11
will be tolerated. Smaller = less tolerance, more accurate line detection.
Another hyper-parameter is the threshold number of votes to accept a line
Shown below is one possible line that the given point could be passing through.
Below I go through deriving how to represent that line in polar coordinates eqn.
Image columns
𝑥 cos 𝜃 𝑦 sin 𝜃 𝑑
𝑥
[0,0]
𝜃 𝑑 : perpendicular distance from line to origin
𝜃 : angle the perpendicular makes with the x-axis
Image rows
d
Basic Hough transform algorithm
1. Initialize H[d, ]=0
2. for each edge point I[x,y] in the image
for = [min to max ] // some quantization
𝑑 𝑥 cos 𝜃 𝑦 sin 𝜃
H[d, ] += 1
3. Find the value(s) of (d, ) where H[d, ] is maximum
4. The detected line in the image is given by
𝑑 𝑥 cos 𝜃 𝑦 sin 𝜃
15
Kristen Grauman
Showing longest segments found
16
Kristen Grauman
Impact of noise on Hough
y d
x
19
Hough transform for circles
• Circle: center (a,b) and radius r
𝑥 𝑎 𝑦 𝑏 𝑟
• For a fixed radius r, unknown gradient direction Each point becomes a circle
Intersection:
most votes for
center occur
here.
b
a
Image space Hough space
Kristen Grauman
24
Example: detecting circles with Hough
Original Edges Votes: Penny
Note: a different Hough transform (with separate accumulators) was used for each circle
radius (quarters vs. penny).
27
Example: detecting circles with Hough
Combined detections
Original Edges Votes: Quarter
29
Example: iris detection
• An Iris Detection Method Using the Hough Transform and Its Evaluation for Facial and
Eye Movement, by Hideki Kashima, Hitoshi Hongo, Kunihito Kato, Kazuhiko Yamamoto,
ACCV 2002.
30
Hough transform: pros and cons
Pros
• All points are processed independently, so can cope with
occlusion, gaps
• Some robustness to noise: noise points unlikely to
contribute consistently to any single bin
• Can detect multiple instances of a model in a single pass
Cons
• Complexity of search time increases exponentially with
the number of model parameters aka dimensions
• Non-target shapes can produce spurious peaks in
parameter space
• Quantization: can be tricky to pick a good grid size
31
Let's say we have the two points in some random model, blue
and green, and we characterize their positions w.r.t. the
arbitrarily chosen ref. point via displacement vectors to it such
that for new images, we apply the displacement vectors to all
points in these images and if the ends of their displacement
Generalized Hough Transform vectors meet (or are close enough to each other), its correct!
Intuition:
Displacement
x
vectors xx
Ref. point x
x
Model image Novel image Vote space
Offline procedure:
a
At each boundary point,
x
θ θ
compute displacement
p1 p2
vector: r = a – pi.
Model shape
Store these vectors in a
θ …
table indexed by
θ … gradient orientation θ.
…
33
[Dana H. Ballard, Generalizing the Hough Transform to Detect Arbitrary Shapes, 1980]
θ …
…
34
Assuming translation is the only transformation here, i.e., orientation and scale are fixed.
Summary
• Fitting problems require finding any supporting evidence for a
model, even within clutter and missing features.
• associate features with an explicit model
37