Title: Hough Tranform
1Hough Tranform
Lecture 12
2Hough Transform
- Elegant method for direct object recognition
-
- Edges need not be connected
- Complete object need not be visible
- Key Idea Edges VOTE for the possible model
3Line detection
- Mathematical model of a line
Y mx n
Y1m x1n
Y2m x2n
P(x1,y1)
P(x2,y2)
YNm xNn
4Image and Parameter Spaces
Y mx n
Image Space
Line in Img. Space Point in Param. Space
5Image space
Fix (m,n), Vary (x,y) - Line
Y mx n
Fix (x1,y1), Vary (m,n) Lines thru a Point
Y1m x1n
P(x1,y1)
6Parameter space
Y1m x1n
Can be re-written as
n -x1 m Y1
Fix (-x1,y1), Vary (m,n) - Line
n -x1 m Y1
7Img-Param Spaces
- Image Space
- Lines
- Points
- Collinear points
- Parameter Space
- Points
- Lines
- Intersecting lines
8Hough Transform Technique
- Given an edge point, there is an infinite number
of lines passing through it (Vary m and
n). - These lines can be represented as a line in
parameter space.
9Hough Transform Technique
- Given a set of collinear edge points, each of
them have associated a line in parameter space. - These lines intersect at the point (m,n)
corresponding to the parameters of the line in
the image space.
10n (-x1) m y1
y
n (-x2) m y2
p
q
P(x1,y1)
Q(x2,y2)
x
11Hough Transform Technique
- At each point of the (discrete) parameter space,
count how many lines pass through it. - Use an array of counters
- Can be thought as a parameter image
- The higher the count, the more edges are
collinear in the image space. - Find a peak in the counter array
- This is a bright point in the parameter image
- It can be found by thresholding
12Practical Issues
- The slope of the line is -?ltmlt?
- The parameter space is INFINITE
- The representation y mx n does not express
lines of the form x k
13Solution
Y mx n
? x cos?y sin?
? - Is the line orientation
? - Is the distance between the origin and the
line
?
?
14New Parameter Space
- Use the parameter space (?, ?)
- The new space is FINITE
- 0 lt ? lt D , where D is the image diagonal.
- 0 lt ? lt ?
- The new space can represent all lines
- Y k is represented with ? k, ?90
- X k is represented with ? k, ?0
15Consequence
- A Point in Image Space is now represented as a
SINUSOID - (x,y) ? ? x cos?y sin?
16Image space
Votes Horizontal axis is ?, vertical is ?.
17Image space
votes
18(No Transcript)
19- Basic Hough transform algorithm
- Initialize Hd, ?0
- For each edge point Ix,y in the image
- for ? 0 to 180
- Hd, ? 1
- Find the value(s) of (d, ?) where Hd, ? is
maximum - The detected line in the image is given by
20Hough Transform Algorithm
- Input edge image (E(i,j)1 for edgels)
- Discretize ? and ? in increments of d? and d?.
Let A(R,T) be an array of integer accumulators,
initialized to 0. - For each pixel E(i,j)1 and h1,2,T do
- ? i cos(h d? ) j sin(h d? )
- Find closest integer k corresponding to r
- Increment counter A(h,k) by one
- Find local maxima in A(R,T)
21Hough Transform Speed Up
- If we know the orientation of the edge usually
available from the edge detection step - We fix ? in the parameter space and increment
only one counter! - For each pixel E(i,j)1 compute
- ? i cos(? ) j sin(? )
- Find closest integer k corresponding
to r - Increment counter A(h,k) by one
22- Extension
- give more votes for stronger edges
Difficulties how big should the cells be? (too
big, and we merge quite different lines too
small, and noise causes lines to be missed)
23Image Transforms - Hough Transform
24Real World Example
Original
Found Lines
Edge Detection
Parameter Space
25????? ?????
????? ????? ???????
???? ?????? ?????? ?? ??????
26Finding Circles by Hough Transform
Equation of Circle
If radius is known
(2D Hough Space)
Accumulator Array
27Finding Circles by Hough Transform
Equation of Circle
If radius is not known 3D Hough Space! Use
Accumulator array
28Using Gradient Information
- Gradient information can save lot of
computation
Edge Location Edge Direction
Assume radius is known
Need to increment only one point in Accumulator!!
29Finding Coins
Original
Edges (note noise)
30Finding Coins (Continued)
Penny
Quarters
31Finding Coins (Continued)
Note that because the quarters and penny are
different sizes, a different Hough transform
(with separate accumulators) was used for each
circle size.
Coin finding sample images from Vivek Kwatra
32Hough Transform for Curves
- The H.T. can be generalized to detect any curve
that can be expressed in parametric form - Y f(x, a1,a2,ap)
- a1, a2, ap are the parameters
- The parameter space is p-dimensional
- The accumulating array is LARGE!
33Generalizing the H.T.
The H.T. can be used even if the curve has not a
simple analytic form!
- Pick a reference point (xc,yc)
- For i 1,,n
- Draw segment to Pi on the boundary.
- Measure its length ri, and its orientation ai.
- Write the coordinates of (xc,yc) as a function of
ri and ai - Record the gradient orientation fi at Pi.
- Build a table with the data, indexed by fi .
xc xi ricos(ai)
yc yi risin(ai)
34H.T. Summary
- H.T. is a voting scheme
- points vote for a set of parameters describing a
line or curve. - The more votes for a particular set
- the more evidence that the corresponding
curve is present in the image. - Can detect MULTIPLE curves in one shot.
- Computational cost increases with the number of
parameters describing the curve.