|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
我运用下面的代码进行小波消噪,为什么用硬阈值得到的信噪比反而比用软阈值得到的信噪比大?请大家帮忙指正,不胜感激。谢谢。下面是代码
clear;
load noisbump;
NX= noisbump;
N=length(NX);
wname='sym4';%选sym4小波基
lev=4;%4层分解4
[c,l]=wavedec(NX,lev,wname);
a4=appcoef(c,l,wname,lev);
d4=detcoef(c,l,4);
d3=detcoef(c,l,3);
d2=detcoef(c,l,2);
d1=detcoef(c,l,1);
cD=[d1,d2,d3,d4];
sigma=median(abs(NX))/0.6745;
thr(1)=sigma*sqrt(2*log(N))/log(1+1);
thr(2)=sigma*sqrt(2*log(N))/log(2+1);
thr(3)=sigma*sqrt(2*log(N))/log(3+1);
thr(4)=sigma*sqrt(2*log(N))/log(4+1);
cD1=wthresh(d1,'s',thr(1));
cD2=wthresh(d2,'s',thr(2));
cD3=wthresh(d3,'s',thr(3));
cD4=wthresh(d4,'s',thr(4));
cd=[a4, cD4,cD3,cD2,cD1];
c=cd;
XD=waverec(c,l,wname);
figure(1);
subplot(2,2,1);
plot(NX);
ylabel('幅值 A');
title('加噪信号');
subplot(2,2,2);
plot(XD);
title('软阈值处理') ;
[c,l]=wavedec(NX,lev,wname);
a4=appcoef(c,l,wname,lev);
d4=detcoef(c,l,4);
d3=detcoef(c,l,3);
d2=detcoef(c,l,2);
d1=detcoef(c,l,1);
cD=[d1,d2,d3,d4];
sigma=median(abs(NX))/0.6745;
thr(1)=sigma*sqrt(2*log(N))/log(1+1);
thr(2)=sigma*sqrt(2*log(N))/log(2+1);
thr(3)=sigma*sqrt(2*log(N))/log(3+1);
thr(4)=sigma*sqrt(2*log(N))/log(4+1);
cD1=wthresh(d1,'h',thr(1));
cD2=wthresh(d2,'h',thr(2));
cD3=wthresh(d3,'h',thr(3));
cD4=wthresh(d4,'h',thr(4));
cd=[a4, cD4,cD3,cD2,cD1];
c=cd;
yh=waverec(c,l,wname);
subplot(2,2,3);
plot(yh);
ylabel('幅值 A');
title('硬阈值处理');
y1=sum((NX).^2) ;
yys= sum ((XD-NX).^2);
yyh= sum ((yh-NX).^2);
snrys=10*log10((y1/yys));%软阈值去噪信号信噪比
fprintf('软阈值去噪信号信噪比%4.4f\n',snrys);
snryh=10*log10((y1/yyh));%硬阈值去噪信号信噪比
fprintf('硬阈值去噪信号信噪比%4.4f\n',snryh);
|
|