Mother wavelet from scaling function: D4 and Haar

D4 dyadic wavelet

We can compute the mother wavelet from the scaling function. Let me show you how to do this for Daubechies’s D4.

First, we need the scaling function.

the D4 scaling function again, quickly

This is review. There is a matrix M0 which has an eigenvector with eigenvalue 1, and that eigenvector gives me the values of the scaling function \varphi at the integers. Once I have initial values, I can compute \varphi by recursion (and because of the specific form of the recursion, only at points whose denominator is a power of 2).

I start by constructing the matrix M0 in principle…

M_0 = \left(\begin{array}{llll} \sqrt{2}\  \text{h0} & 0 & 0 & 0 \\ \sqrt{2}\  \text{h2} & \sqrt{2}\  \text{h1} & \sqrt{2}\  \text{h0}   & 0 \\ 0 & \sqrt{2}\  \text{h3} & \sqrt{2}\  \text{h2} & \sqrt{2}\    \text{h1} \\ 0 & 0 & 0 & \sqrt{2}\  \text{h3}\end{array}\right)

(This comes from evaluating the dilation equation at the integers, then writing the resulting system of equations as a matrix-vector equation. It turns out to be M_0\ \varphi = \varphi\ . In fact, I construct M0 from its pattern, but i know how to derive – hence check – it.)

Then I set the values of the filter coefficients h…

\left\{\text{h0}\to \frac{1+\sqrt{3}}{4 \sqrt{2}\ },\text{h1}\to   \frac{3+\sqrt{3}}{4 \sqrt{2}\ },\text{h2}\to   \frac{3-\sqrt{3}}{4 \sqrt{2}\ },\text{h3}\to   \frac{1-\sqrt{3}}{4 \sqrt{2}\ }\right\}

The matrix M0 becomes…

M_0 = \left(\begin{array}{llll} 0.683013 & 0. & 0. & 0. \\ 0.316987 & 1.18301 & 0.683013 & 0. \\ 0. & -0.183013 & 0.316987 & 1.18301 \\ 0. & 0. & 0. & -0.183013\end{array}\right)

Now I look for an eigenvector having eigenvalue 1. Here are the eigenvalues (first row) and eigenvectors (subsequent rows)…

\begin{array}{c} \{1.,0.683013,0.5,-0.183013\} \\ \left(\begin{array}{llll} 0. & -0.965926 & 0.258819 & 0. \\ 0.408248 & -0.816497 & 0.408248 & 0. \\ 0. & 0.707107 & -0.707107 & 0. \\ 0. & 0.408248 & -0.816497 & 0.408248\end{array}\right)\end{array}

We see, as we saw before, that we want the first eigenvector from that list. Mathematica has given me a vector of length 1; I want a vector – I’ll explain later – whose components sum to 1.

V = \{0.,1.36603,-0.366025,0.\}

I take those components as the initial values of the scaling function, i.e. its values at the integers. Then I write a recursive function definition, which includes the requirement that the function is zero outside the interval [0,3].

Frankly, the easiest way to show it to you is a drawing, especially of what Mathematica knows after I make the definition; read the last line.

D4 may 9 1

In order to make a point, I am not going to evaluate that function anywhere else. I have all I need for now.

the D4 mother wavelet

Let me hand you another recipe. The “mother wavelet” \psi satisfies an equation very much like the dilation equation. We have

\psi(t) = \sum_{n}{g(n)\ \sqrt{2}\ \ \varphi(2\ t - n)}

We do not have to specify that the function is zero outside [0,3]; all we have to do is feed it \varphi\ .

It’s important that it is not a recursion for \psi\ : the LHS is \psi(t) but the RHS is still the scaling function \varphi(2t-n)\ . And the coefficients have changed. They are often denoted by h1 or by g. I think I’ll use g.

The g(n) are related to the h(n), but not uniquely. In general,

g(n) = \pm (-1)^n\ h(L-1-n)\ , for L an even integer (I’m pretty sure it has to be even).

An extremely convenient choice is L = N, the number of nonzero h’s, in which case we get

g(n) = \pm (-1)^n\ h(N-1-n)\ ,

which simply says reverse the h’s and alternate the signs.

