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
墨池有雨
- 粉丝: 113
- 资源: 6
最新资源
- springboot060师生共评的作业管理系统设计与实现.zip
- springboot257基于SpringBoot的中山社区医疗综合服务平台.zip
- MATLAB程序:多微网优化,多能源系统优化,多Energyhub 协同优化 摘要:基于多能量集成的优点,本文建立了一个基于交互控制的双级两阶段框架,以实现互联多能量系统(MESs)之间的最佳能量供应
- springboot062购物推荐网站的设计与实现.zip
- springboot258流浪动物救助网站.zip
- springboot257基于SpringBoot的中山社区医疗综合服务平台_0303174040.zip
- 6自由度机械臂MATLAB仿真KUKA KR6机器人仿真 simulink simscape 逆向运动学,正向运动学 非线性控制
- springboot063知识管理系统.zip
- springboot259交通管理在线服务系统的开发.zip
- springboot259交通管理在线服务系统的开发_0303174040.zip
- springboot064高校学科竞赛平台.zip
- springboot260火锅店管理系统.zip
- springboot260火锅店管理系统_0303174040.zip
- GlobalUrban-ISA-GS.rar 全球城市边界、不透水表面及绿地数据集下载
- Labview工业以太网Ethernetip TCP通讯培训支持所有Ethernetip协议的设备和模块常用罗克韦尔 ABPLC,欧姆龙NXNJPLC数据标签通讯让你从原理上学会从此定值自己的通讯协议
- springboot261高校专业实习管理系统的设计和开发.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