I am currently having some issues with my current implementation of a hough transform. Right now I am mostly focused on the getting the hough accumulator, rhos and Thetas. I feel like this is hardest part as I feel everything else works. I also realize I could just use the function but that isn't what I am trying to do. I feel like I missing a few small details that will make all the difference.
The first step is getting the edge image using
img_edges=edge(img,'canny')
After that is the part where I get the other stuff I mentioned
function [H, theta, rho] = hough_lines_acc(BW, varargin)
p = inputParser();
addParameter(p, 'RhoResolution', 1);
addParameter(p, 'Theta', linspace(-90, 90, 180));
parse(p, varargin{:});
rhoStep = p.Results.RhoResolution;
D = sqrt((255 - 1)^2 + (255 - 1)^2);
nrho = round(2*(ceil(D/rhoStep)) + 1);
rho=linspace(0,nrho,nrho+1);
theta=p.Results.Theta;
ntheta = length(theta);
%initialize H to all zeros
H=zeros(nrho+1,ntheta);
[y,x]=size(BW);
for u= 1:y
for v= 1:x
if BW(u,v)==1
for i=1:ntheta
the=theta(i);
rhov=abs(ceil(v*cosd(the)+u*sind(the)));
H(rhov+1,i)=H(rhov+1,i)+1;
end
end
end
end
end
I just need some pointers so I can get this running .I actually think the rest of the hough transform I have down.
rhoandthetaproperly. - rayryeng