forked from palmerc/Hough
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnaiveHough.m
33 lines (27 loc) · 1 KB
/
naiveHough.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function [ Hough, theta_range, rho_range ] = naiveHough(I)
%NAIVEHOUGH Peforms the Hough transform in a straightforward way.
%
[rows, cols] = size(I);
theta_maximum = 90;
rho_maximum = floor(sqrt(rows^2 + cols^2)) - 1;
theta_range = -theta_maximum:theta_maximum - 1;
rho_range = -rho_maximum:rho_maximum;
Hough = zeros(length(rho_range), length(theta_range));
wb = waitbar(0, 'Naive Hough Transform');
for row = 1:rows
waitbar(row/rows, wb);
for col = 1:cols
if I(row, col) > 0
x = col - 1;
y = row - 1;
for theta = theta_range
rho = round((x * cosd(theta)) + (y * sind(theta)));
rho_index = rho + rho_maximum + 1;
theta_index = theta + theta_maximum + 1;
Hough(rho_index, theta_index) = Hough(rho_index, theta_index) + 1;
end
end
end
end
close(wb);
end