doing multiple tests using one run

i am working on a facial recognition system, and i need some help with creating a loop that allows me to do multiple test in one time run, here is the testing part of the code:
prompt = {'Enter test image name:'};
dlg_title = 'Face Recognition System';
num_lines= 1;
def = {'1'};
TestImage = inputdlg(prompt,dlg_title,num_lines,def);
TestImage = strcat(TestDatabasePath,'/',char(TestImage),'.pgm');
im = imread(TestImage);
toc;
recognition_rate=abs(50*(size(N,2)-wrong)/size(N,2))
T = CreateDatabase(TrainDatabasePath);
[m, A, Eigenfaces] = face(T);
OutputName = recog(TestImage, m, A, Eigenfaces);
SelectedImage = strcat(TrainDatabasePath,'/',OutputName);
SelectedImage = imread(SelectedImage);
imshow(im)
title('Image to be tested');
figure,imshow(SelectedImage);
title('Equivalent Image');
any help?

2 件のコメント

Walter Roberson
Walter Roberson 2020 年 5 月 10 日
Multiple tests? How? Something along the lines of using uigetfile() with 'MultiSelect', 'on', and processing all of the files the user chooses?
zeina abdelaziz
zeina abdelaziz 2020 年 5 月 10 日
like i want the user to be able to pick multiple images to test not just one, once the run button is pushed

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 5 月 10 日

0 投票

uigetfile() with 'MultiSelect', 'on' in order to get the list of file names.
Note that there is a trick to uigetfile with multiselect on: if the user selects more than one file then the file names are returned as a cell array of character vectors, but if the user selects only one file than the file name is returned as a character vector that is not in a cell array. The way to deal with that is
[filenames, pathname] = uigetfile('*.png', 'Pick some files', 'multiselect', 'on');
if isnumeric(filenames)
return; %user cancel
end
filenames = cellstr(filenames); %character vector will become cell array of character vector
filenames = fullfile(pathname, filenames); %attach the directory
numfiles = length(filenames);
for K = 1 : numfiles
TestImage = filenames{K};
im = imread(TestImage);
and so on
end

質問済み:

2020 年 5 月 10 日

コメント済み:

2020 年 5 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by