3
$\begingroup$

I'm trying to get a grip on Wavelets. I've read "Wavelets, Their Friends, and What They Can Do for You" which lead me to an implementation of the discrete DWT with filter banks. Basically, I'm using the equations

$$ a_{j,k} = \left[\tilde{H} * a_{j+1}\right](2k)\\ d_{j,k} = \left[\tilde{G} * a_{j+1}\right](2k) $$

which involve convolution and downsampling to get the coefficients $a$ and $d$. $\tilde{H}$ and $\tilde{G}$ refer to the flipped impulse response of the wavelet, for which I currently use normalized Daubechies 2 (db2), i. e. $H = \{0.483, 0.837, 0.224, -0.129\}$ and $\tilde{H} = \{-0.129, 0.224, 0.837, 0.483\}$. Convolution is defined as

$$ \left[\tilde{H} * a_{j+1}\right](2k) := \sum_{n=0}^{3} \tilde{h}_na_{j+1,2k-n} $$

and uses a periodically extended signal. For $\tilde{G}$ it is defined likewise.

Now I wanted to transform the very simple signal $x = [1,2,3,4] = a_{1}$ to the coefficients $a$ and $d$. For testing purposes I used PyWavelets, which claims to be tested against Matlab. The result is

$$ a_{0,0}=2.82842712\ a_{0,1}=4.24264069\\ d_{0,0}=-0.51763809\ d_{0,1}=1.93185165 $$

for both implementations, i.e. my own and PyWavelets. However, for a slightly extended signal $x = [1,2,3,4,5]$, the ordering and some values of the coefficients does not match. E.g. for $a$ my implementation yields $[3.725, 5.787, 3.311]$, whereas PyWavelets yields $[3.311, 3.725, 7.106]$.

Now I'm confused and I'm trying to clarify some things, so

  1. Is there a way to test the correctness of the decomposition? E.g. by applying inverse DWT and testing whether the resulting signal matches the original signal?

  2. If 1. succeeds in my case, then is the ordering of the coefficients not relevant if the correct reverse ordering is applied?

  3. Why does the book names Daubechies Wavelet as DB2, although it has 4 taps? PyWavelets does this likewise, but e.g. Wikipedia does this not, anyway, I'm not a fan of wikipedia.

Update

Thanks to datageist for answering question #3.

Regarding the other two, I came up with the idea that my convolution might be wrong, and I tested two other "modes" of PyWavelets, namely zero-padding (zpd) and periodic-padding (ppd). Before that I used the periodic mode (per) which basically also performs ppd but yields less elements, and I had problems with that. So, I changed the signal with the filter and from now on moved the filter through the signal. For ppd I get the following scheme:

$$ \begin{matrix} x & 1 & 2 & 3 & 4 & 5 & 6 \\ \\ a_3 & 0.224 & -0.129 & 0 & 0 & 0.483 & 0.832 \\ a_2 & 0.483 & 0.832 & 0.224 & -0.129 & 0 & 0 \\ a_1 & 0 & 0 & 0.483 & 0.832 & 0.224 & -0.129 \\ a_0 & 0.224 & -0.129 & 0 & 0 & 0.483 & 0.832 \end{matrix} $$

Multiplying row elements with $x$ and summing up yields the correct result for each row, and it also matches with PyWavelets (except for rounding issues). The same goes for zpd:

$$ \begin{matrix} x & 1 & 2 & 3 & 4 & 5 & 6 \\ \\ a_3 & 0.224 & -0.129 & 0 & 0 & 0 & 0 \\ a_2 & 0.483 & 0.832 & 0.224 & -0.129 & 0 & 0 \\ a_1 & 0 & 0 & 0.483 & 0.832 & 0.224 & -0.129 \\ a_0 & 0 & 0 & 0 & 0 & 0.483 & 0.832 \end{matrix} $$

which also yields the correct results.

However, for per, the results are still wrong, so I'll have to find out what they do there.

$\endgroup$
2
  • 1
    $\begingroup$ For the DB2 naming thing, see my answer here: dsp.stackexchange.com/questions/328/… $\endgroup$
    – datageist
    Commented Mar 11, 2013 at 0:23
  • $\begingroup$ Welcome to DSP.SE! This is a great question! $\endgroup$
    – Phonon
    Commented Mar 12, 2013 at 6:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.