how to read all the images in a folder???

9 visualizaciones (últimos 30 días)
Aps
Aps el 4 de Abr. de 2015
Comentada: Image Analyst el 12 de Oct. de 2019
how to read the all the images present in a folder

Respuesta aceptada

Stephen23
Stephen23 el 4 de Abr. de 2015
Editada: Stephen23 el 4 de Abr. de 2015
You can use dir to get a structure with of the files listed, and you can use a wildcard search too:
myFolder = 'C:\Documents and Settings\yourUserName\My Documents\My Pictures';
if ~isdir(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
filePattern = fullfile(myFolder, '*.jpg');
jpegFiles = dir(filePattern);
for k = 1:length(jpegFiles)
baseFileName = jpegFiles(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
imageArray = imread(fullFileName);
imshow(imageArray); % Display image.
drawnow; % Force display to update immediately.
end
This example if taken straight from the Wiki FAQ:
  2 comentarios
sarah fteih
sarah fteih el 12 de Oct. de 2019
this code is work well can you complete this code by adding how to get the output of these images in a new folder on my pc?
Image Analyst
Image Analyst el 12 de Oct. de 2019
What is the output of your image analysis? An Excel workbook? A bunch of variables that you want saved in a .mat file? I have no idea but just use whatever output function you want, like xlswrite(), writetable(), csvwrite(), dlmwrite(), fprintf(), imwrite(), etc.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by