Computer Vision - Hough Transform
Computer Vision - Hough Transform
3/13/2023 Le Thanh Ha 2
Parameter function
• Object in image can be defined by a function of parameter
(parameter function):
f (x, y, a1, · · · , an) = 0
In which (x,y) is pixel position and {a1, · · · , an} is a set of n
parameters specifying the shape.
3/13/2023 Le Thanh Ha 3
Hough transform
• Transform to parameter space:
– Every pixel (x,y) in a 2D image is transformed into a surface of n-
dimension space.
3/13/2023 Le Thanh Ha 4
Line detection
• Parameter function to be used:
y = ax + b
- It is a line in Image
- But, it is only a point (a,b) in parameter space.
3/13/2023 Le Thanh Ha 5
Line Detection
• A point (x0,y0) I corresponds to the line a = y0/x0 - b/x0 in the
parameter space P.
3/13/2023 Le Thanh Ha 6
Line detection
• Construct the line function of following image by hough
transform:
3/13/2023 Le Thanh Ha 7
Line detection
• Another line function can be used:
in which ρ0 là is the distance between line and the origin, and θ0 là is the angle
between the distance vector and Ox axis.
3/13/2023 Le Thanh Ha 8
Line detection algorithm
• Create a 2D matrix H(ρ, θ) for the parameter space. Initialize the matrix
with 0 values.
• For pixel (x,y) satisfies |G(x,y)| > Ts, increase H(ρ, θ) such that:
3/13/2023 Le Thanh Ha 9
Line detection algorithm
3/13/2023 Le Thanh Ha 10
Line detection
3/13/2023 Le Thanh Ha 11
Line detection
3/13/2023 Le Thanh Ha 12
Line detection
3/13/2023 Le Thanh Ha 13
Circle detection
• A circle with radius R at position (a,b) can be specified by a
function:
3/13/2023 Le Thanh Ha 14
Circle detection
• With a fixed radius R, (a,b) has a circle orbit centered at (x,y) and radius R.
• The coordinate of the real cirle can be found by a cummulative table
3/13/2023 Le Thanh Ha 15
Circle Detection
• For pixel (x,y) satisfies |G(x,y)| >Ts, increase the cummulative
table in in parameter space such that:
a = x R cos G
R,
b = y R sin G
H (a, b, R) = H (a, b, R) + 1
3/13/2023 Le Thanh Ha 16
Circle Detection
3/13/2023 Le Thanh Ha 17
Circle Detection
3/13/2023 Le Thanh Ha 18
Circle Detection
3/13/2023 Le Thanh Ha 19
Summary
• Hough transform
• It can be used to detect some image features having a paticular
shape properties: line, circle, …
3/13/2023 Le Thanh Ha 20