资源简介
NULL
博文链接:https://gongwanlu.iteye.com/blog/1018161
代码片段和文件信息
%**********************************************
% 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.m
----------- --------- ---------- ----- ----
4982 1
- 上一篇:模糊PID控制器
- 下一篇:LMDMATLAB代码
相关资源
- 惯导工具箱MATLAB
- MATLAB神经网络工具箱中的神经网络模
- 光谱读入、降噪和去背景一体化matl
- 多旅行商matlab实验源码
- 基于天牛须搜索算法优化BP神经网络
- topsis matlab 源程序
- 3D文件清理与保存工具
- pso工具箱 matlab
- MATLAB 回声状态网络ESN工具箱 ESN_Tool
- 数字信号处理实验指导书MATLAB版源码
- 数字图像处理matlab版本书中源程序及
- MATLAB 求解PDE偏微分方程工具箱及
- DE差分进化算法MATLAB源码,中文详细注
- MARLAB 入门MATLAB 数学工具软件 简明教
- 人脸识别matlab源码
- 四元数matlab工具箱2.6版
- 正交信号修正OSC源码
- 数学形态学 源码
- 脉动风功率谱源码
- matlab神经网络工具箱系统预测
- matlab中的计时工具timeit.m
- matlab can总线工具箱介绍
- dipum_toolbox_2.0.1.zip数字图像处理课本自
- labview模型接口工具箱.rar
- psot工具箱及使用说明.zip
- 基于Matlab2018b的SimMechanics工具箱建立的
- Chaos Toolbox Ver.2.0混沌全部工具箱
- 线性预测及其Matlab实现,源码,程序
- matab源码 fmincon函数实用
- 图像lbp特征提取的MATLAB实现源码
评论
共有 条评论