
- SciPy - Home
- SciPy - Introduction
- SciPy - Environment Setup
- SciPy - Basic Functionality
- SciPy - Relationship with NumPy
- SciPy Clusters
- SciPy - Clusters
- SciPy - Hierarchical Clustering
- SciPy - K-means Clustering
- SciPy - Distance Metrics
- SciPy Constants
- SciPy - Constants
- SciPy - Mathematical Constants
- SciPy - Physical Constants
- SciPy - Unit Conversion
- SciPy - Astronomical Constants
- SciPy - Fourier Transforms
- SciPy - FFTpack
- SciPy - Discrete Fourier Transform (DFT)
- SciPy - Fast Fourier Transform (FFT)
- SciPy Integration Equations
- SciPy - Integrate Module
- SciPy - Single Integration
- SciPy - Double Integration
- SciPy - Triple Integration
- SciPy - Multiple Integration
- SciPy Differential Equations
- SciPy - Differential Equations
- SciPy - Integration of Stochastic Differential Equations
- SciPy - Integration of Ordinary Differential Equations
- SciPy - Discontinuous Functions
- SciPy - Oscillatory Functions
- SciPy - Partial Differential Equations
- SciPy Interpolation
- SciPy - Interpolate
- SciPy - Linear 1-D Interpolation
- SciPy - Polynomial 1-D Interpolation
- SciPy - Spline 1-D Interpolation
- SciPy - Grid Data Multi-Dimensional Interpolation
- SciPy - RBF Multi-Dimensional Interpolation
- SciPy - Polynomial & Spline Interpolation
- SciPy Curve Fitting
- SciPy - Curve Fitting
- SciPy - Linear Curve Fitting
- SciPy - Non-Linear Curve Fitting
- SciPy - Input & Output
- SciPy - Input & Output
- SciPy - Reading & Writing Files
- SciPy - Working with Different File Formats
- SciPy - Efficient Data Storage with HDF5
- SciPy - Data Serialization
- SciPy Linear Algebra
- SciPy - Linalg
- SciPy - Matrix Creation & Basic Operations
- SciPy - Matrix LU Decomposition
- SciPy - Matrix QU Decomposition
- SciPy - Singular Value Decomposition
- SciPy - Cholesky Decomposition
- SciPy - Solving Linear Systems
- SciPy - Eigenvalues & Eigenvectors
- SciPy Image Processing
- SciPy - Ndimage
- SciPy - Reading & Writing Images
- SciPy - Image Transformation
- SciPy - Filtering & Edge Detection
- SciPy - Top Hat Filters
- SciPy - Morphological Filters
- SciPy - Low Pass Filters
- SciPy - High Pass Filters
- SciPy - Bilateral Filter
- SciPy - Median Filter
- SciPy - Non - Linear Filters in Image Processing
- SciPy - High Boost Filter
- SciPy - Laplacian Filter
- SciPy - Morphological Operations
- SciPy - Image Segmentation
- SciPy - Thresholding in Image Segmentation
- SciPy - Region-Based Segmentation
- SciPy - Connected Component Labeling
- SciPy Optimize
- SciPy - Optimize
- SciPy - Special Matrices & Functions
- SciPy - Unconstrained Optimization
- SciPy - Constrained Optimization
- SciPy - Matrix Norms
- SciPy - Sparse Matrix
- SciPy - Frobenius Norm
- SciPy - Spectral Norm
- SciPy Condition Numbers
- SciPy - Condition Numbers
- SciPy - Linear Least Squares
- SciPy - Non-Linear Least Squares
- SciPy - Finding Roots of Scalar Functions
- SciPy - Finding Roots of Multivariate Functions
- SciPy - Signal Processing
- SciPy - Signal Filtering & Smoothing
- SciPy - Short-Time Fourier Transform
- SciPy - Wavelet Transform
- SciPy - Continuous Wavelet Transform
- SciPy - Discrete Wavelet Transform
- SciPy - Wavelet Packet Transform
- SciPy - Multi-Resolution Analysis
- SciPy - Stationary Wavelet Transform
- SciPy - Statistical Functions
- SciPy - Stats
- SciPy - Descriptive Statistics
- SciPy - Continuous Probability Distributions
- SciPy - Discrete Probability Distributions
- SciPy - Statistical Tests & Inference
- SciPy - Generating Random Samples
- SciPy - Kaplan-Meier Estimator Survival Analysis
- SciPy - Cox Proportional Hazards Model Survival Analysis
- SciPy Spatial Data
- SciPy - Spatial
- SciPy - Special Functions
- SciPy - Special Package
- SciPy Advanced Topics
- SciPy - CSGraph
- SciPy - ODR
- SciPy Useful Resources
- SciPy - Reference
- SciPy - Quick Guide
- SciPy - Cheatsheet
- SciPy - Useful Resources
- SciPy - Discussion
Stationary Wavelet Transform (SWT)
Stationary Wavelet Transform in SciPy
The Stationary Wavelet Transform (SWT) is a variant of the Discrete Wavelet Transform (DWT) where the scaling and shifting of the wavelet function are done in a way that avoids down-sampling. This results in no loss of information, unlike the DWT which includes down-sampling that may cause some detail loss. SWT is especially useful for applications where high precision in time-frequency analysis is required such as in image processing, de-noising and feature extraction of non-stationary signals.
The Stationary Wavelet Transform of a signal x(t) can be represented as follows −
$\mathrm{W(j, k) = \int_{-\infty}^{\infty} x(t) \psi^* \left( \frac{t - k}{2^j} \right) dt}$
Where −
- x(t) is the input signal.
- (t) is the mother wavelet.
- = 2j is the scale factor.
- = k is the translation parameter (discrete shifts of the signal).
- W(j, k) represents the wavelet coefficients at scale j and shift k.
Key Properties of SWT
Following are the key properties of the Stationary Wavelet Transform −
- No Down-sampling: Unlike DWT, SWT does not perform downsampling which avoids the loss of detail during decomposition.
- Shift Invariance: The SWT is shift-invariant which means small shifts in the signal do not cause large changes in the wavelet coefficients which makes it suitable for detecting small changes in non-stationary signals.
- Multi-Resolution Analysis: Similar to DWT, SWT allows for multi-resolution analysis by analyzing signals at multiple scales.
- Time-Frequency Localization: SWT provides time-frequency localization by making it useful for non-stationary signal analysis such as speech or biomedical signal processing.
In SciPy versions 1.15.1 and later the cwt function has been removed from the scipy.signal module. Therefore, for the Continuous Wavelet Transform (CWT) or stationary wavelet transformations alternative libraries such as PyWavelets (pywt) can be used.
Using PyWavelets (pywt)
If we're facing issues with SciPy's DWT function we can use PyWavelets (pywt) which provides efficient implementations of both the DWT and SWT in Python. It supports a wide range of wavelet types and decomposition levels by making it a versatile tool for wavelet analysis.
Basic Example of SWT using PyWavelets
In this example we will perform a 1-level Stationary Wavelet Transform on a simple signal using the Haar wavelet −
import numpy as np import pywt import matplotlib.pyplot as plt # Create a simple signal (a step function for demonstration) signal = np.array([1, 1, 1, 0, 0, 0, 1, 1, 1, 0]) # Perform 1-level Stationary Wavelet Transform (SWT) using the Haar wavelet coeffs = pywt.swt(signal, 'haar', level=1) # Extract the approximation (cA) and detail (cD) coefficients cA, cD = coeffs[0] # Plot the original signal, approximation coefficients, and detail coefficients plt.figure(figsize=(10, 6)) # Plot the original signal plt.subplot(3, 1, 1) plt.plot(signal, label="Original Signal", color='blue') plt.title("Original Signal") plt.legend() # Plot the approximation coefficients (cA) plt.subplot(3, 1, 2) plt.plot(cA, label="Approximation Coefficients (cA)", color='green') plt.title("Approximation Coefficients (cA)") plt.legend() # Plot the detail coefficients (cD) plt.subplot(3, 1, 3) plt.plot(cD, label="Detail Coefficients (cD)", color='red') plt.title("Detail Coefficients (cD)") plt.legend() plt.tight_layout() plt.show()
Following is the output of the Basic Stationary Wavelet Transform using PyWavelets −

