denosing signal using wavedec and waverec

조회 수: 7 (최근 30일)
konoha
konoha 2021년 7월 14일
편집: Umeshraja 2024년 9월 21일
I am trying to use wavedec and waverec to denosing signals. suppose i have a signal x with some gaussian noise and then apply wavedec to do a level 3 db3 decomposition, i have two outputs, C and I, the wavelet decomposition vector C and the bookkeeping vector l, which contains the number of coefficients by level. Since we are doing a level 4 decomposition, I is a 4 by 1 vector. Assume the first two level manifest most noises, how do i threshold the coefficients in these two levels and then use the result for waverec?

답변 (1개)

Umeshraja
Umeshraja 2024년 9월 5일
편집: Umeshraja 2024년 9월 21일
If you're looking to denoise a signal using 'wavedec' and 'waverec', you can follow these primary steps:
  • Perform a Multilevel Wavelet Decomposition: Decompose the signal into multiple levels using wavelets.
  • Identify a Thresholding Technique: Choose a method for thresholding the wavelet coefficients.
  • Threshold and Reconstruct: Apply the chosen thresholding technique to the coefficients and reconstruct the denoised signal.
For a 3-level decomposition, the size of the bookkeeping vector will be 5x1. Hereby attaching 3-level decomposition diagram from documentation for reference. This vector includes the length of the wavelet decomposition vector at each level and the length of the original signal. In a typical decomposition, the first level's coefficients are stored at the end of the Wavelet Decomposition Vector (C). If noise is primarily in the first two levels, you would need to threshold the last two sections of coefficients (cD1 and cD2).
There are several thresholding techniques available, such as Univeral Threshold, SureShring (or 'rigsure') method, Heursure and minimax methods. 'wdenoise' is the built-in denoising function where technique name can be used as an argument . Alternatively, the 'wthresh' function from wavelet toolbox can be used to apply thresholding after manually determining the threshold.
Below is a sample MATLAB code of denoising using 'wavedec' and 'wdenoise' function.
% Load the noisy Doppler signal
load noisdopp
signal = noisdopp;
% Wavelet parameters
wname = "db3"; % Wavelet name
level = 3; % Decomposition level
% Perform wavelet decomposition using the inbuilt function
[C, L] = wavedec(signal, level, wname);
% Denoise using MATLAB's built-in function
denoiseusinginbuiltfunction = wdenoise(signal, level, DenoisingMethod="UniversalThreshold");
% Plot the noisy and denoised signals using the inbuilt function
subplot(2, 1, 1);
plot(signal, 'r', 'DisplayName', 'Noisy Signal');
hold on;
plot(denoiseusinginbuiltfunction, 'b', 'DisplayName', 'Denoised Signal (Inbuilt)');
title('Noisy vs. Denoised Signal (Inbuilt Function)');
xlabel('Sample Index');
ylabel('Amplitude');
legend('show');
grid on;
% Manually determine a threshold. Here the universal threshold method is used for simplicity
sigma = median(abs(C(L(5)-L(4):L(4)))) / 0.6745;
threshold = sigma * sqrt(2 * log(length(signal)));
% Apply soft thresholding to detail coefficients
for i = 1:3
start_idx = sum(L(1:i)) + 1;
end_idx = sum(L(1:i+1));
C(start_idx:end_idx) = wthresh(C(start_idx:end_idx), 's', threshold);
end
% Reconstruct the denoised signal manually
denoised_signal = waverec(C, L, wname);
% Plot the noisy and manually denoised signals
subplot(2, 1, 2);
plot(signal, 'r', 'DisplayName', 'Noisy Signal');
hold on;
plot(denoised_signal, 'b', 'DisplayName', 'Denoised Signal (Manual)');
title('Noisy vs. Manually Denoised Doppler Signal');
xlabel('Sample Index');
ylabel('Amplitude');
legend('show');
grid on;
You can also use Wavelet Signal Denoiser app for visualizing and denoising real-valued 1-D signals by running following command
>>waveletSignalDenoiser
To know more about thresholding, please refer to the following documentation
I hope it helps!

카테고리

Help CenterFile Exchange에서 Denoising and Compression에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by