[XD,CXD,LXD] = wden(X,TPTR,SORH,SCAL,N,'wname'); CXD和 CLD为滤波后 XD的小波分解后的结构。 TPTR为阀值选择规则
'rigrsure' uses the principle of Stein's Unbiased Risk. 'heursure' is an heuristic variant of the first option. 'sqtwolog' for universal threshold
'minimaxi' for minimax thresholding (see thselect for more information) SORH ('s' or 'h') is for soft or hard thresholding
SCAL defines multiplicative threshold rescaling: 'one' for no rescaling,'sln' for rescaling using a single estimation of level noise based on first-level
coefficients,'mln' for rescaling done using level-dependent estimation of level nois
例子 1
% Set signal to noise ratio and set rand seed. snr = 3; init = 2055615866;
% a standard Gaussian white noise. [xref,x] = wnoise(3,11,snr,init);
% De-noise noisy signal using soft heuristic SURE thresholding % from the decomposition of x, at level 5 by sym8 wavelet. lev = 5;
xd = wden(x,'heursure','s','one',lev,'sym8'); subplot(611), plot(xref), axis([1 2048 -10 10]); title('Original signal');
subplot(612), plot(x), axis([1 2048 -10 10]);
8ddencmp,wdencmp去噪函数。
8.2 最理想的去噪方法阀值法。ddencmp,wdencmp函数。可以去除噪声,而不影响原信号 的尖峰,这是小波的优势。
[THR,SORH,KEEPAPP,CRIT] = ddencmp(IN1,IN2,X);产生的系数可以供wencmp函数使用。 [THR,SORH,KEEPAPP,CRIT] = ddencmp(den,wv,X);小波 [THR,SORH,KEEPAPP,CRIT] = ddencmp(den,wp,X);小波包 IN1 is 'den' for de-noising or 'cmp' for compression.
IN2 is 'wv' for wavelet or 'wp' for wavelet packet.
THR是阀值, SORH是软阀值或者硬阀值, KEEPAPP 保持相似系数, and CRIT (used only for wavelet packets) is the entropy name 例子 1
load sinsin;init=2055615866; randn('seed',init); x = X + 18*randn(size(X)); [thr,sorh,keepapp] = ddencmp('den','wv',x);
d = wdencmp('gbl',x,'db3',2,thr,sorh,keepapp);或者
[XC,CXC,LXC,PERF0,PERFL2] = wdencmp('lvd',C,L,'wname',N,THR,SORH)
例子 1 MATLAB的小波消噪程序(一)
t=0:1000; s=sin(0.03*t); subplot(3,1,1); 取信号。 plot(s); axis([0 1000 -1 1]); title('原始信号');
load noissin; ns=noissin; subplot(3,1,2); plot(ns); title('染噪信号'); %给该信号加噪声
xd=wden(ns,'minimaxi','s','one',5,'db3'); subplot(3,1,3); plot(xd); title('消噪信号'); %进行消噪处理
MATLAB的小波消噪程序(二)
%装载采集的信号 leleccum.mat load leleccum;
%=============================
%将信号中第 2000到第 3450个采样点赋给 s indx=2000:3450; s=leleccum(indx);
%============================= %画出原始信号 subplot(2,2,1); plot(s);
title('原始信号');
%=============================
%用 db1小波对原始信号进行 3层分解并提取系数 [c,l]=wavedec(s,3,'db1'); a3=appcoef(c,l,'db1',3); d3=detcoef(c,l,3); d2=detcoef(c,l,2); d1=detcoef(c,l,1);
%=============================
%对信号进行强制性消噪处理并图示结果 dd3=zeros(1,length(d3)); dd2=zeros(1,length(d2)); dd1=zeros(1,length(d1)); c1=[a3 dd3 dd2 dd1];
s1=waverec(c1,l,'db1'); subplot(2,2,2); plot(s1);grid;
title('强制消噪后的信号'); %=============================
%用默认阈值对信号进行消噪处理并图示结果 %用
ddencmp函数获得信号的默认阈值
[thr,sorh,keepapp]=ddencmp('den','wv',s);
s2=wdencmp('gbl',c,l,'db1',3,thr,sorh,keepapp); subplot(2,2,3); plot(s2);grid;
title('默认阈值消噪后的信号'); %============================= %用给定的软阈值进行消噪处理 softd1=wthresh(d1,'s',1.465); softd2=wthresh(d2,'s',1.823); softd3=wthresh(d3,'s',2.768); c2=[a3 softd3 softd2 softd1]; s3=waverec(c2,l,'db1'); subplot(2,2,4); plot(s3);grid;
title('给定软阈值消噪后的信号');
MATLAB的小波消噪程序(三)
y=linspace(.1,1,100); thr=0.28;
ythard=wthresh(y,'h',thr); ytsoft=wthresh(y,'s',thr); subplot(2,2,1); plot(y);
title('原始信号'); subplot(2,2,3); plot(ythard);
title('硬阈值信号'); subplot(2,2,4); plot(ytsoft);
title('软阈值信号');
MATLAB的小波消噪程序(四) %设置信噪比和随机种子值 snr=4;
init=2055615866;
%============================= %产生原始信号
sref和被高斯白噪声污染的信号 s
[sref,s]=wnoise(1,11,snr,init); %============================= %用
sym8小波对信号 s进行
3层分解并对细节系数
%选用
SURE阈值模式和尺度噪声
xd=wden(s,'heursure','s','one',3,'sym8'); %============================= %对上述信号进行图示 subplot(3,1,1); plot(sref);
title('参考信号'); subplot(3,1,2); plot(s);
title('染噪信号'); subplot(3,1,3); plot(xd);
title('消噪信号');
matlab小波去噪要四种方法
1 小波分解与重构法 2 非线性小波变换阐值法 3 平移不变量小波 4 小波变换模极大值法
%在噪声环境下语音信号的增强 %语音信号为读入的声音文件 %噪声为正态随机噪声
sound=wavread('c12345.wav'); count1=length(sound);
noise=0.05*randn(1,count1);
for i=1:count1
signal(i)=sound(i); end
for i=1:count1
y(i)=signal(i)+noise(i); end
%在小波基'db3'下进行一维离散小波变换 [coefs1,coefs2]=dwt(y,'db3'); %[低频高频 ]
count2=length(coefs1); count3=length(coefs2);
energy1=sum((abs(coefs1)).^2); energy2=sum((abs(coefs2)).^2); energy3=energy1+energy2; for i=1:count2
recoefs1(i)=coefs1(i)/energy3; end
for i=1:count3
recoefs2(i)=coefs2(i)/energy3; %低频系数进行语音信号清浊音的判别 zhen=160;
count4=fix(count2/zhen); for i=1:count4
n=160*(i-1)+1:160+160*(i-1); end
s=sound(n); w=hamming(160); sw=s.*w;
a=aryule(sw,10); sw=filter(a,1,sw); sw=sw/sum(sw);
r=xcorr(sw,'biased');