PyWavelets

1.9.0 · active · verified Sun Apr 05

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.

Warnings

Install

Imports

Quickstart

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.

import pywt
import numpy as np

data = np.array([1, 2, 3, 4, 5, 6])
wavelet = 'db1'

# Perform a single-level Discrete Wavelet Transform (DWT)
cA, cD = pywt.dwt(data, wavelet)

print(f"Original data: {data}")
print(f"Approximation coefficients (cA): {cA}")
print(f"Detail coefficients (cD): {cD}")

# Perform inverse DWT to reconstruct the signal
reconstructed_data = pywt.idwt(cA, cD, wavelet)
print(f"Reconstructed data: {reconstructed_data}")

view raw JSON →