MATLAB: How can i create a loop for all images in the dataser

image loop dataset

I wanna do the same work for all images which are in my dataset for extracting features of every image. How can i do it please? i don't know if 'dir' or 'cd' allow me to do that.

Best Answer

imagefiles = dir('*.jpg'); % give your extension
nfiles = length(imagefiles); % Number of image files
% loop for each file
for ii=1:nfiles
currentfilename = imagefiles(ii).name;
currentimage = imread(currentfilename); % read the image
% do what you want
end