%对一幅图像I进行M尺度的小波变换
function Im=dwt
p=imread('a.jpg');
q=rgb2gray(p);
I=imresize(q,[16,16]);
M=3;% M----小波变换的尺度
I1=double(I);
[m,n]=size(I);
Iout=zeros(size(I));
W1=zeros(size(I));
%=============Haar wavelete transform==================
W1=I1;
for k=1:M
for i=1:n
W1(:,i)=selfdwt(W1(:,i),1);%对列进行变换
end
for i=1:m
W1(i,:)=selfdwt(W1(i,:),2);%对行进行变换
end
for i=1:m
for j=1:n
Iout(i,j)=W1(i,j);
end
end
m=m/2;
n=n/2;
W1=zeros(m,n);
for i=1:m
for j=1:n
W1(i,j)=Iout(i,j);
end
end
end
%======================================================
Im=uint8(Iout.*28);
figure
imshow(Im)
title('after dwt')