Need Help Compressing/ Simplifying this Code

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?

Risposte (1)

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 Commenti

hi ty this works because I also have to do computations/processing for each image so I can just put those equations into the for loop and I should be good to go? im assuming
hello
yes , yu can put your image processing in the main loop - should work fine
all the best

Accedi per commentare.

Richiesto:

il 6 Ott 2020

Commentato:

il 7 Ott 2020

Community Treasure Hunt

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

Start Hunting!

Translated by