I have a folder that contains 10 subfolders each subfolder contains 8 images, I want to dynamically select 5 images from each subfolders but i got following error.
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:5)).name}; % randomly select 5 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); endend %% save data
save('db2.mat','reduced_traindata'); toc
Best Answer