Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
yasmin almashagbah
yasmin almashagbah le 8 Déc 2020
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 commentaire
Ameer Hamza
Ameer Hamza le 10 Déc 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

Connectez-vous pour commenter.

Réponses (1)

Hritika Suneja
Hritika Suneja le 31 Déc 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

Catégories

En savoir plus sur Computer Vision with Simulink dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by