高分求matlab pca人脸识别程序

来源:百度知道 编辑:UC知道 时间:2024/06/23 05:18:47
用subplot,imshow,imread,遍历并显示图库文件夹中的人脸图像(用循环)。运行后图像要显示成矩阵模式的,还得产生统一矩阵和均值矩阵。
大侠们帮帮小妹吧,自己编的最好,如果从网上扒的最好能有简单的注解!

clc
clear all
close all
clear memory
nump=40; %no_of_classes
nots=5; %no_of_training_set
D=pwd;
cd([D, '\ORLDatabase']);
[face,MAP]=imread('face1.bmp');
[a,b]=size(face);
counter=0;
for i=1:nump
for j=1:nots
file=['face' int2str((i-1)*10+j) '.bmp'];
[face,MAP]=imread(file);
grayface=ind2gray(face,MAP);
counter=counter+1;
X(counter,:)=double(reshape(grayface,a*b,1));
end
end
counter=0;
for i=1:nump
for j=nots+1:10
file=['face' int2str((i-1)*10+j) '.bmp'];
[face,MAP]=imread(file);
grayface=ind2gray(face,MAP);
counter=counter+1;
Y(counter,:)=double(reshape(grayface,a*b,1));
end
end
cd(D)
clear memory
clc
AVERAGE=mean(x')';
Average_Matrix=(