资源简介
基于pca实现人脸识别,是经典的人脸识别算法之一,有较好的识别效果
代码片段和文件信息
function [personpic] = pca_faces(TestPerTestPicNumRecFaces)
%此函数用基于PCA的方法实现人脸检测,采用特征脸实现。
%输入:
% TestPerTestPic:希望检测的第TestPer个人的第TestPic个脸应该选择任意人后五幅脸中的一幅作为测试图像
% NumRecFaces:希望得到的最相近的人脸数,小于10,默认为4
%输出:
% Person,Pic:检测到的最相近的几个第Person个人的第Pic个脸
if nargin == 2
NumRecFaces = 4;
end;
load Imgs %load the database
%choose the first five faces for one person as the training faces
TrainImgs = Imgs(:1:5);
for i=2:40
TrainImgs = [TrainImgs Imgs(:1+10*(i-1):5+10*(i-1))];
end
%run PCA to train
[VectorsValuesPsi] = pc_evectors(TrainImgs30); % Get top 30 PC evectors of Imgs
%show the eigenfaces
figure;
subplot(251)
pc_ev = reshape(Vectors(:1)wh)‘; % Get PC eigenvector 1
imagesc(pc_ev); colormap(gray(256)); axis off ;axis image
subplot(252)
pc_ev = reshape(Vectors(:2)wh)‘; % Get PC eigenvector 2
imagesc(pc_ev); colormap(gray(256)); axis off; axis image
subplot(253)
pc_ev = reshape(Vectors(:3)wh)‘; % Get PC eigenvector 3
imagesc(pc_ev); colormap(gray(256)); axis off; axis image
subplot(254)
pc_ev = reshape(Vectors(:4)wh)‘; % Get PC eigenvector 4
imagesc(pc_ev); colormap(gray(256)); axis off; axis image
subplot(255)
pc_ev = reshape(Vectors(:5)wh)‘; % Get PC eigenvector 5
imagesc(pc_ev); colormap(gray(256)); axis off; axis image
subplot(256)
pc_ev = reshape(Vectors(:6)wh)‘; % Get PC eigenvector 6
imagesc(pc_ev); colormap(gray(256)); axis off; axis image
subplot(257)
pc_ev = reshape(Vectors(:7)wh)‘; % Get PC eigenvector 7
imagesc(pc_ev); colormap(gray(256)); axis off; axis image
subplot(258)
pc_ev = reshape(Vectors(:8)wh)‘; % Get PC eigenvector 8
imagesc(pc_ev); colormap(gray(256)); axis off; axis image
subplot(259)
pc_ev = reshape(Vectors(:9)wh)‘; % Get PC eigenvector 9
imagesc(pc_ev); colormap(gray(256)); axis off; axis image
subplot(2510)
pc_ev = reshape(Vectors(:10)wh)‘; % Get PC eigenvector 10
imagesc(pc_ev); colormap(gray(256)); axis off ;axis image
%input a new image to recongnize
%show the test face
TestFace = Imgs(:10*(TestPer-1)+TestPic);
TFace = reshape(TestFacewh)‘;
figure;
imagesc(TFace);
colormap(gray(256));
title(‘Test Face‘);axis off
%select the first 10 eigenvectors to reconstruct
LowDim_TestF = Vectors(:1:10)‘*(TestFace - Psi); % Project onto eigenvectors
%construct a matrix to save the closest recognized faces
RecFaces = zeros(2NumRecFaces);%first row to record the index the second to the distinction
%find the nearest faces in the database(400 face in all)
for i = 1:NumRecFaces
TemptFace = Imgs(:i);
LowDim_TemptF = Vectors(:1:10)‘*(TemptFace - Psi);
Dis = sum(abs(LowDim_TestF-LowDim_TemptF));
RecFaces(2i) = Dis;%distinction
end
[RecFaces(2:)RecFaces(1:)] = sort(RecFaces(2:));
for i = NumRecFaces+1:400
TemptFace = Imgs(:i);
LowDim_TemptF = Vectors(:1:10)‘*(TemptFace - Psi);
Dis = sum(abs
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3876 2009-06-17 22:34 pca_face recognition\pca_faces.m
文件 2179 2001-02-12 15:32 pca_face recognition\pc_evectors.m
文件 77 2009-06-17 22:34 pca_face recognition\run_result.m
文件 445 2001-02-12 15:32 pca_face recognition\sortem.m
目录 0 2009-06-17 22:43 pca_face recognition
----------- --------- ---------- ----- ----
6577 5
- 上一篇:多径信道matlab代码
- 下一篇:HBMA算法和EMBA算法
相关资源
- 掌纹识别PCA
- DPCA 程序编写
- 基于MATLAB的LBP图片特征提取算法,人
- Deep Semi-NMF源代码
- matlab圈出照片中人脸和五官的位置
- MATLAB实现人脸识别光照归一化算法
- 基于SVM(支持向量机) 的人脸识别
- PCA-SIFT 源代码 matlab
- 人脸识别MATLAB程序
- 基于肤色的RGB多人脸检测
- MATLAB人脸识别PCALDAKPCABP,可视化界面
- 人脸识别算法matlab
- TwoDPCA用matlab实现的2dpca人脸识别程序
- 用于图像识别的2DPCA算法程序matlab
- 基于MATLAB的KL人脸识别程序可运行.r
- KPCA MATLAB程序,提供4种核函数,根据
- PCA Matlab源码
- Matlab笔记本自带摄像头人脸识别 by
- KPCA的MATLAB代码
- ( 关于人脸检测的MATLAB代码
- 基于matlab的人脸识别算法(PCA
- PCA故障诊断MATLAB实现
- 基于LDA(fisherface)和KNN的人脸识别
- SAR图像去噪matlab小波去噪、contourlet变
- myPCA.m
- 基于MATLAB的库外人脸识别GUI界面源码
- pq pca svm 使用小波能量差提取信号
- BP人脸识别
- 局部二值模式进行编码的人脸识别
- face recognition 稀疏表示人脸分类与识别
评论
共有 条评论