Need Help Compressing/ Simplifying this Code
Show older comments

Basically instead of loading and referencing each image seperately is it possible(i know it is just not how ) to call all these images at once into the directory for reference theres 3 sets of images Im trying to load in each set consists of 10 images with the same name-0001(a number reference for each image in the set) I really dont want 30 lines of code just to read all these images Im assuming a for loop would be my best friend here?
Answers (1)
Mathieu NOE
on 6 Oct 2020
hello
try this code :
% select appropriate options below ...
% files = dir('*.tif'); % all tif files in current directory
files = dir('handheld*.tif'); % as example : only tif files with "handheld" in the filename
% main loop
for ck = 1:length(files)
Filename = files(ck).name;
H{ck} = imread(Filename);
end
%%%%%%%%%%%%%%%%%%
% check if ok
%%%%%%%%%%%%%%%%%%
for ck = 1:length(files)
figure(ck), imagesc(H{ck});
end
% it works !!
2 Comments
luke bender
on 6 Oct 2020
Mathieu NOE
on 7 Oct 2020
hello
yes , yu can put your image processing in the main loop - should work fine
all the best
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!