PyWavelets is a free, open-source Python library for wavelet transforms. It provides 1D, 2D, and nD forward and inverse Discrete Wavelet Transforms (DWT and IDWT), Stationary Wavelet Transforms (SWT), Wavelet Packet decomposition, and Continuous Wavelet Transforms (CWT). It combines a simple high-level interface with low-level C and Cython performance and is widely used in signal processing, image compression, and noise removal. The current version is 1.9.0 and it has an active release cadence, with minor updates and new features being released regularly.
pip install PyWaveletsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates a basic 1D Discrete Wavelet Transform (DWT) and its inverse using the 'db1' (Daubechies 1) wavelet. It shows how to decompose a signal into approximation (cA) and detail (cD) coefficients, and then reconstruct the original signal.
Upgrade Python to 3.11 or newer, or downgrade PyWavelets to a compatible version if unable to upgrade Python.
Update NumPy to version 1.25.0 or higher using `pip install --upgrade numpy`.
Manually install `scipy` (e.g., `pip install scipy`) if your application or specific PyWavelets functions (like certain CWT functionalities) require it.
For commercial use, the new image is safe. If the original image is critical for non-commercial use, you must source it externally or use an older PyWavelets version.
Always explicitly specify the `mode` parameter (e.g., `mode='symmetric'`) and consult the documentation or `pywt.dwt_coeff_len()` to predict output sizes, especially when chaining transforms or performing inverse transforms.
pip install PyWavelets
import pywt coeffs = pywt.dwt2(data, wavelet_name)
import pywt # To see available wavelets: print(pywt.wavelist()) # Use a valid wavelet name, e.g. coeffs = pywt.dwt(data, 'db1')
import numpy as np import pywt data = np.array([1, 2, 3, 4]) # Ensure data is an array coeffs = pywt.dwt(data, 'db1')