
- 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
SciPy - Discrete Wavelet Transform (DWT)
Discrete Wavelet Transform in SciPy
The Discrete Wavelet Transform (DWT) is a powerful tool for analyzing signals by decomposing them into different frequency components with a discrete scale. Unlike the Continuous Wavelet Transform (CWT), DWT uses a fixed set of wavelet functions which makes it computationally more efficient and appropriate for real-time signal processing applications.
DWT is commonly used for signal compression, denoising and feature extraction in various fields such as image processing, audio processing and bio-signal analysis.
The Discrete 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 DWT
Following are the key properties of the Discrete Wavelet Transform −
- Multi-Resolution Analysis: DWT allows the signal to be analyzed at different scales (resolutions) which helps capture both the low-frequency and high-frequency components.
- Efficient Computation: DWT is computationally efficient because it operates with a discrete set of wavelet functions by making it suitable for real-time applications.
- Downsampling: DWT performs downsampling at each level, reducing the size of the coefficients and thus the data storage requirements.
- Time-Frequency Localization: DWT provides both time and frequency localization of the signal by making it useful for analyzing non-stationary signals.
In SciPy versions 1.15.1 and later the cwt function has been removed from the scipy.signal module. Therefore, if you're using SciPy 1.15.1 or higher, we should use alternative methods to perform the Continuous Wavelet Transform (CWT) such as the PyWavelets (pywt) library.
Using PyWavelets (pywt)
If We're facing issues with SciPy's dwt function then we have an alternative approach which is to use PyWavelets (pywt), a powerful library for wavelet analysis in Python. It provides extensive functionality for Continuous Wavelet Transform (CWT), Discrete Wavelet Transform (DWT) and more.
Basic Example of DWT using PyWavelets
In this example we will perform a 1-level DWT on a simple signal using the Haar wavelet which one of the simplest wavelets −
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 Discrete Wavelet Transform (DWT) using the Haar wavelet coeffs = pywt.dwt(signal, 'haar') # Extract the approximation (cA) and detail (cD) coefficients cA, cD = coeffs # 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 Discrete Wavelet Transform using PyWavelets −

Multi-Level DWT Decomposition using PyWavelets
This example shows how to perform multi-level DWT 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 DWT decomposition using 'db1' (Daubechies wavelet) coeffs = pywt.wavedec(signal, 'db1', level=3) # Decompose to 3 levels # coeffs contains the approximation and detail coefficients at each level cA3, cD3, cD2, cD1 = coeffs # cA3: Approximation at level 3, cD3: Detail at level 3, etc. # 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 3 plt.subplot(5, 1, 2) plt.plot(cA3) plt.title("Approximation Coefficients at Level 3") # Plot the detail coefficients at level 3 plt.subplot(5, 1, 3) plt.plot(cD3) plt.title("Detail Coefficients at Level 3") # Plot the detail coefficients at level 2 plt.subplot(5, 1, 4) plt.plot(cD2) plt.title("Detail Coefficients at Level 2") # Plot the detail coefficients at level 1 plt.subplot(5, 1, 5) plt.plot(cD1) plt.title("Detail Coefficients at Level 1") plt.tight_layout() plt.show()
Below is the output of the Multi-Level Discrete Wavelet Transform using PyWavelets −

Applications of DWT
The Discrete Wavelet Transform (DWT) is widely used in various fields due to its computational efficiency and ability to provide both time and frequency information. Some key applications are as follows −
- Signal Compression: DWT is used in applications like JPEG 2000 for image compression and in audio and video compression formats.
- Denoising: DWT helps remove noise from signals while preserving the important features by making it useful in fields like speech processing and biomedical signal analysis.
- Feature Extraction: DWT is used to extract features from signals for classification or qattern recognition in machine learning tasks.
- Data Fusion: DWT can fuse information from multiple data sources useful in sensor networks and medical diagnostics.
Choosing the Right Wavelet for DWT
Just like in CWT choosing the right wavelet for DWT is important for capturing the features of the signal being analyzed. Some common wavelets for DWT 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 |