Loading and processing multiple images using uigetfile

2 vues (au cours des 30 derniers jours)
William Pang
William Pang le 17 Juin 2020
Commenté : Image Analyst le 18 Juin 2020
Hi,
I was wondering whether it is possible to load multiple images using uigetfile. I know how to do it with one file:
[FileName, FilePath]= uigetfile('.TIF','Select File to Open');
%If user does not select file
if [FileName,FilePath] == 0;
return;
end
I_M = imread(fullfile(FilePath, FileName));
But I'm wondering how I can use the multiselect feature with uigetfile
[file,path] = uigetfile('*.TIF','Select One or More Files','MultiSelect', 'on');
And then read multiple images using imread that runs with a for loop, something like this:
for count=1:total_images_selected
images{count}=imread(%not quite sure what to put here);
%Some analysis afterwards that basically sums the matrix values in a processed image
end
Any help would be appreciated!

Réponse acceptée

Voss
Voss le 17 Juin 2020
Looks like you almost had it, but just to fill in the "%not quite sure what to put here" part:
[file,path] = uigetfile('*.TIF','Select One or More Files','MultiSelect', 'on');
if isequal(file,0)
return
end
total_images_selected = numel(file);
images = cell(1,total_images_selected);
for count = 1:total_images_selected
images{count} = imread(fullfile(path,file{count}));
% analysis
end
  2 commentaires
William Pang
William Pang le 17 Juin 2020
Thanks so much!
Image Analyst
Image Analyst le 18 Juin 2020
Chances are you don't need to save all your images in a cell array, which could eat up all your memory. You can probably just process them right then and there in the loop.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur App Building dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by