0
0
RosConceptBeginner · 4 min read

Continuous Wavelet Transform: Definition, Example, and Uses

The continuous wavelet transform (CWT) is a method to analyze signals by breaking them into wavelets, which are small waves that vary in scale and position. It helps reveal how different frequency components of a signal change over time, unlike traditional Fourier transform which only shows overall frequencies.
⚙️

How It Works

The continuous wavelet transform works by sliding a small wave called a wavelet across the signal. Imagine you have a magnifying glass that can zoom in and out on different parts of a song to see the details of the sound at different times and pitches.

Unlike looking at the whole song at once, CWT lets you focus on short pieces at different scales. This means you can see both fast changes (high frequencies) and slow changes (low frequencies) in the signal as they happen over time.

It does this by stretching or compressing the wavelet and moving it along the signal, measuring how well the wavelet matches the signal at each point. The result is a map showing which frequencies are present at which times.

💻

Example

This example uses Python and the scipy library to perform a continuous wavelet transform on a simple signal made of two sine waves with different frequencies.

python
import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import cwt, ricker

# Create a signal: sum of two sine waves
fs = 100  # sampling frequency
x = np.linspace(0, 1, fs, endpoint=False)
signal = np.sin(2 * np.pi * 5 * x) + np.sin(2 * np.pi * 20 * x)

# Use Ricker wavelet (Mexican hat) for CWT
widths = np.arange(1, 31)
cwt_result = cwt(signal, ricker, widths)

# Plot the signal and its CWT
plt.figure(figsize=(10, 6))
plt.subplot(2, 1, 1)
plt.plot(x, signal)
plt.title('Original Signal')
plt.subplot(2, 1, 2)
plt.imshow(cwt_result, extent=[0, 1, 1, 31], cmap='PRGn', aspect='auto', origin='lower')
plt.title('Continuous Wavelet Transform (CWT)')
plt.ylabel('Wavelet Width')
plt.xlabel('Time [s]')
plt.show()
Output
A plot window showing the original signal (two sine waves combined) on top and a colored map below representing the CWT coefficients across time and wavelet widths.
🎯

When to Use

Use continuous wavelet transform when you want to analyze signals that change over time, especially if you need to see how different frequencies appear and disappear. It is very useful for:

  • Analyzing music or speech signals to detect notes or phonemes.
  • Studying seismic waves to find events like earthquakes.
  • Examining biomedical signals like EEG or ECG to detect abnormalities.
  • Any situation where frequency content varies with time and you need detailed time-frequency information.

Key Points

  • CWT breaks a signal into wavelets to analyze frequency changes over time.
  • It provides a time-frequency map, unlike Fourier transform which only shows frequency.
  • Wavelets are scaled and shifted to capture different signal details.
  • Useful for signals with non-stationary or transient features.

Key Takeaways

Continuous wavelet transform reveals how signal frequencies change over time.
It uses scaled and shifted wavelets to analyze local signal features.
CWT is ideal for non-stationary signals like speech, music, or biomedical data.
It produces a time-frequency map that helps detect transient events.
Python's scipy library provides easy tools to compute CWT.