function [] = reconstruct()
load C:\att_faces\model.mat;
% 计算新图片在特征子空间中的系数
a1 = imread('C:\Users\xuxiaoxue\Desktop\att_faces\s3\1.pgm');
a2 = imread('C:\Users\xuxiaoxue\Desktop\att_faces\s2\10.pgm');
a3=imread('C:\Users\xuxiaoxue\Desktop\att_faces\1.pgm');
a11=imnoise(a1,'gaussian',0,0.001);
a22=imnoise(a2,'gaussian',0,0.001);
a33=imnoise(a3,'gaussian',0,0.001);
b1=a11(1:112*92); % b 是行矢量 1×N,其中N=10304,提取顺序是先列后行,即从上到下,从左到右
b2=a22(1:112*92); % b 是行矢量 1×N,其中N=10304,提取顺序是先列后行,即从上到下,从左到右
b3=a33(1:112*92); % b 是行矢量 1×N,其中N=10304,提取顺序是先列后行,即从上到下,从左到右
b1=im2double(b1);
b2=im2double(b2);
b3=im2double(b3);
b1=b1-samplemean;
b2=b2-samplemean;
b3=b3-samplemean;
c1 = b1 * base; % c 是图片a 在子空间中的系数, 是1*p 行矢量
c2 = b2 * base; % c 是图片a 在子空间中的系数, 是1*p 行矢量
c3 = b3 * base; % c 是图片a 在子空间中的系数, 是1*p 行矢量
% 根据特征系数及特征脸重建图
% 前15 个
t = 15;
temp1 = base(:,1:t) * c1(1:t)';
temp1 = temp1 + samplemean';
imwrite(mat2gray(reshape(temp1, 112,92)),'C:\Users\xuxiaoxue\Desktop\att_faces\s3\t11.pgm');
temp2 = base(:,1:t) * c2(1:t)';
temp2 = temp2 + samplemean';
imwrite(mat2gray(reshape(temp2, 112,92)),'C:\Users\xuxiaoxue\Desktop\att_faces\s2\t12.pgm');
temp3 = base(:,1:t) * c3(1:t)';
temp3 = temp3 + samplemean';
imwrite(mat2gray(reshape(temp3, 112,92)),'C:\Users\xuxiaoxue\Desktop\att_faces\t13.pgm');
% 前50 个
t=50;
temp1 = base(:,1:t) * c1(1:t)';
temp1 = temp1 + samplemean';
imwrite(mat2gray(reshape(temp1, 112,92)),'C:\Users\xuxiaoxue\Desktop\att_faces\s3\t21.pgm');
temp2 = base(:,1:t) * c2(1:t)';
temp2 = temp2 + samplemean';
imwrite(mat2gray(reshape(temp2, 112,92)),'C:\Users\xuxiaoxue\Desktop\att_faces\s2\t22.pgm');
temp3 = base(:,1:t) * c3(1:t)';
temp3 = temp3 + samplemean';
imwrite(mat2gray(reshape(temp3, 112,92)),'C:\Users\xuxiaoxue\Desktop\att_faces\t23.pgm');
% 前100 个
t = 100;
temp1 = base(:,1:t) * c1(1:t)';
temp1 = temp1 + samplemean';
imwrite(mat2gray(reshape(temp1, 112,92)),'C:\Users\xuxiaoxue\Desktop\att_faces\s3\t31.pgm');
temp2 = base(:,1:t) * c2(1:t)';
temp2 = temp2 + samplemean';
imwrite(mat2gray(reshape(temp2, 112,92)),'C:\Users\xuxiaoxue\Desktop\att_faces\s2\t32.pgm');
temp3 = base(:,1:t) * c3(1:t)';
temp3 = temp3 + samplemean';
imwrite(mat2gray(reshape(temp3, 112,92)),'C:\Users\xuxiaoxue\Desktop\att_faces\t33.pgm');
% 前150 个
t = 150;
temp1 = base(:,1:t) * c1(1:t)';
temp1 = temp1 + samplemean';
imwrite(mat2gray(reshape(temp1, 112,92)),'C:\Users\xuxiaoxue\Desktop\att_faces\s3\t41.pgm');
temp2 = base(:,1:t) * c2(1:t)';
temp2 = temp2 + samplemean';
imwrite(mat2gray(reshape(temp2, 112,92)),'C:\Users\xuxiaoxue\Desktop\att_faces\s2\t42.pgm');
temp3 = base(:,1:t) * c3(1:t)';
temp3 = temp3 + samplemean';
imwrite(mat2gray(reshape(temp3, 112,92)),'C:\Users\xuxiaoxue\Desktop\att_faces\t43.pgm');;
% 前199 个
t = 199;
temp1 = base(:,1:t) * c1(1:t)';
temp1 = temp1 + samplemean';
imwrite(mat2gray(reshape(temp1, 112,92)),'C:\Users\xuxiaoxue\Desktop\att_faces\s3\t51.pgm');
temp2 = base(:,1:t) * c2(1:t)';
temp2 = temp2 + samplemean';
imwrite(mat2gray(reshape(temp2, 112,92)),'C:\Users\xuxiaoxue\Desktop\att_faces\s2\t52.pgm');
temp3 = base(:,1:t) * c3(1:t)';
temp3 = temp3 + samplemean';
imwrite(mat2gray(reshape(temp3, 112,92)),'C:\Users\xuxiaoxue\Desktop\att_faces\t53.pgm');
figure,
subplot(121),imshow(a11);title('加入高斯噪声');
subplot(122),imshow('C:\Users\xuxiaoxue\Desktop\att_faces\s3\t51.pgm');title('重建图像');
figure,
subplot(121),imshow(a22);title('加入高斯噪声');
subplot(122),imshow('C:\Users\xuxiaoxue\Desktop\att_faces\s2\t52.pgm');title('重建图像');
figure,
subplot(121),imshow(a33);title('加入高斯噪声');
subplot(122),imshow('C:\Users\xuxiaoxue\Desktop\att_faces\t53.pgm');title('重建图像');
figure,
subplot(122),imshow('C:\Users\xuxiaoxue\Desktop\att_faces\t53.pgm');title('重建图像');
subplot(2,3,1),imshow(imread('C:\att_faces\s3\1.pgm'));title('original');
subplot(2,3,2),imshow(imread('C:\\att_faces\s2\10.pgm'));title('original');
subplot(2,3,3),imshow(imread('C:\att_faces\1.pgm'));title('original');
subplot(2,3,4),imshow(imread('C:\att_faces\t51.pgm'));title('重建');
subplot(2,3,5),imshow(imread('C:\att_faces\t52.pgm'));title('重建');
subplot(2,3,6),imshow(imread('C:\att_faces\t53.pgm'));title('重建')
end
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本科期间做的一个课程设计,觉得比较好玩,现将之记录下来。其中包含实验所用图库及源程序。 实验目的: (1)学习主成分分析(PCA)的基础知识; (2)了解PCA在人脸识别与重建方面的应用; (3)认识数据降维操作在数据处理中的重要作用; (4)学习使用MATLAB软件实现PCA算法,进行人脸识别,加深其在数字图像处理中解决该类问题的应用流程。
资源推荐
资源详情
资源评论
收起资源包目录
基于主成分分析(PCA)的人脸识别实验设计 (639个子文件)
reconstruct2.m 4KB
reconstruct4.m 4KB
reconstruct3.m 4KB
reconstruct1.m 4KB
FaceRec.m 3KB
eigface.m 2KB
model.mat 15.06MB
1.pgm 907KB
7.pgm 10KB
7.pgm 10KB
t52.pgm 10KB
t12.pgm 10KB
3.pgm 10KB
4.pgm 10KB
2.pgm 10KB
5.pgm 10KB
10.pgm 10KB
2.pgm 10KB
6.pgm 10KB
t22.pgm 10KB
4.pgm 10KB
7.pgm 10KB
9.pgm 10KB
10.pgm 10KB
6.pgm 10KB
1.pgm 10KB
6.pgm 10KB
7.pgm 10KB
3.pgm 10KB
t32.pgm 10KB
10.pgm 10KB
10.pgm 10KB
8.pgm 10KB
1.pgm 10KB
7.pgm 10KB
2.pgm 10KB
9.pgm 10KB
4.pgm 10KB
10.pgm 10KB
2.pgm 10KB
t42.pgm 10KB
4.pgm 10KB
8.pgm 10KB
1.pgm 10KB
8.pgm 10KB
3.pgm 10KB
5.pgm 10KB
1.pgm 10KB
6.pgm 10KB
5.pgm 10KB
5.pgm 10KB
3.pgm 10KB
t12.pgm 10KB
9.pgm 10KB
5.pgm 10KB
4.pgm 10KB
9.pgm 10KB
10.pgm 10KB
1.pgm 10KB
7.pgm 10KB
3.pgm 10KB
9.pgm 10KB
9.pgm 10KB
8.pgm 10KB
8.pgm 10KB
1.pgm 10KB
6.pgm 10KB
6.pgm 10KB
2.pgm 10KB
4.pgm 10KB
10.pgm 10KB
8.pgm 10KB
8.pgm 10KB
5.pgm 10KB
3.pgm 10KB
2.pgm 10KB
3.pgm 10KB
6.pgm 10KB
2.pgm 10KB
9.pgm 10KB
1.pgm 10KB
4.pgm 10KB
5.pgm 10KB
7.pgm 10KB
8.pgm 10KB
4.pgm 10KB
1.pgm 10KB
4.pgm 10KB
5.pgm 10KB
9.pgm 10KB
8.pgm 10KB
5.pgm 10KB
8.pgm 10KB
4.pgm 10KB
5.pgm 10KB
6.pgm 10KB
3.pgm 10KB
10.pgm 10KB
4.pgm 10KB
8.pgm 10KB
共 639 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
- mu63252024-05-12博主,为什么我下载之后没有办法运行
墨池有雨
- 粉丝: 114
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功