Multi-Level SWT Decomposition using PyWavelets
This example shows how to perform multi-level SWT decomposition on a signal using PyWavelets. We will decompose the signal into multiple levels −
import numpy as np import matplotlib.pyplot as plt import pywt # Generate a simple signal (a combination of two sine waves) t = np.linspace(0, 1, 500, endpoint=False) # Time vector signal = np.sin(2 * np.pi * 10 * t) + np.sin(2 * np.pi * 50 * t) # Signal # Perform Multi-Level SWT decomposition using 'db1' (Daubechies wavelet) coeffs = pywt.swt(signal, 'db1', level=2) # Decompose to 2 levels # coeffs contains the approximation and detail coefficients at each level cA2, cD2 = coeffs[1] # cA2: Approximation at level 2, cD2: Detail at level 2 # Plot the original signal and the decomposition results plt.figure(figsize=(10, 10)) # Plot the original signal plt.subplot(5, 1, 1) plt.plot(t, signal) plt.title("Original Signal") plt.xlabel("Time (s)") plt.ylabel("Amplitude") # Plot the approximation coefficients at level 2 plt.subplot(5, 1, 2) plt.plot(cA2) plt.title("Approximation Coefficients at Level 2") # Plot the detail coefficients at level 2 plt.subplot(5, 1, 3) plt.plot(cD2) plt.title("Detail Coefficients at Level 2") plt.tight_layout() plt.show()
Below is the output of the Multi-Level Stationary Wavelet Transform using PyWavelets −

Applications of SWT
The Stationary Wavelet Transform (SWT) is widely used in various fields due to its ability to provide both time and frequency information while preserving the signal's features. Some key applications are as follows −
- Denoising: SWT is often used to remove noise from signals, especially in fields like speech processing, biomedical signal analysis and image processing.
- Compression: SWT can be used for signal and image compression as it provides a compact representation of the data.
- Feature Extraction: SWT is useful for extracting relevant features from signals for machine learning tasks such as classification or pattern recognition.
- Edge Detection: In image processing, SWT can be used for detecting edges and other important features in an image.
Choosing the Right Wavelet for SWT
Just like in DWT by choosing the right wavelet for SWT is essential for capturing the features of the signal being analyzed. Some common wavelets for SWT are as follows −
Wavelet | Best For | Example Use Cases |
---|---|---|
Daubechies (db) | Smooth signals, multiresolution analysis | Signal denoising, image compression |
Symlet | Symmetric signals, efficient approximation | Audio processing, compression |
Coiflet | Signals with smooth features, multiresolution | Feature extraction, denoising |
Haar | Discontinuous signals, edge detection | Compression, real-time signal analysis |