## Denoise

### Background

One of the most useful applications of wavelet analysis is to remove unwanted noise from a dataset. This noise could be due to measurement errors or instrument noise. In image processing the "noise" might be small-scale features or artifacts.

You could try to remove noise from the signal by using a low-pass or band-pass Fourier filter. There are two problems with this approach:

1. You need to carefully choose the width and shape of your filter, both to avoid removing too much of your signal and to decrease "ringing" from peaks and discontinuities, and,
2. In many cases the noise is "white," in other words, it is distributed across all frequencies or spatial scales.

Wavelet analysis, on the other hand, offers a scale-independent and robust method to filter out noise. The basic technique involves computing the wavelet transform of your data and then decreasing or discarding the smallest wavelet coefficients. The inverse transform of these coefficients will then be a filtered version of your data.

### Method

We assume that you have computed the wavelet transform Wi of a multi-dimensional data array, Ai, where i=0...N-1 is the index and N is the number of points.

You then compute a threshold level W0. This threshold level can be based on the percent of wavelet power that you wish to retain, the number of coefficients, or some other method. Suggestions for choosing the threshold are given in Donoho and Johnstone (1994). Wavelet coefficients smaller than this threshold are discarded while those above are retained. There are two methods for thresholding:

#### Hard threshold

The hard threshold removes all discarded wavelet coefficients by setting them to zero and computing the inverse wavelet transform. This can be defined as:

where Wi is the wavelet coefficient and W0 is the chosen threshold level.

#### Soft Threshold

The soft threshold also sets all discarded wavelet coefficients to zero. However, it also linearly reduces the magnitude of the each retained wavelet coefficient by an amount equal to the largest discarded coefficient, i.e.:

where sgn(Wi) is the sign of Wi.

### Example

We will look at a magnetic-resonance image (MRI) of the brain, and use the Denoising widget tool to filter out unwanted speckles and compress the size of the image.

Try the following steps:

1. In WV_APPLET, choose File ® Import ® Image File, and navigate to the `examples/data` directory in the IDL distribution.
2. Import the file `mr_brain.dcm`. The file should contain a 256 x 256 unsigned integer (UINT) image.
3. In the Dataset Viewer, change the Title field to `MRI Brain Image' and the Variable field to 'Brain'.
4. Select the Brain dataset and start up the Denoise tool from the Tools Menu. You should see the Denoise widget, with the threshold set to 100% and all coefficients retained.
5. Set the # coeffs threshold to 8192 points. You should then see a view similar to that of the following figure.

Notice that you have retained 12.5% of the coefficients and have discarded 87.5%. The black regions of the "Wavelet Coeffs" plot shows the discarded coefficients. The percent difference between the original and filtered image is about 6%. Examining the filtered image, you will notice that much of the speckling around the outside is now gone. In addition, some of the small-scale features and low-contrast regions within the image have been diminished. Finally, the dotted line on the Cumulative Power graph indicates that although you are only retaining 12.5% of the information you are preserving almost 100% of the variance, or power.