You are on page 1of 6

Hough Transform

Documentation for Hough Transform for shape detection.

Aleksandra Joanna Wiśniewska


August 12, 2004

Contents
1 Introduction 2

2 The Mathematical basis [1] 2

3 Implementation in Matlab 3

4 Tests 5

5 Summary 6

1
1 INTRODUCTION 2

1 Introduction
The main task of my Vision System is to properly classify objects. In real-time
systems like an autonomous robot a good answer is not enough, the responde
time is as important. In situations where next motion depends on picture recog-
nition, a fast algorithm is necessary. There is place for Hough Transform. It’s
simplicity makes it so interesting.

2 The Mathematical basis [1]


We can describe a straight line as a function y = f (x) in co-ordinate system:

y =a·x+b (1)

where a is the direction coefficient of the straight, and b is the displacement


from the center of the co-ordinate system. There is also another way in Hesse’s
normal form:

~n · (~x − ~a) = 0 (2)


where ~n is the unit vector, ~x is the line vector and ~a is the follow vector as we
see in the Figure 1.

Figure 1: Hesse’s normal form

for:

~a = ρ · ~n (3)
we have:

~n · (~x − ρ · ~n) = 0 (4)


3 IMPLEMENTATION IN MATLAB 3

when |~n| = 1 we have from the triangle dependence:


µ ¶
cos θ
~n = (5)
sin θ
Vector ~x we can write as:
µ ¶
x
~x = (6)
y
From (5), (6) → (4) :
µ ¶ õ ¶ µ ¶!
cos θ x cos θ
· −ρ· =0 (7)
sin θ y sin θ

x · cos θ + y · sin θ − ρ = 0 (8)


Equation (8) is the basis of the Hough transform.

Hough space is spanned through ρ and θ. In this space a straight is identifi-


able as a point (ρ, θ)

3 Implementation in Matlab
We have a picture (value=1 is background) and a black straight (value=0 is an
object).

Figure 2: Straight line in xy - space

We know neither θ nor ρ. For every point in the line we compute all possible
straights, that can cross this point. And for every pair of (θ, ρ) we increment the
value the in Hough space in co-ordinates for this pair. All curves derived from
one straight meet in one point. This point has the biggest value; it describes
ours line.
3 IMPLEMENTATION IN MATLAB 4

Figure 3: Straight line in Hough space

On Figure 2 values of Hough space accumulators are shown. It’s evaluation


of hough.m function. The brightest point describes parameters of the line found.
To find this point we look for local maxima. For shape detection we analyze all
local maxima.

Figure 4: The original photo, Hough accumulator and reproduction of straights


found

Figure 4 shows how the algorithm works in the case of numerous lines.
4 TESTS 5

4 Tests
The following figures (made with script: houghtest.m) show how the algorithm
works for basic shapes. All source files are after edge detection (see Picture
Processing in Matlab documentation):

As we see the transform cannot recognize a horizontal line. The last figure
shows the results for a real photo:
5 SUMMARY 6

5 Summary
Hough transformation finds straight lines in a picture in an easy way with
this algorithm we can detect figures; with a specific shapes and angles. It is
independent from scale. It can be useful also in finding shapes in a room with
many other objects.

References
[1] Constantin Christmann, Proseminar Computervision: Geradenbestimmung
mit der Hough-Transformation
[2] R.Steinbrecher Bilverarbeitung in der Praxis
[3] Matlab Help

You might also like