1
votes

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.

1
What exactly are you having trouble with? To me your implementation looks fine. It looks like you're accumulating the rho and theta properly. - rayryeng
My goal is to emulate every step of a hough transform. When I run this, I get something that is a solid figure and it doesn't high light any real points. - Chris Jones
For instance, when I take that on an image and then run the rest of what I am doing through the real hough functions, the houghlines part returns nothing. Yet the exact same code that is given a hough accumulator from the default hough function in matlab will follow the whole process to completion and it will do it correctly. - Chris Jones

1 Answers

0
votes

Overall it seems that there might be some other issues going . I did change the range of the rho so that it can include negative and positive and the result is nice. I actually think my issue does lie elsewhere.