标签:阈值 log10 sqrt length abs 语音 d4 sigma 源码
一、简介
二、源代码
clc;
clear;
fs=wavread('C:\Users\lenovo\Desktop\93317443speech-denoising\Ring01.wav');
y=fs(40000:120000);
N=length(y);
figure(1);
subplot(111);
plot(y);
ylabel('幅值 A');
title('原始信号');
s=awgn(y,20,'measured');%加入高斯白噪声
figure(2);
plot(s);
ylabel('幅值 A');
title('加噪信号');
wname='db3';%选db3小波基
lev=5;%5层分解
[c,l]=wavedec(s,lev,wname);
a5=appcoef(c,l,wname,lev);
d5=detcoef(c,l,5);
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,d5];
a=8500;b=13;
sigma=median(abs(cD))/3.647
thr1=(sigma*sqrt(2*(log10(N))))/(log10(2));
cD1=wthresh(d1,'s',thr1);
thr2=(sigma*sqrt(2*(log10(N))))/(log10(3));
cD2=wthresh(d2,'s',thr2);
thr3=(sigma*sqrt(2*(log10(N))))/(log10(4));
cD3=wthresh(d3,'s',thr3);
thr4=(sigma*sqrt(2*(log10(N))))/(log10(5));
cD4=wthresh(d4,'s',thr4);
thr5=(sigma*sqrt(2*(log10(N))))/(log10(6));
cD5=wthresh(d5,'s',thr5);
cd=[a5,cD5,cD4,cD3,cD2,cD1];
c=cd;
ys=waverec(c,l,wname);
figure(3);
plot(ys);
title('软阈值处理');
thr1=(sigma*sqrt(2*(log10(N))))/(log10(2));
cD1=wthresh(d1,'h',thr1);
thr2=(sigma*sqrt(2*(log10(N))))/(log10(3));
cD2=wthresh(d2,'h',thr2);
thr3=(sigma*sqrt(2*(log10(N))))/(log10(4));
cD3=wthresh(d3,'h',thr3);
thr4=(sigma*sqrt(2*(log10(N))))/(log10(5));
cD4=wthresh(d4,'h',thr4);
thr5=(sigma*sqrt(2*(log10(N))))/(log10(6));
cD5=wthresh(d5,'h',thr5);
cd=[a5,cD5,cD4,cD3,cD2,cD1];
c=cd;
yh=waverec(c,l,wname);
figure(4);
plot(yh);
title('硬阈值处理');
thr1=(sigma*sqrt(2*(log10(length(d1)))))/(log10(1+1));
for i=1:length(d1)
if(abs(d1(i))>=thr1)
cD1(i)=sign(d1(i))*(abs(d1(i))-b*thr1/(a^(abs(abs(d1(i))-thr1))+b-1));%估计第一层小波系数
else
cD1(i)=0;
end
end
thr2=(sigma*sqrt(2*(log10(length(d2)))))/(log10(2+1));
for i=1:length(d2)
if(abs(d2(i))>=thr2)
cD2(i)=sign(d2(i))*(abs(d2(i))-b*thr2/(a^(abs(abs(d2(i))-thr2))+b-1));%估计第二层小波系数
else
cD2(i)=0;
end
end
thr3=(sigma*sqrt(2*(log10(length(d3)))))/(log10(3+1));
for i=1:length(d3)
if(abs(d3(i))>=thr3)
cD3(i)=sign(d3(i))*(abs(d3(i))-b*thr3/(a^(abs(abs(d3(i))-thr3))+b-1));%估计第三层小波系数
else
cD3(i)=0;
end
end
thr4=(sigma*sqrt(2*(log10(length(d4)))))/(log10(4+1));
for i=1:length(d4)
if(abs(d4(i))>=thr4)
cD4(i)=sign(d4(i))*(abs(d4(i))-b*thr4/(a^(abs(abs(d4(i))-thr4))+b-1));%估计第四层小波系数
else
cD4(i)=0;
end
end
thr5=(sigma*sqrt(2*(log10(length(d5)))))/(log10(5+1));
for i=1:length(d5)
if(abs(d5(i))>=thr5)
cD5(i)=sign(d5(i))*(abs(d5(i))-b*thr5/(a^(abs(abs(d5(i))-thr5))+b-1));%估计第五层小波系数
else
cD5(i)=0;
end
end
%%%%开始重构
cd=[a5,cD5,cD4,cD3,cD2,cD1];
c=cd;
yhs=waverec(cd,l,wname);
figure(5);
plot(ys,'LineWidth',1);
ylabel('幅值 A')
三、运行结果
四、备注
版本:2014a
标签:阈值,log10,sqrt,length,abs,语音,d4,sigma,源码 来源: https://blog.51cto.com/u_15287606/2975946
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。