我对matlab还是比较陌生,我正在尝试实现Hough变换,但是我的代码似乎有问题,因为即使在一张简单的照片中也只能找到一些行。我将不胜感激。
distance = sqrt((size(BW,1) - 1 )^2 + (size(BW,2) - 1)^2 );
rho = -ceil(distance):rhoStep:ceil(distance);
H = zeros((2 * ceil(distance/rhoStep)) + 1 , length(theta));
[edge_row, edge_col] = find(BW);
theta_rad = theta * pi/180;
for i = 1:length(edge_row)
y = edge_row(i);
x = edge_col(i);
for j = 1 : length(theta)
d = x*cos(theta_rad(j)) + y * sin(theta_rad(j)) + distance;
H(round(d), j) = H(round(d), j) + 1;
end
end