필터 지우기
필터 지우기

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 (최근 30일)
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
Pijush
Pijush 2018년 9월 15일
Yes I got the point and I have change X to X1, Thank you!

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Octave에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by