Module 6 Filter bank - igheyas/WaveletTransformation GitHub Wiki

๐Ÿ“‹ Week 6: Filter Banks & Fast Wavelet Algorithms ๐Ÿ“ Outline Goals

Two-Scale Relations โ†’ Filter Banks

Analysis (Decomposition) Filter Bank

Synthesis (Reconstruction) Filter Bank

Mallatโ€™s Pyramid Algorithm

Computational Complexity

Example: One-Level DWT in Python

Exercises

a = x                  # a_0
for j in 0..J-1:
    a, d[j+1] = analysis_filter_bank(a)
# store a_J and all dโ€™s

import numpy as np
import pywt

# sample signal
x = np.random.randn(1024)

# choose wavelet
wav = pywt.Wavelet('db4')
h, g = wav.dec_lo, wav.dec_hi       # analysis low-/high-pass
hr, gr = wav.rec_lo, wav.rec_hi    # reconstruction filters

# 1-level DWT via filter bank
# convolution + downsample
a1 = np.convolve(x, h, mode='full')[::2]
d1 = np.convolve(x, g, mode='full')[::2]

# one-level inverse DWT
# upsample + convolution + sum
up_a = np.zeros(2*len(a1)); up_a[::2] = a1
up_d = np.zeros(2*len(d1)); up_d[::2] = d1
x_rec = np.convolve(up_a, hr, mode='full') + np.convolve(up_d, gr, mode='full')
x_rec = x_rec[:len(x)]  # trim to original length