Index in position 1 is invalid. error after running multiple times

1 visualización (últimos 30 días)
I am trying to extract features from a dataset. the problem that after a group of images features extracted it is stoped by itself for example features are extracted for 20 images then for image 21 it gives this error
Index in position 1 is invalid. Array indices must be positive integers or logical values.
my code
clc;
clear all;
close all;
warning off;
imds=imageDatastore('E:\dataset test','IncludeSubFolders',true,'LabelSource','foldernames');
trainingFeatures=[];
trainingLabels=imds.Labels;
for i = 1:numel(imds.Files) % Read images using a for loop
img = readimage(imds,i);
trainingFeatures(i,:) = example(img);
end
the error
Index in position 1 is invalid. Array indices must be positive integers or logical values.
Error in clipLine (line 85)
inter1 = points(ind,:);
Error in A (line 55)
edge = clipLine(LINE, BOX);
Error in example (line 40)
[lensV, lensF] =A(img,N,pxMin,calLen);
Error in Untitled2 (line 30)
trainingFeatures(i,:) = example(img);
  1 comentario
Ameer Hamza
Ameer Hamza el 10 de Dic. de 2020
The error is caused by a function you defined, 'clipLine'. Add a breakpoint in this code to see what is causing the value of 'ind' to become invalid: https://www.mathworks.com/help/matlab/matlab_prog/set-breakpoints.html

Iniciar sesión para comentar.

Respuestas (1)

Hritika Suneja
Hritika Suneja el 31 de Dic. de 2020
It's difficult to fix the error without seeing the complete code. However errors like ' Index in position 1 is invalid.' generlly occur because of some incorrect indexing in your code. It might happen that a wrong variable is being used to index an array. You can use the command mentioned below to debug these types of errors:
>>dbstop if error

Categorías

Más información sobre Computer Vision with Simulink en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by