How to reconstruct the signal by applying thresholding on wavelet coefficients?

只谈情不闲聊 提交于 2019-12-13 15:28:51

问题


I want to reconstruct a 1D audio signal by thresholding the wavelet coefficients. First of all, I read the audio signal and normalised it. After that I added white Gaussian noise. Subsequently I calculated the maximum volume level for decomposition.

I applied multi-level wavelet decomposition on the noisy signal using the db2 wavelet and obtained the approximate and detailed coefficients. For the thresholding calculation using wdencmp, I get the threshold value using soft thresholding and applied this threshold on the wavelet coefficients. At the end, I use waverec to reconstruct the original signal using the new coefficients.

[x,Fs] = audioread('audio8.wav');   %Read cough sound
sound(x,Fs)
figure
plot(x(1:end,1))
title('Original Cough Sound')
xlabel('Frequency (Hz)')
ylabel('Amplitude')

x = x/abs(max(x));      %Normalization of Cough Sound
normalized_snr = snr(x,Fs);    %SNR of Normalized Cough Sound
figure
plot(x)
title('Normalized Cough Sound')
xlabel('Frequency (Hz)')
ylabel('Amplitude')

gauss_noise = awgn(x,20,'measured');  %Adding White Gaussian Noise 20db
sound(gauss_noise,Fs)
disp(length(gauss_noise))
noisy_snr = snr(gauss_noise,Fs);     %SNR of Noisy Cough Sound
figure
plot(gauss_noise)
title('Noisy Cough Sound')
xlabel('Frequency (Hz)')
ylabel('Amplitude')

level = floor(log2(length(gauss_noise))); %Get the maximum level for decomposition
disp(level)

[c,l] = wavedec(gauss_noise,level,'db2'); %multi level wavelet decomposition
figure
plot(c)
grid on
title('Wavelet Coefficients')

[thr,sorh,keepapp] = ddencmp('den','wv',gauss_noise); %Values for denoising like thr = value of thresholding, sorh = soft/hard thrsholding, keepapp = keep the approximation coefficients as it is.
clean = wdencmp('gbl',c,l,'db2',level,thr,sorh,keepapp); %Denoise the signal
snr_clean = snr(clean,Fs);
sound(clean,Fs)
figure
subplot(211)
plot(x); title('Original Signal');
subplot(212)
plot(clean); title('Denoised Signal After thresholding');

xrec = waverec(c,l,'db2'); %Perform wavelet reconstruction on new coefficients after thresholding 
rec_snr = snr(xrec,Fs);
figure
plot(xrec)
grid on
title('Reconstructed Signal')
sound(xrec,Fs)

Did I apply the threshold on the wavelet coefficients in the right way? And is the reconstructed signal correct now?

来源:https://stackoverflow.com/questions/52155844/how-to-reconstruct-the-signal-by-applying-thresholding-on-wavelet-coefficients

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!