MATLAB Examples

# 1-D Cycle Spinning

This example shows how to denoise a 1-D signal using cycle spinning and the shift-variant orthogonal nonredundant wavelet transform. The example compares the results of the two denoising methods.

Create a noisy 1-D bumps signal with a signal-to-noise ratio of 6. The signal-to-noise ratio is defined as where is the length of the signal, is the squared L2 norm, and is the variance of the noise.

rng default; [X,XN] = wnoise('bumps',10,sqrt(6)); subplot(211) plot(X); title('Original Signal'); subplot(212) plot(XN); title('Noisy Signal'); 

Denoise the signal using cycle spinning with 15 shifts, 7 to the left and 7 to the right, including the zero-shifted signal. Use Daubechies’ least-asymmetric wavelet with 4 vanishing moments (sym4) and denoise the signal down to level 4 using soft thresholding and the universal threshold estimated from the level-1 detail coefficients.

ydenoise = zeros(length(XN),15); for nn = -7:7 yshift = circshift(XN,[0 nn]); [yd,cyd] = wden(yshift,'sqtwolog' ,'s','sln',4,'sym4'); ydenoise(:,nn+8) = circshift(yd,[0, -nn]); end ydenoise = mean(ydenoise,2); 

Denoise the signal using the orthogonal nonredundant discrete wavelet transform (DWT) with the same parameters. Compare the orthogonal DWT with cycle spinning.

xd = wden(XN,'sqtwolog','s','sln',4,'sym4'); subplot(211) plot(ydenoise,'b','linewidth',2); hold on; plot(X,'r') axis([1 1024 -10 10]); legend('Denoised Signal','Original Signal','Location','SouthEast'); ylabel('Amplitude'); title('Cycle Spinning Denoising'); subplot(212) plot(xd,'b','linewidth',2); hold on; plot(X,'r'); axis([1 1024 -10 10]); legend('Denoised Signal','Original Signal','Location','SouthEast'); xlabel('Sample'); ylabel('Amplitude'); title('Standard Orthogonal Denoising'); absDiffDWT = norm(X-xd,2) absDiffCycleSpin = norm(X-ydenoise',2) 
absDiffDWT = 19.6925 absDiffCycleSpin = 15.5400 

Cycle spinning with only 15 shifts has reduced the approximation error.