example.m
上传用户:netsea168
上传日期:2015-08-07
资源大小:617k
文件大小:1k
- % A sample script, which shows the usage of functions, included in
- % PCA-based face recognition system (Eigenface method)
- %
- % See also: CREATEDATABASE, EIGENFACECORE, RECOGNITION
- % Original version by Amir Hossein Omidvarnia, October 2007
- % Email: aomidvar@ece.ut.ac.ir
- clear all
- clc
- close all
- % You can customize and fix initial directory paths
- TrainDatabasePath = uigetdir('D:Program FilesMATLABR2006awork', 'Select training database path' );
- TestDatabasePath = uigetdir('D:Program FilesMATLABR2006awork', 'Select test database path');
- prompt = {'Enter test image name (a number between 1 to 10):'};
- dlg_title = 'Input of PCA-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, A, Eigenfaces] = EigenfaceCore(T);
- OutputName = Recognition(TestImage, m, A, Eigenfaces);
- 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)