Skip to content

NOTES

DWT — Discrete Wavelet Transform

Multi-resolution signal decomposition via quadrature mirror filters. Ideal for non-stationary signal time-frequency analysis.


Algorithm

Mallat's Multilevel Decomposition

Single level:

\[ \begin{aligned} a1[n] &= \sumk x[k] \cdot h[2n - k] \quad &\text{(low-pass → approximation)}\\ d1[n] &= \sumk x[k] \cdot g[2n - k] \quad &\text{(high-pass → detail)} \end{aligned} \]

  • Low-pass \(h\) extracts signal trend; high-pass \(g\) captures transients
  • Each output: \(N/2\) points (2× downsampling)

Recursive: repeat on \(a1\) → \(a2, d_2\), etc.

Perfect reconstruction: upsample → synthesis filters → sum. Unmodified coefficients → exact original.

Wavelet Selection

  • DB1 (Haar)


    Simplest, piecewise constant
    Transient / impact detection

  • DB2–DB4


    Compact + smoothness balance
    Common in SHM

  • DB5–DB10


    Smoother basis
    Slowly varying signals

Energy preservation

Orthogonal DWT is norm-preserving: \(|x|^2 = \sum |aL|^2 + \sum^L \sum |d_j|^2\). Use to evaluate subband energy distribution.

Boundary effects

Artifacts amplify across levels. Short signals are vulnerable. This implementation uses symmetric padding.


API Reference

// Single-level decomposition
tiny_error_t tiny_dwt_decompose_f32(const float *input, int len,
                                    float *approx, float *detail,
                                    tiny_dwt_wavelet_t wavelet);

// Single-level reconstruction
tiny_error_t tiny_dwt_reconstruct_f32(const float *approx, const float *detail,
                                      int len, float *output,
                                      tiny_dwt_wavelet_t wavelet);

// Multilevel decomposition
tiny_error_t tiny_dwt_multilevel_decompose_f32(const float *input, int len,
                                               int levels, float *coeffs,
                                               tiny_dwt_wavelet_t wavelet);

// Multilevel reconstruction
tiny_error_t tiny_dwt_multilevel_reconstruct_f32(const float *coeffs, int len,
                                                 int levels, float *output,
                                                 tiny_dwt_wavelet_t wavelet);

// Coefficient processing (thresholding, denoising)
tiny_error_t tiny_dwt_coeffs_process(float *coeffs, int len, int levels,
                                     float threshold, tiny_dwt_process_t mode);

Wavelet enum: TINY_DWT_DB1 ... TINY_DWT_DB10