sh167779@163.com
求程序
程序執行過程為:
程序運行後首先提示將TestDatabase,TrainDatabase兩個文件夾添加到路徑中
然後提示從TestDatabase中隨便選擇壹張圖片,程序會從TrainDatabase中選出與剛才所選相同的圖片
效果如下
手選圖片
程序挑出來的圖片
主程序代碼如下:
clear all
clc
close all
% You can customize and fix initial directory paths
TrainDatabasePath = uigetdir(strcat(matlabroot,'\work'), 'Select training database path' );
TestDatabasePath = uigetdir(strcat(matlabroot,'\work'), 'Select test database path');
prompt = {'Enter test image name (a number between 1 to 10):'};
dlg_title = 'Input of FLD-Based Face Recognition System';
num_lines= 1;
def = {'1'};
TestImage? = inputdlg(prompt,dlg_title,num_lines,def);
TestImage = strcat(TestDatabasePath,'\',char(TestImage),'.jpg');
im = imread(TestImage);
T = CreateDatabase(TrainDatabasePath);
[m V_PCA V_Fisher ProjectedImages_Fisher] = FisherfaceCore(T);
OutputName = Recognition(TestImage, m, V_PCA, V_Fisher, ProjectedImages_Fisher);
SelectedImage = strcat(TrainDatabasePath,'\',OutputName);
SelectedImage = imread(SelectedImage);
imshow(im)
title('Test Image');
figure,imshow(SelectedImage);
title('Equivalent Image');
str = strcat('Matched image is :? ',OutputName);
disp(str)