twodrecons.m

来自「两个文件」· M 代码 · 共 71 行

M
71
字号
%--------------------------------------------------------------
% 
% 
%--------------------------------------------------------------

%------------ function name ---------------- 

%Description	: 基于2DPCA的人脸重建
%Author	:	gongzzzz
%time	:	07-5-23
%Input  : 
%
%Output :
%参考文献:	Yang Jian,Zhang David,F.Frangi Alejandro,Yang Jingyu.
%		Two-dimensional PCA:A new approach to appearance-based
%		face representation and recognition.IEEE Trans.on Pattern %
%		Analysis and Machine Intelligence,26(2004)1,131-137.
%
%function [] = TwoDRecons()
	
%%%%%%%%根据测试需要修改的参数%%%%%%%
%	load F:\BJ3D\gray\model.mat;
	load e:\ORL\model2D.mat;
	imgPath = 'D:\test\s40_10';
	a=imread([imgPath '.jpg']);
	imgHei = 112;
	imgWid = 92;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

	b=double(a);
	b=b-Avg;

	% 计算新图片在特征子空间中的系数
	c = b * vsort;   % c 是图片a在子空间中的系数, 是1*p行矢量

	imwrite(mat2gray(Avg),'D:\test\avg.bmp');
	% 根据特征系数及特征脸重建图

	% 前1个 
	t = 1;
	temp = c(:,1:t) * vsort(:,1:t)';
	temp = temp + Avg;
	imwrite(mat2gray(temp),[imgPath '_p21.bmp']);

	% 前10个 
	t = 10;
	temp = c(:,1:t) * vsort(:,1:t)';
	temp = temp + Avg;
	imwrite(mat2gray(temp),[imgPath '_p22.bmp']);

	% 前20个 
	t = 20;
	temp = c(:,1:t) * vsort(:,1:t)';
	temp = temp + Avg;
	imwrite(mat2gray(temp),[imgPath '_p23.bmp']);

	% 前92个 
	t = 92;
	temp = c(:,1:t) * vsort(:,1:t)';
	temp = temp + Avg;
	imwrite(mat2gray(temp),[imgPath '_p24.bmp']);






	


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?