xmy827
2009-05-18, 19:42
下面的程序是别人给的 想问下这个程序是实现什么的 主要过程怎么样的
function deccoef = dk(x,wave,dim);
%deccoef = dk(x,wave,dim)
%x信号,wave所选小波,dim为分解的层数,deccoef为分解后的系数
[L H]=wfilters(wave,'d');
N=length(x);
h=length(L);
deccoef=zeros(dim+1,N);
ca=x;
for j=1:dim
ca = wextend('1D','per',ca,h/2);
A=conv(ca,L);
D=conv(ca,H);
A=wkeep(A,N,h+1);
D=wkeep(D,N,h+1);
deccoef(j,:)=D;
ca=A;
LL=zeros(1,2*h);
LL(1:2:end)=L;
HH=zeros(1,2*h);
HH(1:2:end)=H;
L=LL;
H=HH;
h=length(L);
end
deccoef(j+1,:)=A;
[x fs bit]=wavread('5');% figure(2)
% subplot(511)
[thr,sorh,keepapp]=ddencmp('den','wv',x);
[x,cxc,lxc,perf,perfl2]=wdencmp('gbl',x,'db3',3,thr,sorh,keepapp);
plot(x);
title('原图像')
ca=dk(x,'db3',4);
figure(2)
plot(ca(5,:));
title('ca4');
figure(3)
plot(ca(4,:))
title('cd4')
figure(4)
plot(ca(3,:))
title('cd3')
figure(5)
plot(ca(2,:))
title('cd2')
figure(6)
plot(ca(1,:))
title('cd1')
function deccoef = dk(x,wave,dim);
%deccoef = dk(x,wave,dim)
%x信号,wave所选小波,dim为分解的层数,deccoef为分解后的系数
[L H]=wfilters(wave,'d');
N=length(x);
h=length(L);
deccoef=zeros(dim+1,N);
ca=x;
for j=1:dim
ca = wextend('1D','per',ca,h/2);
A=conv(ca,L);
D=conv(ca,H);
A=wkeep(A,N,h+1);
D=wkeep(D,N,h+1);
deccoef(j,:)=D;
ca=A;
LL=zeros(1,2*h);
LL(1:2:end)=L;
HH=zeros(1,2*h);
HH(1:2:end)=H;
L=LL;
H=HH;
h=length(L);
end
deccoef(j+1,:)=A;
[x fs bit]=wavread('5');% figure(2)
% subplot(511)
[thr,sorh,keepapp]=ddencmp('den','wv',x);
[x,cxc,lxc,perf,perfl2]=wdencmp('gbl',x,'db3',3,thr,sorh,keepapp);
plot(x);
title('原图像')
ca=dk(x,'db3',4);
figure(2)
plot(ca(5,:));
title('ca4');
figure(3)
plot(ca(4,:))
title('cd4')
figure(4)
plot(ca(3,:))
title('cd3')
figure(5)
plot(ca(2,:))
title('cd2')
figure(6)
plot(ca(1,:))
title('cd1')