Wden: Wavelet Denoising Function in MATLAB
Wden: Wavelet Denoising in MATLAB
The wden function in MATLAB implements 1-D signal denoising using wavelet transforms. This function offers several options for thresholding, allowing for fine-grained control over the denoising process.
Function Syntax
[xd,cxd,lxd,thrs] = wden(in1,in2,in3,in4,in5,in6,in7)
Input Arguments
- in1: The input signal to be denoised. Can be a signal vector, DWT coefficient vector (C from
wavedc), MODWT transform matrix (W frommodwt), or a vector of wavelet coefficients fromwdenitself. - in2: The threshold selection rule. Choose from:
- 'modwtsqtwolog': MODWT with Donoho & Johnstone's universal threshold and level-dependent thresholding.
- 'rigrsure': Stein's Unbiased Risk (DWT).
- 'heursure': Heuristic variant of Stein's Unbiased Risk (DWT).
- 'sqtwolog': Donoho & Johnstone's universal threshold (DWT).
- 'minimaxi': Minimax thresholding (DWT).
- in3: Thresholding type ('s' for soft, 'h' for hard).
- in4: Threshold scaling method:
- 'one': No rescaling.
- 'sln': Noise estimate based on first-level coefficients.
- 'mln': Level-dependent noise estimates (only for MODWT).
- in5: Level of wavelet transform.
- in6: Wavelet name (string). For MODWT, it must be an orthogonal wavelet.
- in7: Number of DWT coefficients by level (L from
wavedc).
Output Arguments
- xd: Denoised signal.
- cxd: Denoised wavelet coefficients.
- lxd: Levels of wavelet transform.
- thrs: Thresholds applied.
Soft Thresholding Implementation
The wden function uses the following code for soft thresholding:
if SORH=='s' % Soft thresholding
xd = sign(in1) .* max(abs(in1)-thrs,0);
end
This code snippet represents the core logic for soft thresholding within wden. Here's what it does:
- Sign and Absolute Value: It calculates the sign (
sign(in1)) and absolute value (abs(in1)) of the input coefficients (in1). - Threshold Application: The absolute value is then compared to the threshold (
thrs). If it's less than the threshold, the coefficient is set to zero (usingmax(abs(in1)-thrs,0)). If it's greater than the threshold, it's shrunk by the amount of the threshold (abs(in1)-thrs). - Re-Application of Sign: Finally, the original sign is multiplied back to ensure the correct polarity of the coefficient after thresholding.
This process effectively removes small coefficients while scaling down larger ones, contributing to a smoother denoised signal.
Conclusion
The wden function offers a powerful and flexible approach to denoising signals using wavelet transforms. Its combination of thresholding options and scaling methods enables fine-tuning for various signal types and noise characteristics. Understanding the role of soft thresholding, as demonstrated in the code snippet above, is essential for effectively applying this function in signal processing applications.
原文地址: https://www.cveoy.top/t/topic/n923 著作权归作者所有。请勿转载和采集!