That is, for our case, N = 4, so we’re looking at h(3-n), and then

g(0) = h(3)
g(1) = -h(2)
g(2) = h(1)
g(3) = -h(0)

(or the negative of all those).

Here are our h’s again…

\left\{\frac{1+\sqrt{3}}{4 \sqrt{2}\ },\frac{3+\sqrt{3}}{4   \sqrt{2}\ },\frac{3-\sqrt{3}}{4 \sqrt{2}\ },\frac{1-\sqrt{3}}{4   \sqrt{2}\ }\right\}

or

\{0.482963,0.836516,0.224144,-0.12941\}

We reverse them, and alternate the signs, in order to get the g’s.

\left\{\frac{1-\sqrt{3}}{4 \sqrt{2}\ },-\frac{3-\sqrt{3}}{4   \sqrt{2}\ },\frac{3+\sqrt{3}}{4   \sqrt{2}\ },-\frac{1+\sqrt{3}}{4 \sqrt{2}\ }\right\}

or

\{-0.12941,-0.224144,0.836516,-0.482963\}

Oddly enough, Burrus et al. showed the opposite of those signs. That doesn’t agree with their own equation, and it would lead to the negative of the following graph – but my picture matches their picture!

Now we define \psi in terms of \varphi(2t-n)\

D4 may 9 2

It’s time to just plot the D4 mother wavelet.

D4 may 9 3

and that looks good.

NOTE that it will compute whatever it needs of \varphi\ , so in a sense it is recursive. This is the point I wanted to make: I did not have to compute \varphi for it, it could do it itself.

Just to put them near each other, here’s a picture of the scaling function:

D4 may 9 4

the Haar wavelet system

Let me show you all of that again for a much simpler case. The Haar wavelets, as they are now called, were invented long before we knew they were a wavelet system. Its scaling function is a step function, defined to be 1 on the half open interval [1,0) and zero elsewhere. I will eventually show you – I hope – that it could be considered the D2 scaling function also.

Oh, here I go again using a cannon when a slingshot would more than suffice. There is no reason to use recursion to graph this scaling function, nor even to graph this mother wavelet. But it’s nice to know that the algorithm works in the simplest case.

Haar (D2) scaling function

We start with the M0 matrix in principle, for two nonzero h’s…

M_0 = \left(\begin{array}{ll} \sqrt{2}\  \text{h0} & 0 \\ 0 & \sqrt{2}\  \text{h1}\end{array}\right)

I simply tell you that the h’s have these (two identical) values…

\left\{\text{h0}\to \frac{1}{\sqrt{2}\ },\text{h1}\to   \frac{1}{\sqrt{2}\ }\right\}

Then the matrix M0 is…

M_0 = \left(\begin{array}{ll} 1. & 0. \\ 0. & 1.\end{array}\right)

Well, well. By inspection – it’s diagonal! – there are two eigenvalues equal to 1, and the eigenvectors are the columns of that matrix. We might as well choose the eigenvector

V = \{1,0\}

The sum of the components is already 1, so we don’t need to scale it to get the initial values of the scaling function.

We define the scaling function \varphi as usual…

D4 may 9 5

Let’s plot it.

D4 may 9 6

A unit step function on the half-open unit interval. I’m rather pleased to see that.

D2 wavelet

To get the g’s for the mother wavelet, we reverse the h’s (oh, they’re the same!) and alternate the signs…

\left\{\frac{1}{\sqrt{2}\ },-\frac{1}{\sqrt{2}\ }\right\}

We write the definition… ask what we know… and then we plot the mother wavelet…

D4 may 9 7

Yes! That’s exactly what I wanted to see. And if you’ve ever seen the Haar (D2) mother wavelet, it’s what you wanted to see, too.

I think the next post will show you a few more scaling functions and mother wavelets, for six nonzero h’s.

Advertisements

2 Responses to “Mother wavelet from scaling function: D4 and Haar”

  1. Asif Iqbal Says:

    Really Very Helpfull. Thanks for writing this. I was stuck in these things from many days. and i got it now .. Thanks Again.. 🙂

  2. rip Says:

    You’re welcome. It’s nice to know that my posts are helping.

    Rip


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: