MATLAB下人脸图像的PCA重构matlab代码(共5页).doc
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《MATLAB下人脸图像的PCA重构matlab代码(共5页).doc》由会员分享,可在线阅读,更多相关《MATLAB下人脸图像的PCA重构matlab代码(共5页).doc(5页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、精选优质文档-倾情为你奉上MATLAB下人脸图像的PCA重构matlab代码主函数clc; clear all;newimage=double(zeros(112*6,92*5); M,sort_V,avg_face = averageface( );%返回去均值的矩阵和协方差,以及排列好的特征向量 k=1; new_sort_V =sort_V(1:10304,1:30);%取特征向量的前30个,并进行显示 for i=1:112:5*112+1 for j=1:92:4*92+1 newimage(i:i+111,j:j+91)=reshape(new_sort_V(:,k),112,92
2、); k=k+1; end end minum=min(min(newimage);%对特征向量进行标定 maxum=max(max(newimage); d=maxum-minum; newimage(:,:)=newimage(:,:)-minum; newimage(:,:)=newimage(:,:)/d; newimage(:,:)=newimage(:,:)*255; newimage=uint8(newimage); subplot(1,3,1); title(特征向量图); imshow(newimage);%显示前30个特征向量 avg_face=uint8(avg_face
3、); subplot(1,3,2) title(平均脸); imshow(avg_face); subplot(1,3,3) tyxs,re_newimage = touyingxishu( sort_V ,avg_face); imshow(re_newimage); 子函数function =img2txt()maindir = D:Image; subdir = dir( maindir ); % 先确定子文件夹 m=1;k=1;for i = 1 : length( subdir ) if( isequal( subdir( i ).name, . ) | isequal( subdi
4、r( i ).name, . ) | subdir( i ).isdir ) % 如果不是目录跳过 continue; end subdirpath = fullfile( maindir, subdir( i ).name, *.pgm ); images = dir( subdirpath ); % 在这个子文件夹下找后缀为pgm的文件 % 遍历每张图片 for j = 1 : length( images ) imagepath = fullfile( maindir, subdir( i ).name, images( j ).name ); imgdata = imread( ima
5、gepath ); % 这里进行你的读取操作 row, col=size(imgdata); %将数据写入txt中 fid = fopen(C:UsersAdministratorDesktop编程实验材料att_faces,s,int2str(m),int2str(k),.txt,w); %新建txt文件存储图像的坐标和灰度值 for I=1:row for J=1:col fprintf(fid,%03dt,imgdata(I,J); end fprintf(fid,n) ; end fclose(fid); k=k+1; end m=m+1; k=1;end function M,sor
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- MATLAB 下人 图像 PCA 代码
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内