Filter löschen
Filter löschen

Why am I getting an error of "error: X(433,_): but X has size 1x1 error: called from naiveHough at line 70 column 13"

2 Ansichten (letzte 30 Tage)
I am wrting a code for hough transformation in octave. Taking help from here
function [ Hough, theta_range, rho_range ] = naiveHough(I)
%NAIVEHOUGH Peforms the Hough transform in a straightforward way.
%
pkg load image
I=imread('aa.jpg');
%I=I.*255;
%I=uint8(I);
%I=uint8(I)<50;
%I=I.*255;
%imshow(I)
[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-1)
waitbar(row/rows, wb);
for col = 1:(cols-1)
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);
Hough=Hough.*2;
subplot(2,2,1)
imhist(uint8(Hough))
subplot(2,2,2)
imshow(uint8(Hough))
values = 1:255;
threshold_value = sort(values,'descend');
XX=threshold_value(5)
X=(Hough)>XX;
subplot(2,2,3)
imshow(X)
%%%%%%%%%%%%%%%MY CODE %%%%%%%%%%%%%%%%%%%%
[M,N]=size(X);
%PLot the Line back again from the Hough Space to Image%
for row = 1:(M-1)
for col = 1:(N-1)
if X(row, col) > 0 %%%%Line 70 %%%%%
the=(col-90);
R=row;
X=R*cosd(the);
Y=R*sind(the);
plot(X,Y);
hold ("on");
end
end
end
hold ("off");
  3 Kommentare

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by