# Stationary wavelet transform

The stationary wavelet transform (SWT) is a wavelet transform algorithm designed to overcome the lack of translation-invariance of the discrete wavelet transform (DWT). Translation-invariance is achieved by removing the downsamplers and upsamplers in the DWT and upsampling the filter coefficients by a factor of $2^{(j-1)}$ in the $j$th level of the algorithm. The SWT is an inherently redundant scheme as the output of each level of SWT contains the same number of samples as the input – so for a decomposition of N levels there is a redundancy of N in the wavelet coefficients. This algorithm is more famously known as "algorithme à trous" in French (word trous means holes in English) which refers to inserting zeros in the filters. It was introduced by Holschneider et al.

## Definition

The basic discrete wavelet transform (DWT) algorithm is adapted to yield a stationary wavelet transform (SWT) which is independent of the origin. The approach of the SWT is simple, which is by applying suitable high-pass and low-pass filters to the data at each level, resulting in the generation of two sequences at the subsequent level. Without employment of downsampling techniques, the length of the new sequences is maintained to be the same as the original sequences. Rather than employing decimation similar to the standard wavelet transform which removes elements, the filters at each level are adjusted by augmenting them with zero-padding, as explained in the following:
${Zx}_{2j}=x_{j},\ {Zx}_{2j+1}=0\ for\ all\ integers\ j$
$D_{0}^{r}H^{\left[r\right]}=HD_{0}^{r}$
$D_{0}^{r}G^{\left[r\right]}=GD_{0}^{r}$
where $Z$ is the operator that intersperses a given sequence with zeros, for all integers $j$.
$D_{0}^{r}$ is the binary decimation operator
$H^{\left[r\right]}$ is a filter with weights ${h_{2^{r}}^{\left[r\right]}}_{j}=h_{j}\ and\ h_{k}^{\left[r\right]}=0\ if\ k\ is\ not\ a\ multiple\ of\ 2^{r}.$
$G^{\left[r\right]}$ is a filter with weights ${g_{2^{r}}^{\left[r\right]}}_{j}=h_{j}\ and\ g_{k}^{\left[r\right]}=0\ if\ k\ is\ not\ a\ multiple\ of\ 2^{r}.$
The design of the filters $H^{\left[r\right]}$ and $G^{\left[r\right]}$ involve of inserting a zero between every adjacent pair of elements in the filter $H^{\left[r-1\right]}$ and $G^{\left[r-1\right]}$ respectively.
The designation of $a^{J}$ as the original sequence $c^{J}$ is required before defining the stationary wavelet transform.
$a^{j-1}=H^{\left[J-j\right]}a^{j},\ for\ j=J,J-1,\ \ldots \ ,1\$
$b^{j-1}=G^{\left[J-j\right]}a^{j},for\ j=J,J-1,\ \ldots \ ,1$
where $a^{j}=b^{j},\ if\ length\ of\ a^{j}=2^{J}$

## Implementation

The following block diagram depicts the digital implementation of SWT.
In the above diagram, filters in each level are up-sampled versions of the previous (see figure below).

## Applications

A few applications of SWT are specified below.

### Image enhancement

The SWT can be used to perform image resolution enhancement to provide a better image quality. The main drawback from enhancing image resolution through conventional method, interpolation, is the loss of the high frequency components. This results in the smoothing of interpolation, providing a blurry image with the absence or reduced presence of fine details, sharp edges. Information of high frequency components (edges) are crucial for achieving better image quality of super-resolved image.
It first decomposes the input image into various subband images by applying a one-level DWT. There are three subband images to capture the high frequency components of the input image. After that is the implementation of SWT, its purpose is to mitigate the information loss produced by the downsampling in each DWT subband. Fortified and corrected high frequency subbands are formed by summing up the high frequency subbands from DWT and SWT, and as a result, the output image is with sharpen edges.

### Signal denoising

The traditional denoising procedure mainly consist of first transforming the signal to another domain, then apply thresholding, and lastly perform inverse transformation to reconstruct the original signal. Stationary wavelet transform is introduced to resolve the Gibbs phenomenon brought by the shifting process in discrete wavelet transform. This phenomenon affects the image quality (noises) after the reconstruction process. The modified procedure is simple, by first perform stationary wavelet transform to the signal, thresholding, and finally transforming back. A brief explanation is shown as following:
Unlike the discrete wavelet transform, SWT does not downsample the signal at each level. Instead, it maintains the original sampling rate throughout the decomposition process, and this ensures the encapsulation of high, low-frequency components in an effective way. As the noise is often spread across all scales, with small contribution in magnitude, thresholding is implemented as the next step to the wavelet coefficients. Coefficients below a certain threshold level are set to zero or reduced, resulting in the separation of the signal from the noise. After removing or suppression of the noise coefficients, which the reconstruction progress does not consider them, the denoised signal is clearer.
Signal denoising is also commonly used in biomedical signal denoising (ECG), image denoising. The effectiveness of SWT in signal denoising makes it a valuable tool in real-world applications in various fields.
* Pattern recognition
* Brain image classification
* Pathological brain detection

## Code Example

Here is an example of applying the stationary wavelet transform to the chirp signal, coded with python3:
* Install required packages to pythonpip install numpy pip install matplotlib pip install pywt
* Import libraries in pythonimport numpy as np import matplotlib.pyplot as plt import pywt
* Main code# Generating a chirp signal t = np.linspace(0, 1, 1000, endpoint=False) frequency = 10 + 20 * t chirp_signal = np.sin(2 * np.pi * frequency * t) # Perform Stationary Wavelet Transform (SWT) wavelet = 'db1' # Daubechies wavelet level = 3 # Decomposition level coeffs = pywt.swt(chirp_signal, wavelet, level) # Coefficients # Plot the original chirp signal plt.figure(figsize=(12, 6)) plt.subplot(level + 2, 1, 1) plt.plot(t, chirp_signal) plt.title('Original Chirp Signal') plt.legend # Plot the SWT Coefficients for i in range(level): plt.subplot(level + 2, 1, i + 2) plt.plot(t, coeffs[i][0]) plt.plot(t, coeffs[i][1]) plt.title(f'SWT Coefficients - Level {i}') plt.tight_layout plt.show
* Output

## Synonyms

* Redundant wavelet transform
* Algorithme à trous
* Quasi-continuous wavelet transform
* Translation invariant wavelet transform
* Shift invariant wavelet transform
* Cycle spinning
* Maximal overlap wavelet transform (MODWT)
* Undecimated wavelet transform (UWT)