0% found this document useful (0 votes)
5 views

Lec 8

The Hough Transform is a technique used to detect lines and curves in 2-D images by transforming points in image space to a parameter space where lines can be identified as intersections of curves. It involves quantizing the parameter space, accumulating votes for potential lines based on edge pixels, and identifying peaks in the accumulator array to determine the presence of lines. While effective for detecting straight lines and simple shapes, it can struggle with noise and complex shapes, leading to spurious peaks and increased computational complexity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Lec 8

The Hough Transform is a technique used to detect lines and curves in 2-D images by transforming points in image space to a parameter space where lines can be identified as intersections of curves. It involves quantizing the parameter space, accumulating votes for potential lines based on edge pixels, and identifying peaks in the accumulator array to determine the presence of lines. While effective for detecting straight lines and simple shapes, it can struggle with noise and complex shapes, leading to spurious peaks and increased computational complexity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

HOUGH TRANSFORM

CS 6350

CV
HOUGH TRANSFORM

The problem:

Given a set of points in 2-D, find


if a sub-set of these points
points,
fall on a LINE.
Hough Transform

One powerful global method for detecting edges (lines and


parametric curves) is called the Hough transform.

Let us suppose that we are looking for straight lines in an


image. If we take a point (x',y') in the image, all lines which pass
through that pixel have the form
y' = m x' + c

for varying values of m and c. See Figure below:


However, this equation can also be written as

c = -x'' m + y''

where,, we now consider x' and y


y' to be constants,, and m and c as
varying.

This is
Thi i a straight
t i ht line
li on a graph
h off c against
i t m as shown
h in
i
Figure below:

Each different line through the point (x', y') corresponds to one
of the points on the line in (m, c) space (termed as Hough space).
Now consider two pixels p and q in (x, y) space which lie on the
same line.

• For each pixel, all of the possible lines through it are represented
by
y a single
g line in (m,
( , c)) space.
p

• Thus the single line in (x, y) space which goes through both pixels
li on th
lies the iintersection
t ti off the
th two
t li
lines representing
ti p and
d q in
i (m,
( c))
space, as illustrated by Figure

Identify the point <--> line correspondences interchangeably


between these two spaces: Spatial coordinate and parametric (Hough).
However, this equation can also be written as

c = -x'' m + y''
where, we now consider x' and y' to be constants, and m and c as
varying.
y g

This is a straight line on a graph of c against m as shown in


Fi
Figure below:
b l

Each different line through the point (x', y') corresponds to one
of the points on the line in (m, c) space (termed as Hough space).
Taking this one step further,

 All pixels
i l which
hi h lie
li on the
th same line
li ini (x,
( y)) space are
represented by lines which all pass through a single point in
((m,, c)) space.
p

 The single point through which they all pass gives the values of
m and
d c in
i the
th equation
ti off the
th line:
li y = m x + c.

p to detect straight
The steps g lines in an image:
g

1. Quantize (m, c) space into a two-dimensional array A for


appropriate
i t steps
t off m and
d c.

2. Initialize all elements of A(m,


( , c)) to zero.

3. For each pixel (x', y') which lies on some edge in the image, we
add
dd 1 to
t allll elements
l t off A(m,
A( c)) whose
h indices
i di m and
d c satisfy
ti f
y' = m x' + c.

Search for elements of A(m, c) which have large values -- Each


one found corresponds to a line in the original image.
One useful property of the Hough transform is that the pixels,
which lie on the line, need not all be contiguous.

For example,
example all of the pixels lying on the two dotted lines in
Figure below, will be recognized as lying on the same straight line. This
can be very useful when trying to detect lines with short breaks in them
due to noise, or when objects are partially occluded as shown below:
Drawback: The figure above clearly demonstrates one disadvantage
of the Hough transform method
method. It gives an infinite line as expressed by
the pair of m and c values, rather than a finite line segment with two well-
defined endpoints.

One practical difficulty is that, the y = m x + c form for


