I have folder containing thousands of (*.jpg) images inside and would like to loop over the name of them and apply calculations on them.
has anybody kind of loop in mind for this?
I have folder containing thousands of (*.jpg) images inside and would like to loop over the name of them and apply calculations on them.
has anybody kind of loop in mind for this?
Loop over the variables that are determining your filenames and use sprintf() to format those variables into strings.
I can't quite figure out your filename pattern, but you would read the first group like this, for example:
for i = 0:9
% The %d character will be replaced by i in the string
filename = sprintf('abcda0b%d99.jpg',i);
im = imread(filename);
% Image calculations
end
If your filenames obey a single pattern, you can do this with nested loops to construct the filename from the variables that are determining your filename. If you reply with more detail about your naming pattern I can help you out.
You can use dir
function:
path='The_path_to_directory_contains_the_jpg_files';
d=dir(path);
for k=3:length(d)
im=imread(fullfile(path,d(k).name));
% do calculations
end