小波变换的图像处理%MATLAB2维小波变换经典程序%FWT_DB.M;%此示意程序用DWT实现二维小波变换%编程时间2004-4-10,编程人沙威%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%clear;clc;T=256;%图像维数SUB_T=T/2;%子图维数%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%1.调原始图像矩阵loadwbarb;%下载图像f=X;%原始图像%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2.进行二维小波分解l=wfilters('db10','l');%db10(消失矩为10)低通分解滤波器冲击响应(长度为20)L=T-length(l);l_zeros=[l,zeros(1,L)];%矩阵行数与输入图像一致,为2的整数幂h=wfilters('db10','h');%db10(消失矩为10)高通分解滤波器冲击响应(长度为20)h_zeros=[h,zeros(1,L)];%矩阵行数与输入图像一致,为2的整数幂fori=1:T;%列变换row(1:SUB_T,i)=dyaddown(ifft(fft(l_zeros).*fft(f(:,i)'))).';%圆周卷积FFTrow(SUB_T+1:T,i)=dyaddown(ifft(fft(h_zeros).*fft(f(:,i)'))).';%圆周卷积FFTend;forj=1:T;%行变换line(j,1:SUB_T)=dyaddown(ifft(fft(l_zeros).*fft(row(j,:))));%圆周卷积FFTline(j,SUB_T+1:T)=dyaddown(ifft(fft(h_zeros).*fft(row(j,:))));%圆周卷积FFTend;decompose_pic=line;%分解矩阵%图像分为四块lt_pic=decompose_pic(1:SUB_T,1:SUB_T);%在矩阵左上方为低频分量--fi(x)*fi(y)rt_pic=decompose_pic(1:SUB_T,SUB_T+1:T);%矩阵右上为--fi(x)*psi(y)lb_pic=decompose_pic(SUB_T+1:T,1:SUB_T);%矩阵左下为--psi(x)*fi(y)rb_pic=decompose_pic(SUB_T+1:T,SUB_T+1:T);%右下方为高频分量--psi(x)*psi(y)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%3.分解结果显示figure(1);colormap(map);subplot(2,1,1);image(f);%原始图像title('originalpic');subplot(2,1,2);image(abs(decompose_pic));%分解后图像title('decomposedpic');figure(2);colormap(map);subplot(2,2,1);image(abs(lt_pic));%左上方为低频分量--fi(x)*fi(y)title('\Phi(x)*\Phi(y)');subplot(2,2,2);image(abs(rt_pic));%矩阵右上为--fi(x)*psi(y)title('\Phi(x)*\Psi(y)');subplot(2,2,3);image(abs(lb_pic));%矩阵左下为--psi(x)*fi(y)title('\Psi(x)*\Phi(y)');subplot(2,2,4);image(abs(rb_pic));%右下方为高频分量--psi(x)*psi(y)title('\Psi(x)*\Psi(y)');%%%%%%%
1