Pulling multiple images into script
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello, I'm trying to create a loop that allows me to pull in a file folder with images, read in those images as their RGB values, and put those values in a struct. My code is below, and I'm having an error in my line that creates the variable f, it only selects one image instead of all of the images in the file. Any suggestions on how I can apply this to all images in the folder?
image_folder= uigetdir();
filenames = dir(fullfile(image_folder, '*.jpg'));
total_images = numel(filenames);
for n = 1:total_images
f= fullfile(image_folder, filenames(n).name) ;
our_images = imread(f);
face_stimuli=(struct);
face_stimuli(total_images).image = our_images;
end
save ('face_Stimuli.mat', 'face_stimuli')
0 Commenti
Risposte (1)
Karen Yadira Lliguin León
il 14 Ott 2022
Spostato: Matt J
il 14 Ott 2022
try with this:
image_folder= uigetdir();
filenames = dir(fullfile(image_folder, '*.jpg'));
total_images = numel(filenames);
face_stimuli=struct;
for n = 1:total_images
f= fullfile(image_folder, filenames(n).name) ;
our_images = imread(f);
face_stimuli(n).image=our_images;
%face_stimuli(total_images).image = our_images;
end
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!