资源简介
直接下载,在matlab运行即可。里面的result是我当时写的结果,如果不需要可以删除。
代码片段和文件信息
%**********************************************
% Aim : The first AI program homework
% title : PCA for face recognition
% Author : GongWanlu & Hufei
% Version : 1.0 final
% Submit Time : 2011-04-07
%**********************************************
% %%%%%%%%%%%%%%%%%%%%%%INITIAL
clear all
clc
close all
% %%%%%%%%%%%%%%%%%%%%%%Some variables according to the Yale Face DB
Num_subject = 15;
Num_image = 11;
Train_num_image = 8; %for every subject we choose 8 to train
Test_num_image = 9; %choose the left 3 images to test
% %%%%%%%%%%%%%%%%%%%%%%Load Data
Data = [];
for i=1:Num_subject
for j=1:Train_num_image
path = sprintf(‘FaceDB_yaleA/%03d/%02d.jpg‘ij);
pic = imread (path); %read one picture
%Make Data Add pic into Data
pic_line = pic(1:147*137); %The pic size is 147*137
%pic_line is 1*N N=147*137. from up to
%downleft to right.
%Reshape 2D image to 1D image
%vectors
Data = [Data;double(pic_line)]; %add pic_line into Data
end
end
% End of Load Data
%%%%%%%%%%%%%%%%%%%%%%%Substract mean from Data and make covariance from centering Data
samplemean = mean(Data); %mean pic 1*N
for k = 1:(Num_subject * Train_num_image)
xmean(k:)=Data(k:)-samplemean; %Normalize
end %xmean is M*N each line is one pic
%data(mean data) be normalized
sigma = xmean *xmean‘; %M*M here is 120*120
[V D]=eig(sigma); %calculate the eigenvalue&eigenvector
%eigenvalue in Dand vectors in V
D1=diag(D); %the eigenvalues
%%%%%%%%%%%%%%%%%%%%%%%% Sorting and eliminating eigenvalues
% At first : sort desc
Dsort=flipud(D1);
Vsort=fliplr(V);
%choose part eigenvalues
Dsum = sum(Dsort); %sum of the eigenvalueswe only choose 80%
%we have different ways to choose
%eigenvalues we need90%or>1……
temp_sum = 0;
p = 0;
while(temp_sum/Dsum<0.8)
p = p+1;
temp_sum = sum(Dsort(1:p));
end
%End of sort part
%%%%%%%%%%%%%%%%%%%%%%%Train Step: get the coordinate system
i=1;
while(i<=p && Dsort(i)>0)
face_base(:i) = Dsort(i)^(-1/2) * xmean‘ * Vsort (:i);
i=i+1;
end
% Dsort(i)^(-1/2) used to normalize make variance=1
% face_base is N*p
% xmean‘ * Vsort (:i); is change small matrix to big matrix. CHACHENG(Chinese)
%next sentence is vary important is our train result
allcoor = Data * face_base;
%End of training
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Draw part
%draw CDF
x = Dsort (1:p);
x = flipud (x);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4982 2011-04-08 00:32 PCA pro\PCA.m
文件 12548 2010-07-09 09:46 PCA pro\FaceDB_yaleA\015\01.jpg
文件 14561 2010-07-09 09:46 PCA pro\FaceDB_yaleA\015\02.jpg
文件 14677 2010-07-09 09:46 PCA pro\FaceDB_yaleA\015\03.jpg
文件 12028 2010-07-09 09:46 PCA pro\FaceDB_yaleA\015\04.jpg
文件 14675 2010-07-09 09:46 PCA pro\FaceDB_yaleA\015\05.jpg
文件 14715 2010-07-09 09:46 PCA pro\FaceDB_yaleA\015\06.jpg
文件 11577 2010-07-09 09:46 PCA pro\FaceDB_yaleA\015\07.jpg
文件 14297 2010-07-09 09:46 PCA pro\FaceDB_yaleA\015\08.jpg
文件 14208 2010-07-09 09:46 PCA pro\FaceDB_yaleA\015\09.jpg
文件 14434 2010-07-09 09:46 PCA pro\FaceDB_yaleA\015\10.jpg
文件 14699 2010-07-09 09:46 PCA pro\FaceDB_yaleA\015\11.jpg
文件 12769 2010-07-09 09:43 PCA pro\FaceDB_yaleA\014\01.jpg
文件 13018 2010-07-09 09:43 PCA pro\FaceDB_yaleA\014\02.jpg
文件 12323 2010-07-09 09:43 PCA pro\FaceDB_yaleA\014\03.jpg
文件 12434 2010-07-09 09:43 PCA pro\FaceDB_yaleA\014\04.jpg
文件 12542 2010-07-09 09:43 PCA pro\FaceDB_yaleA\014\05.jpg
文件 12542 2010-07-09 09:43 PCA pro\FaceDB_yaleA\014\06.jpg
文件 11967 2010-07-09 09:43 PCA pro\FaceDB_yaleA\014\07.jpg
文件 12467 2010-07-09 09:43 PCA pro\FaceDB_yaleA\014\08.jpg
文件 12568 2010-07-09 09:43 PCA pro\FaceDB_yaleA\014\09.jpg
文件 12610 2010-07-09 09:43 PCA pro\FaceDB_yaleA\014\10.jpg
文件 12585 2010-07-09 09:43 PCA pro\FaceDB_yaleA\014\11.jpg
文件 12124 2010-07-09 09:42 PCA pro\FaceDB_yaleA\013\01.jpg
文件 13003 2010-07-09 09:42 PCA pro\FaceDB_yaleA\013\02.jpg
文件 13199 2010-07-09 09:42 PCA pro\FaceDB_yaleA\013\03.jpg
文件 11922 2010-07-09 09:42 PCA pro\FaceDB_yaleA\013\04.jpg
文件 12076 2010-07-09 09:42 PCA pro\FaceDB_yaleA\013\05.jpg
文件 12831 2010-07-09 09:42 PCA pro\FaceDB_yaleA\013\06.jpg
文件 11613 2010-07-09 09:42 PCA pro\FaceDB_yaleA\013\07.jpg
............此处省略160个文件信息
- 上一篇:ACCESS 做的销售管理
- 下一篇:薛定宇教授 ctrllab工具箱3.0
相关资源
- MATLAB Deep Learning: With Machine Learning Ne
- 降维技术matlab工具箱
- polsarpro,matlab、Pauli、Yamaguchi、Cloud
- matlab2015b 32位激活文件
- viola_jones 的haar 特征检测的matlab 程序
- HDR_image-master MATLAB仿真程序
- Matlab编程实现LSB信息的隐藏与提取
- 用matlab写的matting的代码
- 用matlab写的图像分割的代码
- 人脸识别系统
- (Matlab 2014a 破解Crack.rar
- ( 协作通信-AF、DF的MATLAB仿真解压密
- MATLAB设计FPGA实现联合ISE和Modelsim仿真
- sift matlab代码
- Z-Buffer消隐算法的Matlab实现
- 用四阶统计量方法对图像特征进行提
- Matlab 2015b Win32 Crack
- matlab下的概率密度函数
- OFDM-MIMOMATLAB
- MATLAB下PSAT工具箱使用说明中文版
- cplex 12.4 MATLAB工具箱
- matlab connector
- 高斯模糊图像的盲复原
- 精通MATLAB数字图像处理2015的源代码
- 精通Matlab图形绘制
- 扩频通信系统的MATLAB仿真
- 一个通信抗干扰仿真MATLAB代码
- bayes分类器完整版代码
- 数字与图像处理matlab课程设计
- Matlab科学计算与可视化仿真宝典-源码
评论
共有 条评论