How To Create A Simple Hough Transform Matrix

A = [0 0 0 0 15; 0 0 0 15 0; 0 0 15 0 0; 0 15 0 0 0; 15 0 0 0 0];

[m,n] = size(A);
rhoValues = zeros(m,n);
thetaValues = zeros(m,n);

diagonalDist = floor(sqrt(m^2 + n^2));
thetaMax = 90;
rhoRange = -diagonalDist:diagonalDist;
thetaRange = -thetaMax:thetaMax;
%Matrix Hough
houghMatrix = zeros(length(rhoRange), length(thetaRange));

for i = 1:m
    for j = 1:n
        if (A(i,j) ~= 0)
            x = m - 1;
            y = n - 1;
            for theta = thetaRange
                rhoValues = round((x*cosd(theta)) + (y*sind(theta)));
                rhoIndex = rhoValues + diagonalDist + 1;
                thetaIndex = theta + thetaMax + 1;
                houghMatrix(rhoIndex,thetaIndex) = houghMatrix(rhoIndex,thetaIndex) + 1;
            end
        end
    end
end

Solve More Practice Questions

Artificial Intelligence or AI

Who is John McCarthy ? American Computer Scientist | AI

What are the different ways to get backlinks?