Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
How do I allow user to choose either a folder or an image(or selective images) to run the rest of the functions?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Currently it is able to select a folder but I want the users to have other options if they want to select an image/ selective images instead.
%% ACCESS ALL IMAGES IN THE FOLDER
selpath = uigetdir;
imageFolder = dir(fullfile(selpath,'\*.jpg'));
numfiles = length(imageFolder);
ori_roi = cell(numfiles, 1);
i = 1;
%% LOOP THROUGH ALL IMAGES IN THE FOLDER & RUN ALL THE 5 FUNCTIONS
for i=1:length(imageFolder)
tic
functionError = 0;
filename = fullfile(selpath,imageFolder(i).name);
originalImage = imread(filename);
fprintf("Image name: %s\n",imageFolder(i).name);
...
3 Kommentare
Geoff Hayes
am 16 Aug. 2019
Shu - please clarify what you mean by unable to see the individual images. Where are you expecting to see them? Are you not seeing the files or are you expecting to see the actual image?
Antworten (1)
Walter Roberson
am 16 Aug. 2019
choice = menu('How do you want to select images?', 'by folder', 'individual image');
switch choice
case 0
%user cancelled
return
case 1
%% ACCESS ALL IMAGES IN THE FOLDER
selpath = uigetdir;
if ~ischar(selpath)
%user cancelled
return
end
imageFolder = dir(fullfile(selpath,'*.jpg'));
filenames = fullfile(selpath, {imageFolder.name});
case 2
%% ACCESS ONE IMAGE IN A FOLDER
[selfile, selpath] = uigetfile({'*.jpg', '*.png', '*.tif', '*.*'}, 'Pick a file');
if ~ischar(selfile)
%user cancelled
return
end
filenames = {fullfile(selpath, selfile)};
otherwise
error('somehow choice is out of range??')
end
numfiles = length(filenames);
ori_roi = cell(numfiles, 1);
%% LOOP THROUGH ALL IMAGES IN THE FOLDER & RUN ALL THE 5 FUNCTIONS
for i=1:numfiles
tic
functionError = 0;
filename = filenames{i};
[~, basename, ~] = filepaths(filename);
originalImage = imread(filename);
fprintf("Image name: %s\n",basename);
...
ori_roi{i} = ....
toc
end
0 Kommentare
Diese Frage ist geschlossen.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!