www.pudn.com > facerecognitionmatlab.rar > CalculateWavelet.m


function W=CalculateWavelet(width,height); 
%计算小波矩阵W;将结果保存在文件wavele.dat中; 
%计算小波变换矩阵簇; 
d=2*pi; 
x0=width/2+i*height/2; 
for v=1:5 
    for u=1:8 
        k1=pi*pow2(-(v+1)/2)*cos(pi*(u-1)/8); 
        k2=pi*pow2(-(v+1)/2)*sin(pi*(u-1)/8); 
        k=pi*pow2(-(v+1)/2)*exp(i*pi*(u-1)/8); 
        for x1=1:width 
            for x2=1:height 
                x=x1+i*x2-x0; 
                tmp1=abs(k*k)/d/d; 
                tmp2=exp(-abs(k*k)*abs(x*x)/2/d/d); 
                tmp3=exp(i*(k1*(x1-width/2)+k2*(x2-height/2)))-exp(-d*d/2); 
%                W(v,u,x1,x2)=tmp2; 
                W(v,u,x1,x2)=tmp1*tmp2*tmp3; 
            end 
        end 
   end 
   width=width+3; 
   height=height+3; 
end 
width=width-3*5;height=height-3*5; 
%画图 
for v=1:5 
    for u=1:8:4 
        %得到对应某个k的Wk; 
        for x1=1:width 
            for x2=1:height 
                Wk(x1,x2)=W(v,u,x1,x2); 
            end 
        end 
        figure; 
        WkReal=real(Wk); 
        xa1=[1:1:width]; 
        xa2=[1:1:height]; 
        %surf(xa1,xa2,WkReal,'FaceColor','interp',... 
        %'EdgeColor','none',... 
        %'FaceLighting','phong'); 
        surf(WkReal); 
        %mesh(WkReal); 
    end 
    width=width+3; 
    height=height+3; 
end 
 
save('d:\wavelet.dat','W')