MATLAB Answers

0

how do I allow user to choose a folder to run the rest of the functions?

Asked by Shu Yi Ho on 14 Aug 2019
Latest activity Commented on by Shu Yi Ho on 15 Aug 2019
%% ACCESS ALL IMAGES IN THE FOLDER
imageFolder = dir('C:\Users\85042513\MATLAB\Projects\BAT CVE\Images\NG\*.jpg');
numfiles = length(imageFolder);
ori_roi = cell(numfiles, 1);
i = 1;
filename = strcat('C:\Users\85042513\MATLAB\Projects\BAT CVE\Images\NG\',imageFolder(i).name);
originalImage = imread(filename);
%% LOOP THROUGH ALL IMAGES IN THE FOLDER & RUN ALL THE 5 FUNCTIONS
for i=1:length(imageFolder)
tic
functionError = 0;
filename = strcat('C:\Users\85042513\MATLAB\Projects\BAT CVE\Images\NG\',imageFolder(i).name);
originalImage = imread(filename);
ori_roi{i} = originalImage( rect(2) : (rect(2)+rect(4)) , rect(1) : (rect(1)+rect(3)) , : );
fprintf("Image name: %s\n",imageFolder(i).name);
...

  0 Comments

Sign in to comment.

Tags

1 Answer

Answer by TADA
on 14 Aug 2019

  4 Comments

Show 1 older comment
You can use uigetdir to select a folder. Then you can change your code to something like this:
selpath = uigetdir;
imageFolder = dir(fullfile(selpath,'*.jpg'));
I want to select a folder instead of the images inside.
What exactly do you intend to do with the folder once it is selected?

Sign in to comment.