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
最新资源
- [AB PLC例程源码]LONG DURATION PRECISION TIMER.zip
- [AB PLC例程源码]logix5000的一个例程,关于显性连接.zip
- [AB PLC例程源码]Micrologix 1000 DDE Demo.zip
- [AB PLC例程源码]MicroLogix 1500 ASCII Input example.zip
- [AB PLC例程源码]Micrologix 1200 HSC Configuration.zip
- [AB PLC例程源码]MicroLogix 1100 Ethernet to Cognex Message.zip
- [AB PLC例程源码]MicroLogix 1500 DNet MSG to multiple PF40.zip
- [AB PLC例程源码]micrologix 1500 sequence control and valve bank control of vacuum pump set.zip
- [AB PLC例程源码]micrologix1500高速脉冲输出例子.zip
- [AB PLC例程源码]ML1000 monitors call for input signal; controls loader & cleaner conveyor.zip
- [AB PLC例程源码]MicroLogix应用案例.zip
- [AB PLC例程源码]Misbehaving Axis.zip
- [AB PLC例程源码]ML1200 prog for precision chain oiling.zip
- [AB PLC例程源码]mlhem slc500 program.zip
- [AB PLC例程源码]ML1000 Washing Machine Program using a step counter as a sequencer.zip
- [AB PLC例程源码]MODBUS例子程序.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


