www.pudn.com > GaitRecognition.rar > generateGEI.asv, change:2012-11-03,size:1836b


clear; 
clc; 
setPath; 
maxWidth=93;%由上面计算所得 
tic; 
cd(normalizationPath);%进入数据目录,包含若干人的步态序列 
normalizationDir=dir('.'); 
for xPerson=3:length(normalizationDir)%遍历所有文件夹 
    cd(normalizationDir(xPerson).name);%进入某人的步态序列目录 
    for x_condition=1:5:50-4 
        cd([pwd '\' xCondition(x_condition:x_condition+4)]);%进入一个条件下的序列目录 
        cd([pwd '\' xAngle]);%进入90°视角的目录        
         
        List=dir('*.png'); 
        frameWidth=zeros(1,length(List));%用来保存每一张图的宽度 
        for i=1:length(List) 
            picSize=size(imread(List(i).name)); 
            frameWidth(1,i)=picSize(2); 
        end 
 
        for iResize=1:length(List)  
            if mod(maxWidth-frameWidth(iResize),2)==1%奇数 
                    addSpace=(maxWidth-frameWidth(iResize)+1)/2; 
                    resizePic=[zeros(picSize(1),addSpace),imread(List(iResize).name),zeros(picSize(1),addSpace-1)]; 
            else 
                    addSpace=(maxWidth-frameWidth(iResize))/2; 
                    resizePic=[zeros(picSize(1),addSpace),imread(List(iResize).name),zeros(picSize(1),addSpace)]; 
            end 
 
            imwrite(resizePic,[strrep(pwd,[rootPath 'normalization\'],resizePath) '\' List(iResize).name],'png'); 
        end 
         
        cd ..%从90°视角目录往上一层  
        cd ..%从一个条件下的序列目录往上一层  
   end 
cd ..%从某人步态序列目录往上一层 
end;% 
disp('resize time:'); 
toc; 
clear; 
%进入到resize文件夹下 
 
 
   
List=dir('*.png'); 
picNum=length(List); 
picSize=size(imread(List(1).name)); 
 
 
%计算能量图 
GEI=zeros(picSize(1),picSize(2));%构建与原图一样大小的零矩阵 
for i=1:picNum 
GEI=GEI+double(imread(List(i).name)); 
end 
GEI=GEI/picNum; 
imwrite(uint8(GEI),[strrep(pwd,rootPath,GEIPath) '\' List(i).name '.png'],'png'); 
end