matlab实现s小波变换代码
输入图像矩阵,输出一幅图像,分为四块;function wvlet=waveup1(x)
%function =waveup1(x)
x=double(x);
wvlet=x;
=size(x);
hc=hp/2;
lc=lp/2;
%奇偶列重排
for n=1:lc
j=n*2-1;
wvlet(:,n)=x(:,j);
wvlet(:,lc+n)=x(:,j+1);
end
%行变换开始
for n=1:lc-1
k=floor((wvlet(:,n)+wvlet(:,n+1))/2);
wvlet(:,lc+n)=wvlet(:,lc+n)-k;
end
k=floor((wvlet(:,lc)+wvlet(:,lc-1))/2);
wvlet(:,lp)=wvlet(:,lp)-k;
k=floor((wvlet(:,lc+2)+wvlet(:,lc+1))/4+0.5);
wvlet(:,1)=wvlet(:,1)+k;
for n=2:lc
k=floor((wvlet(:,lc+n)+wvlet(:,lc+n-1))/4+0.5);
wvlet(:,n)=wvlet(:,n)+k;
end
%行变换结束
x=wvlet;
%奇偶行重排
for n=1:hc
j=n*2-1;
wvlet(n,:)=x(j,:);
wvlet(hc+n,:)=x(j+1,:);
end
%列重排开始
for n=1:hc-1
k=floor((wvlet(n,:)+wvlet(n+1,:))/2);
wvlet(hc+n,:)=wvlet(hc+n,:)-k;
end
k=floor((wvlet(hc,:)+wvlet(hc-1,:))/2);
wvlet(hp,:)=wvlet(hp,:)-k;
k=floor((wvlet(hc+2,:)+wvlet(hc+1,:))/4+0.5);
wvlet(1,:)=wvlet(1,:)+k;
for n=2:hc
k=floor((wvlet(hc+n,:)+wvlet(hc+n-1,:))/4+0.5);
wvlet(n,:)=wvlet(n,:)+k;
end
%列重排结束
wvlet=uint8(wvlet);
ll=wvlet(1:hc,1:lc);
hl=wvlet(1:hc,lc+1:lp);
lh=wvlet(hc+1:hp,1:lc);
hh=wvlet(hc+1:hp,lc+1:lp); %function wvlet=waveup2(x)
function =waveup2(x)
x=double(x);
wvlet=x;
=size(x);
hc=hp/2;
lc=lp/2;
%奇偶列重排
for n=1:lc
j=n*2-1;
wvlet(:,n)=x(:,j);
wvlet(:,lc+n)=x(:,j+1);
end
%行变换开始
for n=1:lc-1
k=(wvlet(:,n)+wvlet(:,n+1))/2;
wvlet(:,lc+n)=wvlet(:,lc+n)-k;
end
k=(wvlet(:,lc)+wvlet(:,lc-1))/2;
wvlet(:,lp)=wvlet(:,lp)-k;
k=(wvlet(:,lc+2)+wvlet(:,lc+1))/4;
wvlet(:,1)=wvlet(:,1)+k;
for n=2:lc
k=(wvlet(:,lc+n)+wvlet(:,lc+n-1))/4;
wvlet(:,n)=wvlet(:,n)+k;
end
%行变换结束
x=wvlet;
%奇偶行重排
for n=1:hc
j=n*2-1;
wvlet(n,:)=x(j,:);
wvlet(hc+n,:)=x(j+1,:);
end
%列重排开始
for n=1:hc-1
k=(wvlet(n,:)+wvlet(n+1,:))/2;
wvlet(hc+n,:)=wvlet(hc+n,:)-k;
end
k=(wvlet(hc,:)+wvlet(hc-1,:))/2;
wvlet(hp,:)=wvlet(hp,:)-k;
k=(wvlet(hc+2,:)+wvlet(hc+1,:))/4;
wvlet(1,:)=wvlet(1,:)+k;
for n=2:hc
k=(wvlet(hc+n,:)+wvlet(hc+n-1,:))/4;
wvlet(n,:)=wvlet(n,:)+k;
end
%列重排结束
%wvlet=uint8(wvlet);
ll=wvlet(1:hc,1:lc);
hl=wvlet(1:hc,lc+1:lp);
lh=wvlet(hc+1:hp,1:lc);
hh=wvlet(hc+1:hp,lc+1:lp); function wvlet=waveup3(x)
%function =waveup3(x)
x=double(x);
wvlet=x;
=size(x);
hc=hp/2;
lc=lp/2;
%奇偶列重排
for n=1:lc
j=n*2-1;
wvlet(:,n)=x(:,j);
wvlet(:,lc+n)=x(:,j+1);
end
%行变换开始
for n=1:lc
wvlet(:,lc+n)=wvlet(:,lc+n)-wvlet(:,n);
end
for n=1:lc
k=wvlet(:,lc+n)/2-mod(wvlet(:,lc+n)/2,1);
wvlet(:,n)=wvlet(:,n)+k;
end
%行变换结束
x=wvlet;
%奇偶行重排
for n=1:hc
j=n*2-1;
wvlet(n,:)=x(j,:);
wvlet(hc+n,:)=x(j+1,:);
end
%列重排开始
for n=1:hc
wvlet(hc+n,:)=wvlet(hc+n,:)-wvlet(n,:);
end
for n=1:hc
k=wvlet(hc+n,:)/2-mod(wvlet(hc+n,:)/2,1);
wvlet(n,:)=wvlet(n,:)+k;
end
%列重排结束
%wvlet=uint8(wvlet);
ll=wvlet(1:hc,1:lc);
hl=wvlet(1:hc,lc+1:lp);
lh=wvlet(hc+1:hp,1:lc);
hh=wvlet(hc+1:hp,lc+1:lp); s小波是哪个小波啊,能不能详细描述一下这个程序的功能啊 该函数的功能:输入图像矩阵,输出一幅图像,分为四块
上面已经有相关说明了
页:
[1]