function OutputName = Recognition(TestImagePath, MeanFace, MeanNormFaces, EigenFaces)
% Description: This function compares two faces by projecting the images into facespace and
% measuring the Euclidean distance between them.
% Input: TestImagePath - Path of test face image
% MeanFace -(1*MN) mean vector, which is one
% of the output of 'EigenfaceCore.m'
%
% MeanNormFaces -(P*MN) matrix with each row
% represents a mean-normalized
% face, which is one of the output
% of 'EigenfaceCore.m'
% EigenFaces
%%%%%%%%%%%%%%%%%%%%%%%% Projecting centered image vectors into facespace
% All centered images are projected into facespace by multiplying in
% Eigenface basis's. Projected vector of each face will be its corresponding
% feature vector.
ProjectedImages = [];
% I think here should be the number of centered training faces rather than
% number of eigenfaces
Train_Number = size(MeanNormFaces,1);
for i = 1 : Train_Number
temp = (EigenFaces*MeanNormFaces(i,:)')'; % Projection of centered images into facespace
ProjectedImages(i,:) =temp; % each row corresponds to a feature
end
%%%%%%%%%%%%%%%%%%%%%%%% Extracting the PCA features from test image
InputImage = imread(TestImagePath);
VecInput=reshape(InputImage,1,size(InputImage,1)*size(InputImage,2));
MeanNormInput = double(VecInput)-MeanFace; % Centered test image
ProjectedTestImage = (EigenFaces*MeanNormInput')'; % Test image feature vector
%%%%%%%%%%%%%%%%%%%%%%%% Calculating Euclidean distances
% Euclidean distances between the projected test image and the projection
% of all centered training images are calculated. Test image is
% supposed to have minimum distance with its corresponding image in the
% training database.
Euc_dist = [];
for i = 1 : Train_Number
temp = ( norm( ProjectedTestImage - ProjectedImages(i,:) ) )^2;
Euc_dist = [Euc_dist temp];
end
[Euc_dist_min , Recognized_index] = min(Euc_dist);
OutputName = strcat('s',int2str((Recognized_index-1)/5+1),'class');
figure,
subplot(121);
imshow(InputImage,[]);
title('输入人脸');
subplot(122);
imshow(reshape((MeanNormFaces(Recognized_index,:)+MeanFace),112,92),[]);
title(strcat('最相似人脸,类别:',int2str((Recognized_index-1)/5+1)));
没有合适的资源?快使用搜索试试~ 我知道了~
PCA人脸识别matlab代码,包括测试数据集
共831个文件
pgm:410个
bmp:400个
url:18个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 94 浏览量
2021-11-12
14:26:08
上传
评论
收藏 6.64MB RAR 举报
温馨提示
PCA人脸识别matlab代码 完整的利用PCA实现人脸识别分类的代码,包括测试数据集,数据集归数据集原作者所有,用户仅可用来测试。
资源推荐
资源详情
资源评论
收起资源包目录
PCA人脸识别matlab代码,包括测试数据集 (831个子文件)
6.bmp 11KB
8.bmp 11KB
4.bmp 11KB
7.bmp 11KB
9.bmp 11KB
5.bmp 11KB
3.bmp 11KB
1.bmp 11KB
10.bmp 11KB
2.bmp 11KB
1.bmp 11KB
4.bmp 11KB
3.bmp 11KB
7.bmp 11KB
5.bmp 11KB
9.bmp 11KB
2.bmp 11KB
6.bmp 11KB
8.bmp 11KB
10.bmp 11KB
4.bmp 11KB
8.bmp 11KB
2.bmp 11KB
7.bmp 11KB
5.bmp 11KB
10.bmp 11KB
3.bmp 11KB
9.bmp 11KB
7.bmp 11KB
6.bmp 11KB
1.bmp 11KB
8.bmp 11KB
6.bmp 11KB
3.bmp 11KB
1.bmp 11KB
3.bmp 11KB
5.bmp 11KB
4.bmp 11KB
8.bmp 11KB
10.bmp 11KB
4.bmp 11KB
9.bmp 11KB
2.bmp 11KB
6.bmp 11KB
7.bmp 11KB
9.bmp 11KB
7.bmp 11KB
10.bmp 11KB
8.bmp 11KB
5.bmp 11KB
3.bmp 11KB
9.bmp 11KB
4.bmp 11KB
2.bmp 11KB
1.bmp 11KB
6.bmp 11KB
10.bmp 11KB
8.bmp 11KB
3.bmp 11KB
1.bmp 11KB
5.bmp 11KB
2.bmp 11KB
7.bmp 11KB
6.bmp 11KB
4.bmp 11KB
10.bmp 11KB
1.bmp 11KB
9.bmp 11KB
6.bmp 11KB
5.bmp 11KB
2.bmp 11KB
7.bmp 11KB
4.bmp 11KB
2.bmp 11KB
3.bmp 11KB
8.bmp 11KB
9.bmp 11KB
6.bmp 11KB
10.bmp 11KB
5.bmp 11KB
1.bmp 11KB
7.bmp 11KB
10.bmp 11KB
5.bmp 11KB
8.bmp 11KB
3.bmp 11KB
4.bmp 11KB
1.bmp 11KB
9.bmp 11KB
7.bmp 11KB
2.bmp 11KB
6.bmp 11KB
9.bmp 11KB
8.bmp 11KB
5.bmp 11KB
10.bmp 11KB
4.bmp 11KB
3.bmp 11KB
2.bmp 11KB
1.bmp 11KB
共 831 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
YG亲测源码屋
- 粉丝: 390
- 资源: 1635
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功