Effacer les filtres
Effacer les filtres

error occured during selection of random images

2 vues (au cours des 30 derniers jours)
Balaji M. Sontakke
Balaji M. Sontakke le 13 Fév 2020
Index exceeds matrix dimensions.
Error in tt (line 18)
fn = fullfile(P,D,F{ii});
clc;
clear all;
tic;
%% Training images
id_test = 0;
id_train = 0;
P = 'ROIBintrain'; % i.e. relative/absolute path to where the subfolders are.
for ii = 1:10 % no of classes
D = sprintf('%u',ii);
S = dir(fullfile(P,D,'*.bmp')); % get all filenames in subfolder
N = numel(S);
X = randperm(N);
F = {S(X(1:8)).name}; % randomly select 8 filenames.
for jj = 1:numel(F) % no of images per class
fn = fullfile(P,D,F{ii});
im = imread(fn);
X = double(im);
X = imresize(X,[100 120],'bilinear'); %300 250
id_train = id_train+1;
traindata{id_train}=ext_vein(X,1);
traindata = traindata';
% only four minutie is taken from one image
reduced_traindata = cellfun(@(M) M(1:min(end,4), :), traindata, 'uniform', 0);
end
end
%% Testing images
d=[];
P = 'ROIBintrain'; % i.e. relative/absolute path to where the subfolders are.
for ii = 1:10 % no of classes
D = sprintf('%u',ii);
S = dir(fullfile(P,D,'*.bmp')); % get all filenames in subfolder
N = numel(S);
X = randperm(N);
F = {S(X(1:8)).name}; % randomly select 8 filenames.
for jj = 1:numel(F) %no of images per class
fn = fullfile(P,D,F{ii});
im = imread(fn);
X = double(im);
X = imresize(X,[100 120],'bilinear'); %300 250
id_test = id_test+1;
testdata{id_test}=ext_vein(X,1);
testdata = testdata';
% only four minutie is taken from one image
reduced_testdata = cellfun(@(M) M(1:min(end,4), :), testdata, 'uniform', 0);
end
end
%%
save('db1.mat','reduced_testdata');
save('db2.mat','reduced_traindata');
toc

Réponses (1)

KALYAN ACHARJYA
KALYAN ACHARJYA le 13 Fév 2020
Modifié(e) : KALYAN ACHARJYA le 13 Fév 2020
Beacuse length of F / fullfile total images is less than 10, check and verify
  6 commentaires
KALYAN ACHARJYA
KALYAN ACHARJYA le 13 Fév 2020
In the initial for loop you have defined ii = 1:10, when ii reached to 9, how it gets the F{9}, its having length only 8, hence it shows the error in that line, change the ii to 8, may be it works (to test)
Error in tt (line 18)
fn = fullfile(P,D,F{ii});
Balaji M. Sontakke
Balaji M. Sontakke le 13 Fév 2020
no sir there is no effect. ii indicates 10 folders each folder having 8 images, i want 5 images randmly from each folder, this program read 5 images but stop with error why this so?

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by