representing a straight line breaks down for vertical lines
lines, when m
becomes infinite.

To avoid this problem, it is better to use the alternative formulation


as given below:
x cos  + y sin  = 
To avoid this problem, it
is better to use the alternative
formulation as given below:

x cos  + y sin  = 

What is the output


p in the
parametric ( space ??
Note, however, that a point in (x, y) space is now represented by a curve
in () space rather than a straight line. Otherwise, the method is
unchanged.
h d
Two points in (x, y) space will now be represented by
two different curves in () space rather than straight lines.
The intersection corresponds to the parameters of the line in (x (x, y)
space, formed by joining those two points.

Find similarity with Radon Transform


Point Features Votes
Algorithm for HT
• IInitialize
iti li allll accumulator
l t cells
ll
in H to Zeros
• For each edge pixel (x,y)
i image
in i
For θ = -90 to 90 ρ
ρ = x cos θ + y sin θ
++ H(iθ, jρ);
end
θ
endd
• Find the value(s) of (θ, ρ)s, where H(iθ, jρ)s
are local maxima.
– D
Detected
t t d li
line(s)
( ) in
i the
th image
i are obtained
bt i d using:
i
ρk = x cos θk + y sin θk
For each data point, a number of lines are plotted going
through it, all at different angles. These are shown as solid lines.
For each solid line draw a line perpendicular to it from the
origin. These are shown as dashed lines.
The length and angle of each dashed line is measured. The
results are shown in tables. This is repeated for each data point.
A graph of length (R or Dist.) against angle, known as a Hough
space graph,
graph is then created
created.
A case of implementation
with three points:

< -- Construct an
R-table from here
Presence of noise

Features Votes

• Peak
P k gets
t fuzzy
f and
d hard
h d to
t locate
l t
Random Noise

Features Votes

• Noise produces spurious peaks


in the accumulator array/R-table
Case of two
thick lines
Original
g g
Edge Detected
Image Detection Lines

Parameter
Space
In the Hough transform, feature points vote for all
possibilities through that point. This can cause
unwanted
t d clutter
l tt in
i the
th accumulator
l t and
d produce
d false
f l
matches/alarms (take large gradient edges only).

Suppose that after we find the global maximum we


remove all votes cast by
y feature points
p on or near the
corresponding match in the image space.

We can then continue the process by looking for


the next largest global maximum, remembering it, and
removing the votes from its points.
points
Operational
p tradeoffs for the
Hough transform
Issue of Resolution/Quantization of Accumulator cells:

How big should the CELLS be?

• Too big - large votes obtained when too many


different lines correspond to a single bucket and we
merge quite different lines;

• Too small - miss lines, because some points that


are not exactly collinear cast votes for different
buckets; problem becomes adverse with noise.
Additional p
processing
g to create
robustness in Hough transform
Post-processing steps:
A H
A. How many lines?
li ?
- Count the peaks in the Hough array
- Treat adjacent peaks as a single peak
- Smooth array, threshold and thin isolated
clusters of bright spots

B Which points belong to each line?


B.
- Search for points close to the line
- Solve again for line (use edge orientation)
and iterate
- Use a coarse to fine strategy
Other shapes
Square Circular

?
Hough Transform for Parametric Curves
The Hough transform is not restricted to detecting
straight lines, though that is a common use. The Hough
transform can be used to detect other type of curves in an
image as well as straight lines. Other geometrical shapes
that can be described with a few parameters are also well
suited to it.
it
The Hough transform can be used to detect other type of
curves in an image as well as straight lines.
lines
For example, if we wish to find circles, with equation:
(x - a)2 + (y - b)2 = R2
Then,
A circle is specified with three parameters:
the X and Y coordinates of its centre (a & b), and R, its
radius.
radius
To find circles using a Hough transform, you need a
three-dimensional accumulator array.
array Each Point in 2-D
space yields (in 3-D Hough space) a: CONE
Each edge element votes for all the circles that it could lie on,
and the 3-D array is searched for peaks that give circle positions and
radii.
dii If you happen
h to
t know
k the
th radius
di ini advance,
d you onlyl needd a 2-D
2D
accumulator.

Then,
 Every point in (x, y) space corresponds to a
s rface in (a,
surface (a b,
b r) space ((we
e can vary
ar an
any ttwo
o of the
parameters a, b and r, the third is determined by the
equation
q of the circle).
)

 The basic method is, thus, modified to use a three-dimensional


H
Hough
h Space
S (3-D
(3 D array)) A(a,
A( b,b r).
)

 All p
points in it,, which satisfy
y the equation
q for a circle,, are
incremented.
Use of Gradient information at each p
pixel (edge),
( g ), converts the
problem to a 2-D problem (1-D search).

Th Conical
The C i l surface
f in
i Hough
H h space gets
t transformed
t f d to
t a:
LINE
Use of Gradient information at each pixel (edge), converts the
problem to a 2-D
2 D problem (1-D
(1 D search).

The Conical surface in Hough space gets transformed to a:

LINE

r(θ)
More complicated shapes can be found - a general ellipse, for
example needs a 5-D parameter space
example, space.

So the method is really useful for simple and parametric


curves. The concept of Hough space has been used in many other
applications, wherever there is a scope of a search in multi-
dimensional space.
space

G ((X,, C)) = 0

In practice, the technique takes rapidly increasing amounts of


ti
time for
f more complicated
li t d curves as the
th number
b off variables
i bl (and
( d
hence the number of dimensions of the array A) increases. The two
other factors on which the time complexity depends are:

• the level of discretization (higher value necessary for


more accuracy)

• number of feature points present in the input


The Generalized Hough Transform, introduced by D.H.
Ballard in 1981, was a modification of the Hough Transform
using the principle of template matching.
matching

This modification enables the Hough g Transform to be


used not only to detect an object described with an analytic
equation (e.g. line, circle, etc), but also to detect an
arbitrary object described with its model.
model

The p
problem of finding
g the object
j (
(described with a
model) in the image can be solved by finding the model's
position in the image.

In the Generalized Hough Transform, the problem of


finding
g the model's p
position is transformed into a p
problem of
finding the transformation parameter that maps the model
onto the image.

^[1]
[ ] D.H. Ballard,, "Generalizing
g the Hough
g Transform to
Detect Arbitrary Shapes", Pattern Recognition, Vol.13, No.2,
p.111-122, 1981.
Generalized
Ge e a ed Hough
oug ttransform
a s o
• We want to find a shape
p defined byy its
boundary points and a reference point
• For every boundary point p, we can compute
the displacement vector:
r = a – p as a
function of
gradient orientation θ a

θ r(θ)
( )
R-table
R table may have
p
multiple entries for each 
• For model shape: construct a R-table storing displacement
vectors
t r as function
f ti off gradient di ti 
di t direction 
• Detection: For each edge point p with gradient orientation θ:
– Retrieve all r indexed with θ
– For each r(θ), put a vote in the Hough space at p + r(θ)

• Peak in this Hough space is the reference point with most


supporting edges (only translation invariant in 2-D).

• For scale and orientation invariance,


invariance first construct
additional tables for all plausible discrete values of and s;
as Ts [R()] andd [R(
[R( hen
h vote t for
f :
p + r(θ,s)
4-D Hough space for GHT: S  {a,  , s}

where a = (xa, ya) denotes a reference origin for the shape, the shape's
orientation, and “s” is a scalar scalingg factor.
Hough transform: +ves
• All points are processed
independently, so can cope with
occlusion
l i

• Some robustness to noise: noise


points
i t unlikely
lik l to
t contribute
t ib t
consistently
y to any
y single
g bin

• Can
C detect
d t t multiple
lti l instances
i t off a
model in a single
g p pass
Hough transform: -ves
ves
• Complexity of search time increases
p y with the number of model
exponentially
parameters

• Non-target shapes can produce spurious


peaks in parameter space

• It’s hard to pick a good grid size

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy