# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English version of the page.

# wden

Automatic 1-D de-noising

## Syntax

```XD = wden(X,TPTR,SORH,SCAL,N,'wname') XD = wden(C,L,TPTR,SORH,SCAL,N,'wname') XD = wden(W,'modwtsqtwolog',SORH,'mln',N,WNAME) [XD,CXD] = wden(...) [XD,CXD,LXD] = wden(...) [XD,CXD,LXD,THR] = wden(...) [XD,CXD,THR] = wden(...) ```

## Description

`wden` is a one-dimensional de-noising function.

`wden` performs an automatic de-noising process of a one-dimensional signal using wavelets.

`XD = wden(X,TPTR,SORH,SCAL,N,'wname')` returns a de-noised version `XD` of input signal `X` obtained by thresholding the wavelet coefficients.

`TPTR` character vector contains the threshold selection rule:

• `'rigrsure'` uses the principle of Stein's Unbiased Risk.

• `'heursure'` is an heuristic variant of the first option.

• `'sqtwolog'` for the universal threshold $\sqrt{2\mathrm{ln}\left(·\right)}$

• `'minimaxi'` for minimax thresholding (see `thselect` for more information)

`SORH` (`'s'` or `'h'`) is for soft or hard thresholding (see `wthresh` for more information).

`SCAL` defines multiplicative threshold rescaling:

`'one'` for no rescaling

`'sln'` for rescaling using a single estimation of level noise based on first-level coefficients

`'mln'` for rescaling done using level-dependent estimation of level noise

Wavelet decomposition is performed at level `N` and `'``wname``'` is a character vector containing the name of the desired orthogonal wavelet (see `wmaxlev` and `wfilters` for more information).

`XD = wden(C,L,TPTR,SORH,SCAL,N,'wname')` returns the same output arguments, using the same options as above, but obtained directly from the input wavelet decomposition structure `[C,L]` of the signal to be de-noised, at level `N` and using `'wname'` orthogonal wavelet.

`XD = wden(W,'modwtsqtwolog',SORH,'mln',N,WNAME)` returns the denoised signal obtained by operating on the MODWT transform matrix `W`, where `W` is the output of MODWT. You must use the same wavelet in both `modwt` and `wden`.

`[XD,CXD] = wden(...)` returns the denoised wavelet coefficients. For DWT denoising, `CXD` is a vector (see `wavedec`). For MODWT denoising, `CXD` is a matrix with N+1 rows (see `modwt`). The number of columns is equal to the length of the input signal `X`.

`[XD,CXD,LXD] = wden(...)` returns the number of coefficients by level for DWT denoising. See `wavedec` for details. The `LXD` output is not supported for MODWT denoising. The additional output arguments `[CXD,LXD]` are the wavelet decomposition structure (see `wavedec` for more information) of the de-noised signal `XD`.

`[XD,CXD,LXD,THR] = wden(...)` returns the denoising thresholds by level for DWT denoising.

`[XD,CXD,THR] = wden(...)` returns the denoising thresholds by level for MODWT denoising when you specify `'modwtsqtwolog'`.

## Examples

collapse all

In this example, three different denoising techniques are applied to a noisy signal. Plots comparing results are generated. The thresholds produced by each technique are also shown.

First, to ensure reproducibility of results, set a seed that will be used to generate the random noise.

`rng('default')`

Create a signal consisting of a 2-Hz sine wave with transients at 0.3 and 0.72 seconds. Add randomly generated noise to the signal and plot the result.

```N = 1000; t = linspace(0,1,N); x = 4*sin(4*pi*t); x = x - sign(t-0.3) - sign(0.72-t); sig = x + 0.5*randn(size(t)); plot(t,sig) title('Signal')```

Using the `sym8` wavelet, perform a level 5 wavelet decomposition of the signal and denoise it by applying three different threshold selection rules to the wavelet coefficients: SURE; minimax; Donoho and Johnstone's universal threshold with level-dependent estimation of the noise. In each case, apply hard thresholding.

```lev = 5; wname = 'sym8'; [dnsig1,c1,l1,threshold_SURE] = wden(sig,'rigrsure','h','mln',lev,wname); [dnsig2,c2,l2,threshold_Minimax] = wden(sig,'minimaxi','h','mln',lev,wname); [dnsig3,c3,l3,threshold_DJ] = wden(sig,'sqtwolog','h','mln',lev,wname);```

Plot and compare the three denoised signals.

```subplot(3,1,1) plot(t,dnsig1) title('Denoised Signal - SURE') subplot(3,1,2) plot(t,dnsig2) title('Denoised Signal - Minimax') subplot(3,1,3) plot(t,dnsig3) title('Denoised Signal - Donoho-Johnstone')```

Compare the thresholds applied at each detail level for the three denoising methods.

`threshold_SURE`
```threshold_SURE = 0.8079 1.1448 1.3915 0.9816 0.8667 ```
`threshold_Minimax`
```threshold_Minimax = 1.0522 1.0881 1.2237 1.3366 1.1985 ```
`threshold_DJ`
```threshold_DJ = 1.7644 1.8247 2.0520 2.2413 2.0097 ```

In this example, a signal is denoised using the DWT and MODWT. Plots comparing results are generated. The thresholds used in each case are also shown.

First, to ensure reproducibility of results, set a seed that will be used to generate random noise.

`rng('default')`

Create a signal consisting of a 2-Hz sine wave with transients at 0.3 and 0.72 seconds. Add randomly generated noise to the signal and plot the result.

```N = 1000; t = linspace(0,1,N); x = 4*sin(4*pi*t); x = x - sign(t-0.3) - sign(0.72-t); sig = x + 0.5*randn(size(t)); plot(t,sig) title('Signal')```

Using the `db2` wavelet, perform a level 3 wavelet decomposition of the signal and denoise it using Donoho and Johnstone's universal threshold with level-dependent estimation of the noise. Obtain denoised versions using DWT and MODWT and soft thresholding.

```wname = 'db2'; lev = 3; [xdDWT,c1,l1,threshold_DWT] = wden(sig,'sqtwolog','s','mln',lev,wname); [xdMODWT,c2,threshold_MODWT] = wden(sig,'modwtsqtwolog','s','mln',lev,wname);```

Plot and compare the results.

```subplot(2,1,1) plot(t,xdDWT) title('DWT Denoising') subplot(2,1,2) plot(t,xdMODWT) title('MODWT Denoising')```

Compare the thresholds applied in each case.

`threshold_DWT`
```threshold_DWT = 1.7783 1.6876 2.0434 ```
`threshold_MODWT`
```threshold_MODWT = 1.2760 0.6405 0.3787 ```

In this example, a blocky signal is denoised using the Haar wavelet with DWT and MODWT denoising. Plots are generated comparing results. Metrics comparing the original with denoised versions are also produced.

First, to ensure reproducibility of results, set a seed that will be used to generate random noise.

`rng('default')`

Generate a signal and a noisy version with the square root of the signal-to-noise ratio equal to 3. Plot and compare each.

```[osig,nsig] = wnoise('blocks',10,3); plot(nsig,'r') hold on plot(osig,'b') legend('Noisy','Original')```

Using the Haar wavelet, perform a level 6 wavelet decomposition of the noisy signal and denoise it using Donoho and Johnstone's universal threshold with level-dependent estimation of the noise. Obtain denoised versions using DWT and MODWT and soft thresholding.

```wname = 'haar'; lev = 6 ; [xdDWT,c1,l1] = wden(nsig,'sqtwolog','s','mln',lev,wname); [xdMODWT,c2] = wden(nsig,'modwtsqtwolog','s','mln',lev,wname);```

Plot and compare the original, noise-free version of the signal with the two denoised versions.

```figure plot(osig,'b') hold on plot(xdDWT,'r--') plot(xdMODWT,'k-.') legend('Original','DWT','MODWT') hold off```

Calculate the L2 and L-infinity norms of the difference between the original signal and the two denoised versions.

`L2norm_original_DWT = norm(abs(osig-xdDWT),2)`
```L2norm_original_DWT = 36.1194 ```
`L2norm_original_MODWT = norm(abs(osig-xdMODWT),2)`
```L2norm_original_MODWT = 14.5987 ```
`LInfinity_original_DWT = norm(abs(osig-xdDWT),Inf)`
```LInfinity_original_DWT = 4.7181 ```
`LInfinity_original_MODWT = norm(abs(osig-xdMODWT),Inf)`
```LInfinity_original_MODWT = 2.9655 ```

## Algorithms

The underlying model for the noisy signal is basically of the following form:

`$s\left(n\right)=f\left(n\right)+\sigma e\left(n\right)$`

where time n is equally spaced.

In the simplest model, suppose that e(n) is a Gaussian white noise N(0,1) and the noise level σ a is supposed to be equal to 1.

The de-noising objective is to suppress the noise part of the signal s and to recover f.

The de-noising procedure proceeds in three steps:

1. Decomposition. Choose a wavelet, and choose a level `N`. Compute the wavelet decomposition of the signal s at level `N`.

2. Detail coefficients thresholding. For each level from 1 to `N`, select a threshold and apply soft thresholding to the detail coefficients.

3. Reconstruction. Compute wavelet reconstruction based on the original approximation coefficients of level `N` and the modified detail coefficients of levels from 1 to `N`.

More details about threshold selection rules are in Wavelet Denoising and Nonparametric Function Estimation, in the User's Guide, and in the help of the `thselect` function. Let us point out that

• The detail coefficients vector is the superposition of the coefficients of f and the coefficients of e, and that the decomposition of e leads to detail coefficients that are standard Gaussian white noises.

• Minimax and SURE threshold selection rules are more conservative and are more convenient when small details of function f lie in the noise range. The two other rules remove the noise more efficiently. The option `'heursure'` is a compromise.

In practice, the basic model cannot be used directly. This section examines the options available, to deal with model deviations. The remaining parameter `scal` has to be specified. It corresponds to threshold rescaling methods.

• Option `scal` = `'one'` corresponds to the basic model.

• In general, you can ignore the noise level that must be estimated. The detail coefficients CD1 (the finest scale) are essentially noise coefficients with standard deviation equal to σ. The median absolute deviation of the coefficients is a robust estimate of σ. The use of a robust estimate is crucial because if level 1 coefficients contain f details, these details are concentrated in few coefficients to avoid signal end effects, which are pure artifacts due to computations on the edges.

• The option `scal = 'sln'` handles threshold rescaling using a single estimation of level noise based on the first-level coefficients.

• When you suspect a nonwhite noise e, thresholds must be rescaled by a level-dependent estimation of the level noise. The same kind of strategy is used by estimating σlev level by level. This estimation is implemented in the file `wnoisest`, which handles the wavelet decomposition structure of the original signal s directly.

• The option `scal` = `'mln'` handles threshold rescaling using a level-dependent estimation of the level noise.

## References

Antoniadis, A.; G. Oppenheim, Eds. (1995), Wavelets and statistics, 103, Lecture Notes in Statistics, Springer Verlag.

Donoho, D.L. (1993), “Progress in wavelet analysis and WVD: a ten minute tour,” in Progress in wavelet analysis and applications, Y. Meyer, S. Roques, pp. 109–128. Frontières Ed.

Donoho, D.L.; I.M. Johnstone (1994), “Ideal spatial adaptation by wavelet shrinkage,” Biometrika, Vol. 81, pp. 425–455.

Donoho, D.L. (1995), “De-noising by soft-thresholding,” IEEE Trans. on Inf. Theory, 42 3, pp. 613– 627.

Donoho, D.L.; I.M. Johnstone, G. Kerkyacharian, D. Picard (1995), “Wavelet shrinkage: asymptotia,” Jour. Roy. Stat. Soc., series B, Vol. 57, No. 2, pp. 301–369.