Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
How do I allow user to choose either a folder or an image(or selective images) to run the rest of the functions?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Geoff Hayes
el 16 de Ag. de 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?
Respuestas (1)
Walter Roberson
el 16 de Ag. de 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 comentarios
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!