Azzera filtri
Azzera filtri

Index in position 1 is invalid. Array indices must be positive integers or logical values.

1 visualizzazione (ultimi 30 giorni)
Hello everyone, I am trying to get edge detected images from the code below but it keeps telling the same error which is :
Index in position 1 is invalid. Array indices must be positive integers or logical values.
Error in
elseif ( IF(i+1,j)<0 || IF(i-1,j)<0 || IF(i,j+1)<0 || IF(i,j-1)<0 || IF(i-1, j-1)<0 || IF(i-1, j+1)<0 || IF(i+1,
j+1)<0 || IF(i+1, j-1)<0)
Please could anyone help me resolving the problem, thank you!
close all;
clc;
%Input image
inim = imread ('ruins.jpg');
inimg = rgb2gray(inim);
%Value for Thresholding
T_Low = 0.075;
T_High = 0.175;
k = 2;
delta_t = 0.1;
col=size(inimg,1);
row=size(inimg,2);
cC = ((abs(inimg)).^2)./(1 + ((abs(inimg).^2).*delta_t)).^k;
F = fft(inimg);
J = cC .* F;
IF1 = ifft(J);
IF = real(IF1);
%Hysteresis Thresholding
T_Low = T_Low * max(max(IF));
T_High = T_High * max(max(IF));
T_res = zeros (pan, leb);
for i = 1 : col
for j = 1 : row
if (IF(i, j) < T_Low)
T_res(i, j) = 0;
elseif(IF(i, j) > T_High)
T_res(i, j) = 1;
%look for the negative in 8-connected components
elseif ( IF(i+1,j)<0 || IF(i-1,j)<0 || IF(i,j+1)<0 || IF(i,j-1)<0 || IF(i-1, j-1)<0 || IF(i-1, j+1)<0 || IF(i+1, j+1)<0 || IF(i+1, j-1)<0)
T_res(i,j) = 1;
end
end
end

Risposte (1)

KALYAN ACHARJYA
KALYAN ACHARJYA il 19 Mag 2019
Modificato: KALYAN ACHARJYA il 19 Mag 2019
( IF(i+1,j)<0 || IF(i-1,j)<0 || IF(i,j+1)<0 || IF(i,j-1)<0 || IF(i-1, j-1)<0 || IF(i-1, j+1)<0 ||
%......^.............^................^............^...so on
When i=1.............^^ becomes zero that menas IF(i-1,j)>>IF(0,j)
When j=1............................................^^ >>IF(i,0)
These array indeces must be non zero positive integer.
IF (0,2)>> not allowed
IF(-2,4) not allowed
IF(1,1) allowed
IF(2,0) not allowed
IF(5,5) is allowed
Also ensure during array indexing, length of array doesnot exceed, otherwise it will reflects another type of array "array exceeds ....."
More detail read here

Prodotti


Release

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by