error occured during selection of random images

1 visualización (últimos 30 días)
Balaji M. Sontakke
Balaji M. Sontakke el 13 de Feb. de 2020
Comentada: Balaji M. Sontakke el 13 de Feb. de 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

Respuestas (1)

KALYAN ACHARJYA
KALYAN ACHARJYA el 13 de Feb. de 2020
Editada: KALYAN ACHARJYA el 13 de Feb. de 2020
Beacuse length of F / fullfile total images is less than 10, check and verify
  6 comentarios
KALYAN ACHARJYA
KALYAN ACHARJYA el 13 de Feb. de 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 el 13 de Feb. de 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?

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by