Pulling multiple images into script
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Karen Yadira Lliguin León
el 14 de Oct. de 2022
Movida: Matt J
el 14 de Oct. de 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
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!