Professional Documents
Culture Documents
Arne Jensen, Anders La Cour-Harbo (Auth.) - Ripples in Mathematics - The Discrete Wavelet Transform-Springer-Verlag Berlin Heidelberg (2001)
Arne Jensen, Anders La Cour-Harbo (Auth.) - Ripples in Mathematics - The Discrete Wavelet Transform-Springer-Verlag Berlin Heidelberg (2001)
Ripples in
Mathematics
The Discrete Wavelet
Transform
, Springer
Arne Jensen
Aalborg University
Department of Mathematical Sciences
Fredrik Bajers Vej 7
9220 Aalborg, Denmark
e-mail: matarne@math.auc.dk
Anders1a Cour-Harbo
Aalborg University
Department of Control Engineering
Fredrik Bajers Vej 7C
9220 Aalborg, Denmark
e-mail: alc@control.auc.dk
Mathematics Subject Classification (2000): 42-01, 42C40, 65-01, 65T60. 94-01, 94A12
This work is subject to copyright. All rights are reserved, whether the whole or part of
the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations,
recitation, broadcasting, reproduction on microfilm or in any other way, and storage in data banks.
Duplication of this publication or parts thereof is permilled only under the provisions of the German
Copyright Law of September 9, 1965, in its current version, and permission for use must always be
obtained from Springer-Verlag. Violations are liable for prosecution under the German Copyright Law.
The use of general descriptive names, registered names, trademarks etc. in this publication does not
imply, even in the absence of a specific statement, that such names are exempt from the relevant
protective laws and regulations and therefore free for general use.
Cover design: Kiinkel&Lapka, Heidelberg
Typeselling by the authors using a ~macro package
Printed on acid-free paper SPIN 10773914 46/3142ck-54 321 0
Preface
Yet another book on wavelets. There are many books on wavelets available,
written for readers with different backgrounds. But the topic is becoming ever
more important in mainstream signal processing, since the new JPEG2000
standard is based on wavelet techniques. Wavelet techniques are also impor-
tant in the MPEG-4 standard.
So we thought that there might be room for yet another book on wavelets.
This one is limited in scope, since it only covers the discrete wavelet trans-
form, which is central in modern digital signal processing. The presentation
is based on the lifting technique discovered by W. Sweldens in 1994. Due to a
result by I. Daubechies and W. Sweldens from 1996 this approach covers the
same class of discrete wavelet transforms as the one based on two channel
filter banks with perfect reconstruction.
The goal of this book is to enable readers, with modest backgrounds
in mathematics, signal analysis, and programming, to understand wavelet
based techniques in signal analysis, and perhaps to enable them to apply
such methods to real world problems.
The book started as a set of lecture notes, written in Danish, for a group
of teachers of signal analysis at Danish Engineering Colleges. The material
has also been presented to groups of engineers working in industry, and used
in mathematics courses at Aalborg University.
We would like to acknowledge the influence of the work by W. Sweldens
[25, 26] on this book. Without his lifting idea we would not have been able
to write this book. We would also like to acknowledge the influence of the
paper [20] by C. Mulcahy. His idea of introducing the wavelet transform
using a signal with 8 samples appealed very much to us, so we have used it
in Chap. 2 to introduce the wavelet transform, and many times later to give
simple examples illustrating the general ideas. It is surprising how much of
wavelet theory one can explain using such simple examples.
This book is an exposition of existing, and in many cases well-known,
results on wavelet theory. For this reason we have not provided detailed ref-
erences to the contributions of the many authors working in this area. We
acknowledge all their contributions, but defer to the textbooks mentioned in
the last chapter for detailed references.
Tokyo, December 2000 Arne Jensen
Aalborg, December 2000 Anders la Cour-Harbo
Contents
1. Introduction.............................................. 1
1.1 Prerequisites........................................... 1
1.2 Guide to the Book. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Background Information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2. A First Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1 The Example. .. .. . . .. .. .. . . .. . . .. . .. 7
2.2 Generalizations......................................... 10
Exercises 10
5. Interpretation............................................ 37
5.1 The First Example. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 37
5.2 Further Results on the Haar Transform 40
5.3 Interpretation of General DWT 45
Exercises 50
Exercises 60
8. Wavelet Packets... .. .. . . .. . . .. . .. 87
8.1 From Wavelets to Wavelet Packets.. . . . . . . . . . . . . . . . . . . . . .. 87
8.2 Choice of Basis. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 90
8.3 Cost Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 96
Exercises 98
Exercises 185
References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Index 241
1. Introduction
1.1 Prerequisites
The prerequisites for reading this book are quite modest, at least for the first
six chapters. For these chapters familiarity with calculus and linear algebra
will suffice. The numerous American undergraduate texts on calculus and lin-
ear algebra contain more material than is needed. From Chap. 7 onwards we
assume familiarity with either the basic concepts in digital signal processing,
as presented in for example [22, 23] (or any introductory text on digital signal
processing), or with Fourier series. What is needed is the Fourier series, and
the z-transform formulation of Fourier series, together with basic concepts
from filter theory, or, in mathematical terms, elementary results on convolu-
tion of sequences. This chapter is somewhat more difficult to read than the
previous chapters, but the material is essential for a real understanding of
the wavelet transforms.
The ultimate goal of this book is to enable the reader to use the discrete
wavelet transform on real world problems. For this goal to be realized it is
necessary that the reader carries out experiments on the computer. We have
chosen MATLAB as the environment for computations, since it is particularly
well suited to signal processing. We give many examples and exercises using
MATLAB. A few examples are also given using the C language, but these
are entirely optional. The MATLAB environment is easy to use, so a modest
background in programming will suffice. In Chap. 13 we provide a number
of examples of applications of the various wavelet transforms, based on a
public domain toolbox, so no programming skills are needed to go through
the examples in that chapter.
i:
function 1/J, well localized in time and frequency (for example a Gaussian),
and replaced translation in frequency by scaling. The transform is defined as
Under some additional conditions on 'l/J the transform is invertible. This trans-
form turned out the be better than Fourier analysis in handling transient
signals. The two authors gave the name 'ondelette', in English 'wavelet,' to
the analyzing function 'l/J. Connections to quantum mechanics were also es-
tablished in the early papers.
It turned out that this continuous wavelet transform was not that easy to
apply. In 1985 Y. Meyer discovered that by using certain discrete values of
the two parameters a, b, one could get an orthonormal basis for the Hilbert
space L 2 (R). More precisely, the basis is of the form
see for example [5, 15]. From this point onwards the mathematics becomes
highly nontrivial. We choose to stop our exposition here. The reader will have
to have the necessary mathematical background to continue, and with that
background there is a large number of excellent books with which to continue.
2. A First Example
Table 2.1. Mean and difference computation. Differences are in boldface type
56 40 8 24 48 48 40 16
48 16 48 28 8 -8 0 12
32 38 16 10 8 -8 0 12
35 -3 16 10 8 -8 0 12
the calculation. Beginning with the last row, we compute the first two entries
in the third row as 32 = 35 + (-3) and 38 = 35 - (-3), Analogously, the first
4 entries in the second row are calculated as 48 = 32 + (16), 16 = 32 - (16),
48 = 38 + (10), and finally 28 = 38 - (10). Repeating this procedure we get
the first row in the table.
Do we gain anything from this change of representation of the signal? In
other words, does the signal in the fourth row exhibit some nice features not
seen in the original signal? One thing is immediately evident. The numbers
in the fourth row are generally smaller than the original numbers. So we have
achieved some kind of loss-free compression by reducing the dynamic range
of the signal. By loss-free we mean that we can transform back to the original
signal, without any loss of information. We could measure the dynamics of
the signal by counting the number of digits used to represent it. The first row
contains 15 digits. The last row contains 12 digits and two negative signs. So
in this example the compression is not very large. But it is easy to give other
examples, where the compression of the dynamic range can be substantial.
We see in this example the pair 48, 48, where the difference of course is
zero. Suppose that after transformation we find that many difference entries
are zero. Then we can store the transformed signal more efficiently by only
storing the non-zero entries (and their locations).
Let us now suppose that we are willing to accept a certain loss of quality
in the signal, if we can get a higher rate of compression. We can try to
process our signal, or better, our transformed signal. One technique is called
thresholding. We choose a threshold and decide to put all entries with an
absolute value less than this threshold equal to zero. Let us in our example
choose 4 as the threshold. This means that we in Table 2.1 replace the entry
-3 by 0 and then perform the reconstruction. The result is in Table 2.2.
The original and transformed signal are both shown in Fig. 2.1. We have
chosen to join the given points by straight line segments to get a good visual-
ization of the signals. Clearly the two graphs differ very little. If presented in
separate plots, it would be difficult to tell them apart. Now let us perform a
more drastic compression. This time we choose the threshold equal to 9. The
computations are given in Table 2.3, and the graphs are plotted in Fig. 2.2.
Notice that the peaks in the original signal have been flattened. We also note
that the signal now is represented by only four non-zero entries.
2.1 The Example 9
50
I
40 1/
"\
\
30
\
\
20 \
\
10
1 2 3 4 5 6 7 8
Fig. 2.1. Original signal and modified signal (dashed line) with threshold 4
60 ,-----.----,.-----.--,----,.---,-----,
50
40
30
20
10
OL.-----'----'-------'---...L.-----'----'-------l
1 2 3 4 5 6 7 8
Fig. 2.2. Original signal and modified signal (dashed line) with threshold 9
10 2. A First Example
We note that there are several variations of the procedure used here. We could
have stored averages and differences, or we could have used the difference
between the second element of the pair and the computed average. The first
choice will lead to boldface entries in the tables that can be obtained from
the computed ones by multiplication by a factor -2. The second variant is
obtained by multiplication by -1.
2.2 Generalizations
Exercises
parameter n. This also has the advantage that we can denote sequences by
Xl and X2, or in the more detailed notation {xI[n]}nEZ and {x2[n]}nEZ.
The condition for finite energy is for an infinity signal
00
L 2
Ix[nll < 00.
n=-oo
A finite signal always satisfies this condition. In the sequel the reader can
assume that all signals are finite. Note that there are several technicalities
involved in treating infinite sums, but since they are irrelevant for most of
what we want to present here, we will omit these technicalities. The set of
all signals with finite energy is denoted by f2(Z) in the literature. We will
use this convenient notation below. Often we use the mathematical term
sequence instead of . Sometimes we also use the term vector, in particular in
connection with use of results from linear algebra.
Let us now return to the example in Sect. 2.1. We took a pair of numbers
a, b and computed the mean, and the difference between the first entry and
the mean
a+b
s= -2-' (3.1)
d=a-s. (3.2)
a=s+d, (3.3)
b=s-d. (3.4)
As mentioned at the end of Sect. 2.1 we could have chosen another compu-
tation of the difference, as in
a+b
j1.=-2-' (3.5)
c5=b-a. (3.6)
Fig. 3.1. The three steps in a lifting building block. Note that the minus means
'the signal from the left minus the signal from the top'
split The entries are sorted into the even and the odd entries. It is important
to note that we do this only to explain the functionality of the algorithm.
In (effective) implementations the entries are not moved or separated.
prediction If the signal contains some structure, then we can expect corre-
lation between a sample and its nearest neighbors. In our first example
the prediction is that the signal is constant. More elaborately, given the
value at the sample number 2n, we predict that the value at sample 2n+ 1
is the same. We then replace the value at 2n + 1 with the correction to
3.2 Definition of Lifting 15
the prediction, which is the difference. In our notation this is (using the
implementation given in (3.7))
dj - 1 [n] = sj[2n + 1] - sj[2n] .
In general, the idea is to have a prediction procedure P and then compute
d j - 1 = odd j _ 1 - P(evenj_d . (3.9)
Thus in the d signal each entry is one odd sample minus some prediction
based on a number of even samples.
update Given an even entry, we have predicted that the next odd entry
has the same value, and stored the difference. We then update our even
entry to reflect our knowledge of the signal. In the example above we
replaced the even entry by the average. In our notation (and again using
the implementation given in (3.7))
sj_t[n] = sj[2n] + dj-t[n]/2 .
In general we decide on an updating procedure, and then compute
Sj-l = eVenj_l + U(dj-d . (3.10)
The algorithm described here is called one step lifting. It requires the choice
of a prediction procedure P, and an update procedure U.
The discrete wavelet transform is obtained by combining a number of
lifting steps. As in the example in Table 2.1 we keep the computed differences
d j - 1 and use the average sequence Sj-l as input for one more lifting step.
This two step procedure is illustrated in Fig. 3.2.
seen to be the mean value of all entries in the original sequence. Taking j = 3
and using the same notation as in the tables in Chap. 2, then we see that
the Table 2.1 is represented symbolically as Table 3.1. Now if we use the
'in place' procedure, and also record the intermediate steps, then we get the
representation in Table 3.2. This table makes it evident that in implementing
Table 3.2. 'In place' representation for Table 3.1 with intermediate steps. Predic-
tion steps are labeled with P, and update steps with U
I~~ ~W ~~ ~~ ~~ ~~ ~~ ~M
83[0] d2[O] 83[2] d2[1] 83[4] d2[2] 83[6] d2[3] P
82[0] d2[0] 82[1] d2[l] 82[2] d2[2] 82[3] d2[3] U
82[0] d2[O] d1 [0] d2[1] 82[2] d2[2] dIll] d2[3] P
8IlO] d2[O] d1 [O] d2[1] 81[1] d2[2] dl[l] d2[3] U
81[0] d2[O] d1 [O] d2[l] do [0] d2[2] dIll] d2[3] P
80[0] d2[0] dl[O] d2[1] do [0] d2[2] dIll] d2[3] U
the procedure on the computer one has to be careful with the indices. For
example, by inspecting the table carefully it is seen that one should step
through the rows in steps of length 2, 4, and 8, while computing the s-values.
We have previously motivated the prediction operation with the reduc-
tion in dynamic range of the signal obtained in using differences rather than
the original values, potentially leading to good compression of a signal. The
update procedure has not yet been clearly motivated. The update performed
in the first example in Chap. 2 was
(3.11)
It turns out that this operation preserves the mean value. The consequence
is that all the s sequences have the same mean value. It is easy to verify in
the case of the example in Table 2.1, since
3.3 A Second Example 17
56 + 40 + 8 + 24 + 48 + 48 + 40 + 16
8
48 + 16 + 48 + 28 32 + 38
-- 4 -- 2 -35
- .
It is not difficult to see that this hold for any s sequence of length 2j . The
mean value of such a sequence is
2 i -1
S = Tj L Sj[n] .
n=O
which shows the result, since the signal 8j is twice as long as 8j-l' In partic-
ular, solO] equals the mean value of the original samples Sj[O], ... ,sj[2 j - 1]
(which in the first example was 35).
and this difference is all we need to store. The principle is shown in Fig. 3.3.
We decide to base the procedure on the two most recently computed
differences. We take it of the form
(3.12)
n n
We would like to have the same property here. Let us first rewrite the ex-
pression for Sj-l [n] above,
n n n
(3.15)
n n
We say that the transform preserves the first moment of the sequence. The
average is also called the zeroth moment of the sequence.
In the above presentation we have simplified the notation by not specify-
ing where the finite sequences start and end, thereby for the moment avoiding
keeping track of the ranges of the variables. In other words, we have consid-
ered our finite sequences as infinite, adding zeroes before and after the given
entries. In implementations one has to keep track of these things, but doing
so now would obscure the simplicity of the lifting procedure. In later chapters
we will deal with these problems in detail, see in particular Chap. 10.
sj[2n + 1].
dj_1[n]
We now look at the lifting procedure in general. Let us first look at how
we can invert the lifting procedure. It is done by reversing the arrows and
changing the signs. Thus the direct transform
d j - 1 = oddj - 1 - P(evenj-d
Sj-l = eVenj_l + U(dj-d
These steps are illustrated in Fig. 3.4. The last step, where the sequences
eVenj_l and oddj_l are merged to form the sequence Sj, is given to explain
the algorithm. It is not performed in implementations, since the entries are
not reordered. As an example, the inverse transform of (3.13) and (3.14) is
Looking at Fig. 3.4 once more, we see that the update step is reversed by the
same update step, but with subtraction instead of addition, and vice versa for
the prediction step. Since each step is inverted separately, we can generalize
in two ways. We can add further pairs of prediction and update steps, and we
can add them singly. If we insist in having them in pairs (this is useful in the
theory, see Chap. 12), we can always add an operation of either type which
does nothing. As an illustration Fig. 3.5 shows a direct transform consisting
of three pairs of prediction and update operations.
It turns out that this generalization is crucial in applications. There are
many important transforms, where the steps do not occur in pairs. Here is
an example, where there is a U operation followed by a P operation and
20 3. DWT and Lifting
another U operation. Furthermore, in the last two steps, in (3.21) and (3.22),
we add a new type of operation which is called normalization, or sometimes
rescaling. The resulting algorithm is applied to a signal {Sj [n]}nEZ as follows
dj - 1 [n] = V3+
V2 1 dj(1)_ 1 [n] . (3.22)
Since there is more than one U operation, we have used superscripts on the
sand d signals in order to tell them apart. Note that in the normalization
steps we have
V3-1 V3+1
--·---1
V2 V2 - .
The reason for the normalization will become apparent in the next chapter,
when we start doing computations. The algorithm above is one step in the
discrete wavelet transform based on an important filter, which in the litera-
ture is often called Daubechies 4. The connection with filters will be explained
in Chap. 7.
To find the inverse transform we have to use the prescription given above.
We do the steps in reverse order and with the signs reversed. Thus the normal-
ization is undone by multiplication by the inverse constants etc. The result
is
3.5 DWT in General 21
(1)
dj _1[n] =
J3-I
V'i dj - 1[n] (3.23)
(2)
Sj_1[n] = J3V'i+ 1Sj-1[n] (3.24)
The contents of the T a box could be the direct Haar transform as given
by (3.28)-(3.31), and the contents of the T s box could be the inverse Haar
transform as given by (3.32)-(3.35). Obviously, we must make sure to use the
inverse transform corresponding to the applied direct transform. Otherwise,
the results will be meaningless.
We can now combine these building blocks to get discrete wavelet trans-
forms. We perform the transform over a certain number of scales j, meaning
that we combine j of the building blocks as shown in Fig. 3.2 in the case of
2 scales, and in Fig. 3.7 in the case of 4 scales. In the latter figure we use the
building block representation of the individual steps.
We use the symbol WP) to denote a direct j scale discrete wavelet trans-
form. The inverse is denoted by WsW. The result of the four scale transform
is the transition
The diagram in Fig. 3.8 shows how it is computed. We use the term scale
to describe how many times the building block T a or T s are applied in the
decomposition of a signal. The word originates from the classical wavelet
theory. The reader should note that we later, in Chap. 8, introduce the term
level, in a context more general than the DWT. When this term is applied to
a DWT decomposition, then the level is equal to the scale plus 1. The reader
should not mix up the two terms.
3.6 Further Examples 23
We have not given the formulas for the inverse transforms. They are obtained
as above by reversing the arrows and changing the signs.
We give one further example of a family of three transforms. We have
taken as an example transforms that start with an update step and a pre-
diction step, which are common to all three. Again, at the end there is a
normalization step.
dj(1)
_ 1[n ] -_ Sj [2n + 1] - 81 (9s j(1)_1[n ] + 3s j(1)_1[n + 1]) (3.43)
CDF(3,1) s~2)
)-1
[n] = S~l)
)-1
[n] + ~d~l)
9 )-1 [n] (3.44)
- 128d)~1[n] + 34d)~1[n + 1]
- 5d)~1 [n + 2]) (3.46)
.j2 (1)
dj-d n ] = 3dj-dn] (3.47)
_ 3 (2)
Sj-dn] - .j2Sj_1[n] . (3.48)
The above formulas for the CDF(2,x) and CDF(3,x) families have been taken
from the technical report [27]. Further examples can be found there.
Exercises
3.1 Verify that the CDF(2,2) transform, defined in (3.13) and (3.14), pre-
serves the first moment, Le. verify that (3.15) holds.
4. Analysis of Synthetic Signals
The discrete wavelet transform has been introduced in the previous two chap-
ters. The general lifting scheme, as well as some examples of transforms, were
presented, and we have seen one application to a signal with just 8 samples.
In this chapter we will apply the transform to a number of synthetic signals,
in order to gain some experience with the properties of the discrete wavelet
transform. We will process some signals by transformation, followed by some
alteration, followed by inverse transformation, as we did in Chap. 2 to the
signal with 8 samples. Here we use significantly longer signals. As an exam-
ple, we will show how this approach can be used to remove some of the noise
in a signal. We will also give an example showing how to separate slow and
fast variations in a signal.
The computations in this chapter have been performed using MATLAB.
We have used the toolbox Uvi_ Wave to perform the computations. See
Chap. 14 for further information on software, and Chap. 13 for an intro-
duction to MATLAB and Uvi_ Wave. At the end of the chapter we give some
exercises, which one should try after having read Sect. 13.1.
-0.5
-1
3.-----.----.----......------,.-------"
-2
dB
~:~~~
0.05
50 100 150 200 250
d7 0 11111111 ",,1111111111 111111111'' ' ' '111111111111111111'' ' ' 1111111111 11111111""""111111111
-0.05 "
20 40 60 80 100 120
0.2
d6 0 111111.,11111111111111"11111111111111,,11111111111111"1 11111
-0.2
10 20 30 40 50 60
4
2
56 0 11111111111111"11111111111111.,11111111111111"1111111IIII 111
-2
-4
10 20 30 40 50 60
Fig. 4.3. The wavelet coefficients from Fig. 4.2 divided into scales, from the DWT
of the signal in Fig. 4.1
one should interpret this graph. In Fig. 4.3 we have plotted the four parts
separately. The top plot is of ds, followed by d 7 , d 6 , and 86' Note that each
plot has its own axes, with different units. Again, these plots are not easy to
interpret. We try a third approach.
We take the transformed signal, 86, d 6 , d 7 , ds, and then replace all entries
except one with zeroes, Le. sequences of the appropriate length consisting
entirely of zeroes. For example, we can take 06, d 6 , 07, Os, where Os is a
signal of length 256 = 2s with zero entries. We then invert this signal using
the inverse three scale discrete wavelet transform based on (3.32)-(3.35).
Schematically, it looks like
wP): 89 -+
8'
9
The result 8~ of this inversion is a signal with the property that if it were
transformed with WP) , the result would be precisely the signal 0 6 , d 6 , 0 7 , Os.
Hence 8~ contains all information on the coefficients on the third scale. The
four possible plots are given in Fig. 4.4. The top plot is the inversion of
0 6 ,06,0 7 , d s followed by 0 6 ,0 6 , d 7 , Os, and 06, d 6 , 07, Os, and finally at the
bottom 86,06,07, Os. This representation, where the contributions are sepa-
rated as described, is called the multiresolution representation of the signal
28 4. Analysis of Synthetic Signals
0.02
06,06,07, dB 0
-0.02 .
0.05 r------r-----,r------.---------,---~
Fig. 4.4. DWT of the signal in Fig. 4.1, Haar transform, multiresolution represen-
tation, separate plots
(in this case over three scales). The plots in Fig. 4.4 correspond to our in-
tuition associated with repeated means and differences. The bottom plot in
Fig. 4.4 could also have been obtained by computing the mean of 8 succes-
sive samples, and then replacing each of these 8 samples by their mean value.
Thus each mean value is repeated 8 times in the plot.
H we invert the transform, we will get back the original signal. In Fig. 4.5
we have plotted the inverted signal, and the difference between this signal
and the original signal. We see that the differences are of magnitude 10- 15 ,
corresponding to the precision of the MATLAB calculations.
We have now presented a way of visualizing the effect of a DWT over a
finite number of scales. We will then perform some experiments with synthetic
signals. As a first example we add an impulse to our sine signal. We change
the value at sample number 200 to the value 2. We have plotted the three
scale representation in Fig. 4.6. We see that the impulse can be localized
in the component d s , and in the averaged signal 86 the impulse has almost
disappeared. Here we have used the very simple Haar transform. By using
other transforms one can get better results.
Let us now show how we can reduce noise in a signal by processing it
in the DWT representation. We take again the sine signal plus an impulse,
and add some noise. The signal is given in Fig. 4.7. The multiresolution
representation is given in Fig. 4.8 The objective now is to remove the noise
from the signals. We will try to do this by processing the signal as follows. In
the transformed representation, 86, d 6 , d 7 , ds, we leave unchanged the largest
4.1 The Haar Transform 29
-1
0 100 200 300 400 500
X 10-15
1
0.5
0
-0.5
-1
0 100 200 300 400 500
Fig. 4.5. Top: Inverse DWT of the signal in Fig. 4.1. Bottom: Difference between
inverted and original signal
dB
-2
:1 I :I
d7
-1
:1 I :I
d6 o:~
-0.5
86
-~r=s:z:=s:J
0 100 200 300 400 500
Fig. 4.6. Multiresolution representation of sine plus impulse at 200, Haar transform
10% of the coefficients, and change the remaining 90% to zero. We then apply
the inverse transform to this altered signal. The result is shown in Fig. 4.9.
We see that it is possible to recognize both the impulse and the sine signal,
but the sine signal has undergone considerable changes. The next section
30 4. Analysis of Synthetic Signals
1.5
-1
Fig. 4.8. Sine plus impulse at 200 plus noise, Haar transform, multiresolution
representation
4.2 The CDF(2,2) Transform 31
1.5
-1
-1.5
o 100 200 300 400 500
Fig. 4.9. Sine plus impulse at 200 plus noise, reconstruction based on the largest
10% of the coefficients, Haar transform
and sample its values in 1024 points, at 1/1024, 2/1024, ... , 1024/1024.
Then we change the values at 1/1024,33/1024,65/1024, etc. by adding 2 to
the computed values. This signal has been plotted in Fig. 4.12. We will now
try to separate the slow variation and the sharp peaks in the signal. We take
32 4. Analysis of Synthetic Signals
-~~
O~~
-0.5
Fig. 4.10. Sine plus impulse at 200 plus noise, multiresolution representation,
CDF(2,2), three scales
o
-1
o
-1
3.5
2.5
1.5
/
v
0.5
"
\
\ V
vV'
"
/
"- L-Y
o
o 0.2 0.4 0.6 0.8
Fig. 4.12. Plot of the function log(2 + sin (37l"Vt) ) plus 2 at points 1/1024, 33/1024,
65/1024, etc.
Exercises
All exercises below require access to MATLAB and Uvi_ Wave (or some other
wavelet toolbox), and some knowledge of their use. You should read Sect. 13.1
before trying to solve these exercises.
4.1 Go through the examples in this chapter, using MATLAB and Uvi_ Wave.
4.2 Carry out experiments on the computer with noise reduction. Vary the
number of coefficients retained, and plot the different reconstructions. Discuss
the results.
4.3 Find the multiresolution representation of a chirp (Le. a signal obtained
from sampling sin(t 2 )).
34 4. Analysis of Synthetic Signals
-~-
-~-
O~~
- 0 . 5 =
O~~
- 0 . 5 =
O.~~
-0.5
_:.~E : Jj
::~~-----'-:
o
~ 200 400 600 800 1000
Fig. 4.13. Multiresolution representation of the signal from Fig. 4.12, six scales,
CDF(2,2)
1.4 ....-------,----,------,-----r-----,
1.2
2.5
1.5
0.5
/
o \ /
-0.5
o 0.2 0.4 0.6 0.8
Fig. 4.15. Signal from Fig. 4.12, with slow variations removed
5. Interpretation
° 1 0 0 0 0 0 0
° ° 1 0 0 0 0 0
° 0 1 0 0 0 0 0
one of the canonical basis vectors in R 8 , is the same as finding the columns
in the matrix (with respect to the canonical basis) of the three scale synthesis
transform WP). This matrix, which we denote by 3
), is shown in (5.1). wi
1 1 1 0 1 0 0 0
1 1 1 0-1 0 0 0
1 1 -1 0 0 1 0 0
W(3) = 1 1 -1 0 0-1 0 0
s (5.1)
1 -1 0 1 0 0 1 0
1 -1 0 1 0 0-1 0
1 -1 0-1 0 0 0 1
1 -1 0-1 0 0 0-1
The first row in Table 5.1 is the transpose of the first column in (5.1), and
so on. Applying this matrix to any length 8 signal performs the inverse Haar
transform. For example, multiplying it with the fourth row of Table 2.3 on
p. 9 (regarded as a column vector) produces the first row of that same table.
The matrix of the direct three scale transform is obtained by computing
the transforms of the eight canonical basis vectors in R 8 . In other words,
we start with the signal [1,0,0,0,0,0,0,0] and carry out the transform as
shown in Table 5.4, and analogously for the remaining seven basis vectors.
The result is the matrix of the direct, or analysis, transform.
5.1 The First Example 39
1 1 1 1 1 1 1 1
8 8 8 8 8 8 8 8
1 1 1 1 1 1 1 1
8 8 8 8 -8 -8 -8 -8
° °° °
1 1 1 1
4 4 -4-4
° ° °°
1 1 1 1
W(3)-
a - 4 4 -4-4 (5.2)
°°°°°°
1 1
2 -2
° ° ° °° °
1 1
2 -2
° ° ° ° °°
1 1
2 -2
° °wi°° ° =°
1 1
2 -2
The second signal is the first signal translated four units in time, but the
transforms look rather different. Actually, this is one of the reasons why
wavelet transforms can be used to localize events in time, as illustrated in
some of the simple examples in Chap. 4. Readers familiar with Fourier anal-
ysis will see that the wavelet transform is quite different from the Fourier
transform with respect to translations in time.
40 5. Interpretation
In the next two subsections we describe some further results on the Haar
transform. They are of a more advanced nature than the other results in
this chapter, but are needed for a deeper understanding of the DWT. The
remaining parts of this chapter can be omitted on a first reading.
Let us now explain why we normalize the Haar transform in the steps (3.30)-
(3.31). This explanation requires a bit more mathematics than the rest of the
chapter. We use the space e2 (Z) of signal of finite energy, introduced in
Chap. 3. The energy in a signal s is measured by the quantity
IIs11 2 = L:ls[nlI
2
• (5.3)
nEZ
The square root of the energy, denoted by Ilsll, is called the norm of the
vector s E e2 (Z). We now compute the norms of the signals in the first and
last row of Table 5.1
for all x E [2(Z). All the building blocks given in Chap. 3 have this property.
In particular, the Haar and Daubechies 4 transform have A = B = .Ii = iJ =
1. Note that we here use the generality of our transform. The transforms T a
and T s can be applied to any vector x E [2(Z).
Since the transforms wiN) and Ws(N) are obtained by iterating the build-
ing blocks, similar estimates hold for these transforms, with constants that
may depend on the scale N.
[~ is ~, (5.6)
2 N entries 2 N entries
ho(t) = 1, t E [0,1] ,
which is independent of N. The second signal (5.7) is obtained from the
function
hI (t) ={ 1, tE [~, !] ,
-1, t E 12,1] ,
again with a function independent of N. The third signal (5.8) is obtained
from sampling the function
42 5. Interpretation
1, t E [0, t] ,
h 2 (t) = { -1, t E ]t,~] ,
0, t E 12,1] .
The pattern is described as follows. We define the function
o o
-1 L-_~-===:...J
o o r
-1 '--- -1 L......._~ ;::;~==-...l
o
-1 L....---i::L.-=-~ ~--.J -1 .....- =.
L......._~ ---.l
o o r
-1 L..- --==-~.......J -1 L--..~~~_ _= - - . J
Table 5.6. Two scale reconstruction for first two unit vectors
1 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1
1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0
1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
results are unchanged, as one can see from the first three lines in Table 5.3.
The results for the two cases with ones in 81 are given in Table 5.6 These two
vectors can be obtained by sampling the two functions ho(2t) and ho(2t -1).
In general, one finds for a given signal of length 2N , transformed down a
number of scales k, 1 :::; k :::; N, results analogous to those above. Thus one
gets a basis of R 2N consisting of vectors obtained by sampling scaled and
translated functions h o(2 n t - m) and h(2 n t - m). Here nand m run through
values determined by the scale considered. As mentioned above, h o is called
the scaling function and h the wavelet.
44 5. Interpretation
eo = [1,0,0,0,0,0,0,0] ,
el = [0,1,0,0,0,0,0,0] ,
e7 = [0,0,0,0,0,0,0,1].
The eight sampled functions will be denoted by h o, ... , h 7 . They are given
by the columns in the matrix (5.1), as before. The transform relationships
can be expressed by the equations
and
Note that we here have to take the transpose of the vectors ek defined above,
apply the matrix, and then transpose the result to get the row vectors h k •
Now let us take a general signal x of length 8, and let y = W~3) (x) denote
the direct transform. Since both the direct and inverse transforms are linear
(preserve linear combinations), and since
7
Y = Ly[n]e n ,
n=O
In this section we give some further examples of the procedure used in the
previous sections, and then state the general result. This section is rather
incomplete, since a complete treatment of these results requires a considerable
mathematical background.
4,....-----,-----r--------r----,...------,
o
-1
-2
-3
-4 L...-_ _--J.. --'- ...L..-_ _- J ......J
the procedure for vectors of length 8,32, 128, and 512, applied to a vector with
a single 1 as its sixth entry. We fit each transform to the interval [0,1). This
requires that we rescale the values of the transform by 2k / 2 , k = 3,5,7,9. The
result is shown in Fig. 5.3. We recall that the inverse Daubechies 4 transform
includes the normalization step. This figure shows that the graphs rapidly
approach a limiting graph, as we increase the length of the vector. This is a
46 5. Interpretation
4r----r-----.------,,-----,-----,
Ol----~
-1
-2
-3 '--_ _--'- -'---_ _- - L - ' - -_ _---l
Fig. 5.3. Inverse Daubechies 4 of sixth basis vector, length 8, 32, 128 and 512,
rescaled
result that can be established rigorously, but it is not easy to do so, and it is
way beyond the scope of this book.
One can interpret the limiting function in Fig. 5.3 as a function whose
values, sampled at appropriate points, represent the entries in the inverse
transform of a vector of length 2N , with a single 1 as its sixth entry. For N
just moderately large, say N = 12, this is a very good approximation to the
actual value. See Fig. 5.4 for the result for N = 12, Le. a vector of length
4096.
For all other basis vectors, except [1,0,0, ... ,0], one gets similar results
in the sense that the graph has the same form, but will be scaled and/or
translated. The underlying function is also here called the wavelet. For the
vector [1,0,0, ... ,0] one gets a different graph. The underlying function is
again called the scaling function.
The theory shows that if one chooses to transform a signal of length 2N to
a scale k, then the inverse transform of the unit vectors with ones at places 1
to 2N -k will be approximations to translated copies of the scaling function.
Let us repeat these computations for the inverse transform CDF(2,2) from
Sect. 3.3 (the formulas for the inverse are given in Sect. 3.4), and at the same
°
time illustrate how the wavelet is translated depending on the placement of
the 1 in the otherwise vector. An example is given in Fig. 5.5. The difference
in the graphs in Fig. 5.5 and Fig. 5.4 is striking. It reflects the result that
the Daubechies 4 wavelet has very little regularity (it is not differentiable),
whereas the other wavelet is a piecewise linear function.
5.3 Interpretation of General DWT 47
4,----,----r--------,------.--------,
01-----,
-1
-2
-3
-4 '---_ _---'- ...L..-._ _- - ' - ....J........_ _---J
Fig. 5.4. Inverse Daubechies 4 of sixth basis vector, length 4096, rescaled. The
result is the Daubechies 4 wavelet
jl~, 1-------,---:------1--.----'---:j
Fig. 5.5. Inverse CDF(2,2) of three basis vectors of length 64, entry 40, or 50,
or 60, equal to 1 and the remaining entries equal to zero. The result is the same
function (the wavelet) with different translations
48 5. Interpretation
Finally, if we try to find the graphs of the scaling function and wavelet un-
derlying the direct CDF(2,2) transform, then we get the graphs in Fig. 5.6
and Fig. 5.7. These functions are quite complicated. These figures have been
generated by taking N = 16 and a transform of k = 12 scales. To generate
the scaling function we have taken the transform of a vector with a one at
place 8. For the wavelet we have taken the one at place 24. It is interesting to
see that while the analysis wavelet and scaling function are very simple func-
tions (we have not shown the scaling function of CDF(2,2), see Exer. 5.6), the
inverse of that same transform (synthesis) have some rather complex wavelet
and scaling functions.
0.15,....---,....-----,,....-----,,-----,----,------,
0.1
0.05
-0.05
0.15,---.-----.-----,-----.-----.-----,
0.1
0.05
01--------.,..,"" ""''''
-0.05
As stated above, these results are strictly correct only in a limiting sense,
and they are not easy to establish. There is one further complication which
we have omitted to state clearly. If one performs the procedure above with a
1 close to the start or end of the vector, then there will in general be some
strange effects, depending on how the transform has been implemented. We
refer to these as boundary effects. They depend on how one makes up for
missing samples in computations near the start or end of a finite vector, the
so-called boundary corrections, which will be considered in detail in Chap. 10.
We have already mentioned zero padding as one of the correction methods.
This is what we have used indirectly in plotting for example Fig. 5.7, where
we have taken a vector with a one at place 24, and zeroes everywhere else.
If we try to interpret these results, then we can say that the direct trans-
form resolves the signal into components of the shape given by the scaling
function and the wavelet. More precisely, it is a superposition of these com-
ponents, with weight according to the value of the entry in the transform,
since the basic shapes were based on vectors with entry equal to 1. This is a
generalization of the concrete computation at the end of Sect. 5.2.2.
Readers interested in a rigorous treatment of the interpretation of the
transforms given here, and with the required mathematical background, are
referred to the literature, for example the books by 1. Daubechies [5], S. Mal-
lat [16], and M. Vetterli-J. Kovacevic [28]. Note that these books base their
treatment of the wavelet transforms on the concepts of multiresolution anal-
ysis and filter theory. We have not yet discussed these concepts.
50 5. Interpretation
Exercises
Note that the exercises 5.4-5.7 require use of MATLAB and Uvi_ Wave. Post-
pone solving them until after you have read Sect. 13.1. This section is inde-
pendent of the following chapters.
5.1 Carry out the missing five inverse transforms needed to find the matrix
(5.1).
5.2 Carry out the computations leading to (5.2).
5.3 Carry out computations similar to those leading to (5.1), and (5.1), in
order to find the matrices W~l) and W~l) for the one scale Haar DWT applied
to a signal of length 8.
5.4 Carry out the computations leading to Fig. 5.3, as explained in the text.
5.5 Carry out the computations leading to Fig. 5.5. Then try the same for
some of the 61 basis vectors not plotted in this figure.
5.6 Plot the scaling function of CDF(2,2). In MATLAB you can do this using
the functions wspline and wavelet from the Uvi_ Wave toolbox.
5.7 Carry out the computations leading to Fig. 5.6, as explained in the text,
and then those leading to Fig. 5.7.
6. Two Dimensional Transforms
In this chapter we will briefly show how the discrete wavelet transform can be
applied to two dimensional signals, such as images. The 2D wavelet transform
comes in two forms. One which consists of two ID transforms, and one which
is a true 2D transform. The first type is called separable, and the second
nonseparable. We present some results and examples in the separable case,
since it is a straightforward generalization of the results in the one dimen-
sional case. At the end of the chapter we give an example of a nonseparable
2D DWT based on an adaptation of the lifting technique to the 2D case.
In this chapter we will focus solely on grey scale images. Such an image
can be represented by a matrix, where each entry gives the grey scale value of
the corresponding pixel. The purpose of this chapter is therefore to show how
to apply the DWT to a matrix as opposed to a vector, as we did in previous
chapters.
xlI, 1], xlI, 2]'· .. ,x[I, 8], x[2, 1], x[2, 2]'· .. , x[8, 8] .
This yields a signal of length 64. The one dimensional discrete wavelet trans-
form can then be applied to this signal. However, this is usually not a good
approach, since there can be correlation between entries in neighboring rows.
For example, there can be large areas of the image with the same grey scale
value. These neighboring samples are typically not neighbors in the 1D signal
obtained by concatenating the rows, and hence the transform may not detect
the correlation.
Fortunately, there is a different way of applying the 1D transform to a
matrix. We recall from Chap. 5 that we can represent the wavelet transform
itself as a matrix, see in particular Exer. 5.3. This fact is also discussed in
more details in Sect. 10.2. In the present context we take a matrix W a , which
performs a one scale wavelet transformation, when applied to a column vector.
To simplify the notation we have omitted the superscript (1). We apply this
transform to the first column in the matrix X,
We then perform the same operation on the rows of yc. This can be done
by first transposing yc, then multiplying it by W a , and finally transposing
again. The transpose of a matrix A is denoted by AT. Thus the result is
by the usual rules for the transpose of a matrix. We can summarize these
computations in the equation
yc,r = WaXWaT . (6.2)
The superscripts show that we have first transformed columns, and then rows.
But (6.2) shows that the same result is obtained by first transforming rows,
and then columns, since matrix multiplication is associative, (WaX) W aT =
Wa(XW a T ).
We can find the inverse transform by using the rules of matrix computa-
tions. The result is
X = W a-1yc,r(W a-1)T = Wsyc,rWsT . (6.3)
Thus in this section and the next we use the above definition of the separable
DWT, and apply it to 2D signals. The properties derived in the previous
chapters still hold, since we just use two 1D transforms. But there are also
new properties related to the fact that we now have a 2D transform. In the
following section we will discuss some of these properties through a number
of examples.
We will again start with the Haar transform, in order to find out, how we can
interpret the transformed image. We use the same ordering of the entries in
the transform as in Table 3.1, dividing the transform coefficients into separate
low and high pass parts. After a one scale Haar transform on both rows and
columns, we end up with a matrix that naturally is interpreted as consisting
of four submatrices, as shown in Fig. 6.1.
-
Fig. 6.1. Interpretation of the two dimensional DWT
The notation is consistent with the one used for one dimensional signals. The
lower index j labels the size of the matrix. Thus Sj is a 2j x 2j matrix. The
submatrix SSj-l of size 2j - 1 x 2j - 1 consists of entries that contain means
over both columns and rows. In the part SD j _ 1 we have computed means for
the columns and differences for the rows. The two operations are reversed in
the part DS j - 1 . In the part DD j - 1 we have computed differences for both
rows and columns.
We use this one scale Haar-based transform as the building block for
a multiresolution!two dimensional 2D DWT. We perform a one scale 2D
transform, and then iterate on the averaged part SSj_l, in order to get
the next step. We will illustrate the process on some simple synthetic images.
We start with the image given in Fig. 6.2.
We now perform a one scale 2D Haar transform on this image, and obtain
the results shown in Fig. 6.3. The left hand plot shows the coefficients, and
the right hand plot the inverse transform of each of the four blocks with
the other three blocks equal to zero. The right hand plot is called the two
dimensional multiresolution representation, since it is the 2D analogue of
54 6. Two Dimensional Transforms
Fig. 6.3. One step 2D Haar transform, grey scale adjusted. Left hand plot shows
coefficients, right hand plot the inverse transform of each block, the multiresolution
representation
Fig. 6.4. One step 2D CDF(2,2) transform, grey scale adjusted. Left hand plot
shows coefficients, right hand plot the inverse transform of each block, the mul-
tiresolution representation
We now do a two step CDF(2,2) transform. The result is shown in Fig. 6.5.
This time we have only shown a plot of the coefficients. In order to be able
to see details, the grey scale has been adjusted in each of the blocks of the
transform, such that the largest value in a block corresponds to black and
the smallest value in a block to white.
Let us next look at some more complicated synthetic images. All images
have 128 x 128 pixels. On the left hand side in Fig. 6.6 we have taken an image
with distinct vertical and horizontal lines. Using the Haar building block, and
transforming over three scales, we get the result on the right hand side in
Fig. 6.6. We see that the vertical and horizontal lines are clearly separated
into the respective components of the transform. The diagonal components
56 6. Two Dimensional Transforms
Fig. 6.5. CDF(2,2) transform, 2 scales, grey scale adjusted. Plot of the coefficients
contain little information on the line structure, as expected. In this figure the
grey scale has again been adjusted in each of the ten blocks. The plot shows
the coefficients.
We now take the image on the left hand side in Fig. 6.7, with a compli-
cated structure. The Haar transform over three scales is also shown. Here the
directional effects are much less pronounced, as we would expect from the
original image. Again, the plot shows the coefficients.
Fig. 6.6. Left: Synthetic image with vertical and horizontal lines. Right: Haar
transform of image over 3 scales, grey scale adjusted. Plot of the coefficients
6.3 A 2D Transform Based on Lifting 57
Fig. 6.1. Left: Synthetic image with complex structure. Right: Haar transform of
image over 3 scales, grey scale adjusted. Plot of the coefficients
Finally, we try with the real image 'Lena' shown in the left hand image in
Fig. 6.8. This image is often used in the context of image processing. In this
case we have chosen a resolution of 256 x 256 pixels. The decomposition over
two scales is shown on the right hand side, again with the grey scale adjusted
within each block. The plot is of the coefficients.
In Fig. 6.9 we have set the averaged part of the transform equal to zero,
keeping the six detail blocks, and then applied the inverse 2D transform over
the two scales, in order to locate contours in the image. We have adjusted
the grey scale to be able to see the details.
In this section we have experimented with separable 2D DWTs. As the
examples have shown, there is a serious problem with separable transforms,
since they single out horizontal, vertical, and diagonal structures in the given
image. In a complicated image a small rotation of the original could change
the features emphasized drastically.
Fig. 6.8. Left: Standard image Lena in 256 x 256 resolution. Right: CDF(2,2)
transform over 2 scales of 'Lena.' Image is grey scale adjusted
Fig. 6.9. Reconstruction based on the detail parts in Fig. 6.8. Image is grey scale
adjusted
the entries x[m+ 1, n], x[m-l, n], x[m, n+ 1], and x[m, n -1]. This naturally
leads to a division of all points in the plane with integer coordinates into two
classes. This division is defined as follows. We select a point as our starting
point, for example the origin (0,0), and color it black. This point has four
nearest neighbors, which we assign the color white. Next we select one of
the white points and color its four nearest neighbors black. One of them, our
starting point, has already been assigned the color black. Continuing in this
manner, we divide the whole lattice Z x Z into two classes of points, called
black and white points. Each point belongs to exactly one class. We have
illustrated the assignment in Fig. 6.10.
6.3 A 2D Transform Based on Lifting 59
0
• 0
• 0
•
• 0
• 0
• 0
0
• 0
• 0
•
• 0
• 0
• 0
0
• 0
• 0
•
Fig. 6.10. Division of the integer lattice into black and white points
Comparing with the one dimensional case, then the black points correspond
to entries in a one dimensional signal with odd indices, and the white points
to those with even indices. We recall from Sect. 3.2 that the first step in the
one dimensional case was to predict the value at an odd indexed entry, and
then replace this entry with the difference, see (3.9). In the two dimensional
case we do exactly the same. We start with the black points. Each black
point value is replaced with the difference between the original value and
the predicted value. This is done for all black points in the first step. In
the second step we go through the white points and update the values here,
based on the just computed values at the black points, see (3.10) in the
one dimensional case. This is the one scale building block. To define a two
dimensional discrete wavelet transform, we keep the computed values at the
black points, and then use the lattice of white points as a new lattice, on
which we perform the two operations in the building block. Notice that the
white points in Fig. 6.10 constitute a square lattice, which is rotated 45°
relative to the original integer lattice, and with a distance of v'2 between
nearest neighbors. This procedure is an 'in place' algorithm, since we work
on just one matrix, successively computing new values and inserting them in
the original matrix.
The transform is inverted exactly as in Sect. 3.2, namely by reversing the
order of the operations and changing the signs.
Let us now make a specific choice of prediction and update procedures.
For a given black point, located at (m, n), we predict that the value at this
point should be the average of the nearest four neighbors. Thus we replace
x[m,n] by
x.[m,n] = x[m,n]
- 41 (x[m -1,n] + x[m + l,n] + x[m,n + 1] + x[m,n -1])
We decide to use an update procedure, which preserves the average value.
Thus the average of the computed values at the white points should equal
60 6. Two Dimensional Transforms
half of the average over all the initial values. The factor one half comes from
the fact that there are half as many white values as there are values in the
original image. A simple computation shows that one can obtain this property
by the following choice of update procedure
xo[m,n] = x[m,n]
1
+ 8 (x.[m - 1, n] + x.[m + 1, n] + x.[m, n + 1] + x.[m, n - 1])
The discrete wavelet transform, defined this way, has the property that it
does not exhibit the pronounced directional effects of the one defined in the
first section. In the literature the lattice in Fig. 6.10 is called the quincunx
lattice. It is possible to use other lattices, for example a hexagonal lattice,
and other procedures for prediction and update.
Exercises
These exercises assume that the reader is familiar with the Uvi_ Wave toolbox,
as for example explained in Chap. 13
6.1 Go through the details of the examples in this section, using the
Uvi_ Wave toolbox in MATLAB.
6.2 Select some other images and perform computer experiments similar to
those above.
6.3 (Difficult.) After you have read Chap. 11, try to implement the nonsep-
arable two dimensional wavelet transform described above. Experiment with
it and compare with some of the applications of the separable one based on
the Haar building block, in particular with respect to directional effects.
7. Lifting and Filters I
Our discussion of the discrete wavelet transform has to this point been based
on the time domain alone. We have represented and treated signals as se-
quences of sample points x = {x[n]}nEZ. The index n E Z represents equidis-
tant sampling times, given a choice of time scale. But we will get a better
understanding of the transform, if we also look at it in the frequency domain.
The frequency representation is obtained from the time domain representa-
tion using the Fourier transform. We will refer to standard texts [22, 23] for
the necessary background, but we recall some of the definitions and results
below.
In the previous chapters we have introduced the discrete wavelet trans-
form using the lifting technique. In the literature, for example [5], the dis-
crete wavelet transform is defined using filters. In this chapter we establish
the connection between the definition using filters, and the lifting definition.
We establish the connection both in the time domain, and in the frequency
domain. Further results on the connection between filters and lifting are given
in Chap. 12.
We note that in this chapter we only discuss the properties of a one scale
discrete wavelet transform, as described in Chap. 3. We look at the properties
of multiresolution transforms in Chap. 9.
Some of the results in this chapter are rather technical, but they are
needed in the sequel for a complete discussion of the DWT. Consequently, in
the following chapters we will often refer back to results obtained here. Note
that it is possible to read the following chapters without having absorbed all
the details in this chapter. One can return to this chapter, when the results
are needed.
We first recall some standard results from signal analysis. A finite energy
signal x = {x[n]}nEZ E e2(Z) has an associated Fourier series,
The function X(e jW ), given by the sum of this series, is periodic with pe-
riod 2rr, as a function of the frequency variable w. We denote the imaginary
unit by j, Le. j2 = -1, as is customary in the engineering literature. We also
adopt the custom that the upper case letter X denotes the representation of
the sequence x in the frequency domain.
For each x E f2(Z) we have the following result, which is called Parseval's
equation,
(7.2)
This means that the energy of the signal can be computed in the frequency
representation via this formula.
Conversely, given a 2rr-periodic function X(e jW ), which satisfies
(7.3)
then we can find a sequence x E f2(Z), such that (7.1) holds, by using
x[n) = 2-1
2rr 0
2
11" X(ejW)ejnwdw . (7.4)
-1
2rr
1
0
2
11"
e -jmw e jnwdw -_ {a if m ::J n ,
1 if m = n .
(7.5)
We note that there are technical details concerning the type of convergence
for the series (7.1) (convergence in mean), which we have decided to omit
here.
The z-transform is obtained from the Fourier representation (7.1) by sub-
stituting z for ejw . Thus the z-transform of the sequence x is defined as
The z-transform defined by (7.6) is linear. This means that the z-transform
of w = ax + f3y is W(z) = aX(z) + f3Y(z), where a and f3 are complex
numbers.
Another property of the z-transform is that it transforms convolution of
sequences into multiplication of the corresponding z-transforms. Let x and
y be two sequences from £2(Z). The convolution of x and y is the sequence
w = x * y, defined by
=L L x[n - klz-(n-k)y[klz-k
n k
=L X(z)y[klz-k = X(z)Y(z) .
k
Analogously, let Xright = {x[n - I]} denote the signal shifted one time unit
to the right. Then
Two other operations needed below are down sampling and up sampling by
two. Given a sequence x, then this sequence down sampled by two, denoted
by X2-/., is defined in the time domain by
Described in words, this means that we delete the odd indexed entries in the
given sequence, and then change the indexing. In the z-transform represen-
tation we find the following result (note that in the second sum the terms
with k odd cancel),
Given a sequence y, the up sampling operation yields the sequence Y2t, ob-
tained in the time domain by
0 if n is odd ,
Y2t []
n = { y[n/2] if n is even.
(7.14)
This means that we interlace zeroes between the given samples, and then
change the indexing. In the z-transform representation we find, after a change
of summation variable from n to k = n/2,
We are now ready to show how to implement the one scale DWT, defined via
the lifting technique, in the z-transform representation. The first step was
7.2 Lifting in the z-Transform Representation 65
to split a given signal into its even and odd components. In the z-transform
representation this splitting is obtained by writing
where
X(z)
Fig. 7.2. Reconstructing the signal from even and odd components
relative location of the even entries. For example, in the CDF(2,2) transform
the first step in (3.13) can be implemented as X1(z) - T(z)Xo(z), where
T(z) = ~(1 + z). (Recall that T(z)Xo(z) means the convolution t * Xo in
the time domain, which is exactly a linear combination of the even entries
with weights t[n].) Let us verify this result. First we multiply, using the
definition (7.17), and then we change the summation variable in the second
sum, to get
+ z) L x[2n]z-n
1
T(z)Xo(z) = "2 (1
n
= "2 L
1
x[2n]z-n + "2
1
L x[2n]z-n+l
n n
= L 1
"2 (x[2n] + x[2n + 2])z-n .
n
Thus we have
X1(z) - T(z)Xo(z) =L (x[2n + 1] - ~(x[2n] + x[2n + 2])) z-n,
n
Xo(z) ] [ [Xo(Z)]
[X1(z) - T(z)Xo(z) - -T(z) 1 X1(z)'
1 0]
An entirely analogous computation (see Exer. 7.2) shows that if we define
S(z) = HI + Z-l), then the update step in (3.14) is implemented in the
z-transform representation as multiplication by the matrix
1 S(Z)]
[o 1 .
°
where K > is a constant. Note that this particular form depends on an
overall normalization of the transform, as explained in connection with The-
orem 7.3.1.
It is a rather surprising fact that the same simple structure of the lifting
steps used above applies to the general case. In the general case a prediction
step is always given by multiplication by a matrix of the form
Here T(z) and S(z) are both polynomials in z and z-l. Such polynomials
are called Laurent polynomials.
The general one scale DWT described in Chap. 3, with the normalization
step included, is then in the z-transform representation given as a matrix
product (see also Fig. 3.5)
H(z) ° ][10
= [Ko K- 1 SN(Z)] [
1
1
-TN(z) 1
0] ... [1°SI(Z)]
1
[ 1 0].
-T1(z) 1
(7.21)
The order of the factors is determined by the order in which we apply the
various steps. First a prediction step, then an update step, perhaps repeated
N times, and then finally the normalization step. Note that matrix multipli-
cation is non-commutative, i.e. U(z)P(z) =j; P(z)U(z) in general.
An important property of the DWT implemented via lifting steps was the
invertibility of the transform, as illustrated for example in Fig. 3.4. It is easy
to verify that we have
P( z ) - 1 = [1 0]
T(z) 1 an
d U( )-1 _
z -
[1°-S(z)]
1 . (7.22)
Since
by the usual rules of matrix multiplication, we have that the matrix H(z) in
(7.21) is invertible, and its inverse, denoted by G(z), is given by
G(z) _ [ 1 0]
- T 1(z) 1
[1°-SI(Z)]
1
... [ 1 0] [1 -SN(Z)] [K- 0]
TN(Z) 1 0 10K'
1
(7.23)
68 7. Lifting and Filters I
X(z)
H(z)
Multiplying all the matrices in the product defining H(z) in (7.21), we get a
matrix with entries, which are Laurent polynomials. We use the notation
for such a general matrix. We can then represent the implementation of the
complete one scale DWT in the z-transform representation by the diagram
in Fig. 7.3. Written in matrix notation the DWT is given as
just like in ordinary linear algebra. This equation shows that the matrix H(z)
is invertible, if and only if d(z) is invertible. It also gives an explicit formula
for the inverse matrix.
7.3 Two Channel Filter Banks 69
are assumed to be FIR filters. Usually the filters with index 0 are chosen to
be low pass filters, and the filters with index 1 to be high pass filters. In the
usual terminology a low pass filter is a filter which is close to 1 for Iwl ::; 1r/2,
and close to 0 for 1r/2 ::; Iwl ::; 1r. Similarly a high pass filter is close to 1 for
1r/2::; Iwl ::; 1r, and close to 0 for Iwl ::; 1r/2. In our case the value 1 has to
be replaced by ..;2, due to the manner in which we have chosen to normalize
the transform. We keep this normalization to facilitate comparison with the
literature.
The analysis and synthesis parts of the filter bank are shown in Fig. 704.
For the moment we consider the filtering scheme in the z-transform repre-
sentation. Later we will also look at it in the time domain. The analysis
part transforms the input X(z) to the output pair Yo(z), Y1(z). The synthe-
sis part then transforms this pair to the output X(z). The filtering scheme
is said to have the perfect reconstruction property, if X(z) = X(z) for all
possible (finite energy) X(z).
X(z)
We first analyze which conditions are needed on the four filters, in order to
obtain the perfect reconstruction property. We perform this analysis in the
z-transform representation. Filtering by h o transforms X(z) to Ho(z)X(z),
and we then use (7.13) to down sample by two. Thus we have
(7.30)
Perfect reconstruction means that X(z) = X(z). We combine the above ex-
pressions and then regroup terms to get
7.3 Two Channel Filter Banks 71
The condition X(z) = X(z) will then follow from the conditions
The converse obviously also holds. These conditions mean that the four filters
cannot be chosen independently, if we want to have perfect reconstruction.
Let us analyze the consequences of (7.31) and (7.32). We write them in
matrix form
In order to solve this equation with respect to Go(z) and G1(z) we need
the matrix to be invertible. Let us denote its determinant by d(z). Since
we assume that all filters are FIR filters, d(z) is a Laurent polynomial. To
be invertible, it has to be a monomial, as shown in Proposition 7.2.1. This
determinant satisfies d( -z) = -d(z), as the following computations show.
This means that the monomial d(z) has to be an odd integer power of z, so
we can write it as
(7.34)
for some integer k and some nonzero constant c. Using Cramer's rule to solve
(7.33) we get
2 Hl(Z) I
o H1(-z)
Go(z) = 1
d(z) = cz 2k+1H1
(-z), (7.35)
Ho(z) 21
G (z) = I d(z)
Ho(-z) 0
1
= _cz 2k+1Iio
(-z)· (7.36)
These equations show that we can choose either the H -filter pair or the G-
filter pair. We will assume that we have filters H o and H 1 , subject to the
condition that
72 7. Lifting and Filters I
(7.37)
for some integer k and nonzero constant c. Then Go and G I are determined
by the equations (7.35) and (7.36), which means that they are unique up to
a scaling factor and an odd shift in time.
In the usual definition of the DWT the starting point is a two channel
filter bank with the perfect reconstruction property. The analysis part is then
used to define the direct one scale DWT (the building block from Sect. 3.2),
and the synthesis part is used for reconstruction.
It is an important result that the filtering approach, and the one based on
lifting, actually are identical. This means that they are just two different ways
of describing the same transformation from X(z) to Yo(z), YI(z). We will now
start explaining this equivalence. Part of the explanation, in particular the
proof of the equivalence, will be postponed to Chap. 12.
The first step is to show that the analysis step in Fig. 7.4 is equivalent
to the analysis step summarized in Fig. 7.3 and in (7.25). Thus we want to
find the equations relating the coefficients in the matrix (7.24) and the filters.
The analysis step by both methods should yield the same result. To avoid
the square root terms we compare the results after up sampling by two. We
start with the equality
YO(Z2)] _ H( 2) [~(X(z) + X( -Z))]
[Y I (Z2) - z ~(X(z)-X(-z))'
where Yo and YI are obtained from the filter bank approach, see (7.28) and
(7.29), and the right hand side from the lifting approach (in the polyphase
form), with H from (7.24). We have also inserted the (up sampled) expressions
(7.19) and (7.20) on the right hand side. The first equation can then be
written as
1
"2 (Ho(z)X(z) + Ho(-z)X(-z)) =
HOO(Z2)~ (X(z) + X( -z)) + HOI (Z2)~ (X(z) - X( -z)) .
This leads to the relation
Ho(z) = HOO (Z2) + zHOI (z2) .
Note the similarity to (7.16). The relation for HI is found analogously, and
then the relations for Go and G I can be found using the perfect reconstruction
conditions (7.35) and (7.36) in the two cases. The relations are summarized
here.
Ho(z)= HOO (z2) + zH01 (z2) , (7.38)
Hdz) = H lO (Z2) + zHl1 (Z2) , (7.39)
I
Go(z) = GOO (Z2) + Z- GOI (z2) , (7.40)
GI(z) = G lO (z2) + Z- IG l1 (z2) . (7.41)
7.3 Two Channel Filter Banks 73
Note the difference in the decomposition of the H-filters and the G-filters.
Thus in the polyphase representation we use
H( ) _ [K
z - ° °]°
K-1
[1 SN(Z)] [ 1
1 -TN(z) 1 1 °
0] ... [1 Sl(Z)] [ 1 0]
-T1(z) 1 .
The proof of this theorem is constructive. It gives an algorithm for finding the
Laurent polynomials Sl (z), . .. ,SN(Z), T 1(z), . .. ,TN(z) in the factorization.
It is important to note that the factorization is not unique. Once we have a
factorization, we can translate it into lifting steps. We will give some examples
of this, together with a detailed proof of the theorem, in Chap. 12.
The advantage of the lifting approach, compared to the filter approach,
is that it is very easy to find perfect reconstruction filters Ho, H 1, Go, and
G 1 . It is just a matter of multiplying the lifting steps as in (7.21), and then
assemble the filters according to the equations (7.38)-(7.41). In Sect. 7.8 we
give some examples.
This approach should be contrasted with the traditional signal analysis
approach, where one tries to find (approximate numerical) solutions to the
equations (7.31) and (7.32), using for example spectral factorization. The
weakness in constructing a transform based solely on the lifting technique is
that it is based entirely on considerations in the time domain. Sometimes it
is desirable to design filters with certain properties in the frequency domain,
74 7. Lifting and Filters I
and once filters have been constructed in the frequency domain, we can use
the constructive proof of the theorem to derive a lifting implementation, as
explained in detail in Chap. 12. Another weakness of the lifting approach
should be mentioned. The numerical stability of transforms defined using
lifting can be difficult to analyze. We will give some further remarks on this
problem in Sect. 14.2.
The two channel filter banks with perfect reconstruction discussed in the pre-
vious section can also be implemented in the time domain using convolution
by filters. (Actually, this is the way the DWT is implemented in the Uvi_ Wave
toolbox (see Chap. 11), and in most other wavelet software packages.) This
leads to an interpretation in terms of biorthogonal or orthonormal bases in
f2(Z). In this section we define these bases and give a few results on them.
In f2(Z) one defines an inner product for any x,y E f2(Z) by
8[n] = {1o if n =
ifniO.
0, (7.45)
(7.46)
which gives the following expression for the norm squared (the energy in the
signal)
This means that the vector en has a one as the n'th entry and zeroes ev-
erywhere else. It is an exercise to verify that this definition actually gives an
orthonormal basis, see Exer. 7.5.
Sometimes the requirements in the definition of the orthonormal basis are
too restrictive for a particular purpose. In this case biorthogonal bases can
often be used instead. They are defined as follows. Two sequences f n , nEZ,
and fm, m E Z, are said to constitute a biorthogonal pair of bases for f2(Z),
if the following properties are satisfied.
(7.52)
n n
(7.54)
Now for n odd the two terms cancel, and for n even they are equal. Thus we
find, replacing n by 2n (note that c5[2n] = c5[n] by the definition),
We use (7.54) once more in (7.31), this time with z replaced by -z, to get
the second equation
(7.57)
We can translate this equation into the time domain as above. The result is
and
Thus we have shown that the perfect reconstruction property of the filter bank
leads to the four equations (7.56), (7.58), (7.60), and (7.62). It turns out that
these four equations have a natural interpretation as the first biorthogonality
condition in the definition of a biorthogonal basis pair in £2(Z). This can be
seen in the following way. We define the sequences of vectors {fi } and {i\}
by
for all n E Z. Since we assume that the four filters are FIR filters, these
vectors all belong to £2(Z). The four relations above then lead to the following
properties of these vectors, where we also use the definition of the inner
product and the assumption of real filter coefficients.
This is seen as follows. There are four cases to consider. Assume for example
that both i and i ' are even. Then we have, using a change of variables,
=L go[k']ho[2(n - m) - k']
k'
=6[n-m].
The remaining three cases are obtained by similar computations, see Exer. 7.6.
One may ask whether the stability condition (7.49) also follows from the
perfect reconstruction property. Unfortunately, this is not the case. This is
one of the deeper mathematical results that we cannot cover in this book. A
substantial background in Fourier analysis and functional analysis is needed
to properly understand this question. We refer to the books [4, 5] for readers
with the necessary mathematical background.
Now we will use the above results to define an important class of filters.
We say that a set of four filters with the perfect reconstruction property are
orthogonal filters, if the associated basis vectors constitute an orthonormal
basis. By the above results and definitions this means that we must have
7.7 Properties of Orthogonal Filters 79
fn = f n for all nEZ, or, translating this condition back to the filters using
(7.63) and (7.64), that
(7.66)
for all k E Z.
Finally, let us note that if we start with a biorthogonal basis pair with the
special structure imposed in (7.63) and (7.64), or with four filters satisfying
the four equations (7.56), (7.58), (7.60), and (7.62), then we can reverse
the arguments and show that the corresponding z-transforms Ho(z), H 1(z),
Go(z), and G1(z) satisfy (7.31) and (7.32). The details are left as Exer. 7.7.
We now briefly summarize the above results. We have four different ap-
proaches to a building block for the DWT. They are
1. The building block is defined using lifting steps, and a final normalization
step.
2. The building block is based on a 2 x 2 matrix (7.24), whose entries are
Laurent polynomials, and on the scheme described in Fig. 7.3. The matrix
is assumed to be invertible. This is the polyphase representation.
3. The building block is based on a two channel filter bank with the per-
fect reconstruction property, as in Fig. 7.4. The perfect reconstruction
property can be specified in two different manners.
a) The conditions (7.31) and (7.32) are imposed on the z-transforms of
the filters, together with the determinant condition (7.37).
b) The four filters satisfy the four equations (7.56), (7.58), (7.60), and
(7.62) in the time domain.
4. Four filters are specified in the time domain, the vectors fn, fn, are
defined as in (7.63) and (7.64), and it is required that they satisfy the
biorthogonality condition.
The results in the previous sections show that all four approaches are equiv-
alent, and we have also established formulas for translating between the dif-
ferent approaches. Part of the details were postponed to Chap. 12, namely
the only not-so-easy translation: From filters to lifting steps.
(7.35) and (7.36). We assume that the given filter is h o. To avoid the trivial
case we also assume that its length L is at least 2.
Proposition 7.7.1. Let h o, hI, go, and gi be four FIR jilters dejining a
two channel jilter bank with the perfect reconstruction property. Assume that
the jilters are orthogonal, i.e. they satisfy (7.66), and that they have real
coefficients. Then the following results hold.
1. The length of h o is even, L = 2K.
2. We can specify HI by
(7.67)
If the nonzero entries in h o are h o[I], ... ,ho[2K], then (7.67) shows that
the nonzero entries in hI are given by
We will now establish these five properties. Using the orthogonality condition
(7.66) and the result (7.56), we find after changing the summation variable
to - k the result
with ho[O] ::J 0 and ho[2N] ::J O. Using (7.71) with n = N ::J 0 (since we
have excluded the trivial case L = 1) we find ho[0]h o[2N] = 0, which is a
contradiction.
Concerning the second result, then the assumption go[k] = ho[-k] implies
Go(z) = HO(Z-I). Using (7.35) for -z we then find
(7.72)
If we now take z = eiw , and use that all coefficients are real, we see that the
third result follows from this equation and (7.67).
Taking z = 1 in (7.72) yields the fourth result, up to a global choice of
signs. We have chosen the plus sign.
The energy conservation property in (7.70) is much more complicated to
establish. We recommend the reader to skip the remainder of this section on
a first reading.
We use the orthogonality assumption to derive the equation
Taking z = eiw and using that the complex conjugate then is z-l, we get
from (7.72), (7.73), and (7.74) that for each wE R the matrix
is a unitary matrix, since the three equations show that for a fixed w E R
the two rows have norm 1 (we include the 1/.../2 factor for this purpose) and
are orthogonal, as vectors in C 2 .
The next step is to note that this matrix allows us to write the equations
(7.28) and (7.29) as follows, again with z = eiw ,
iW
h X (e iw / 2) ]
Yo(e )] _ U( iW/2) [
[Y1(eiw) - e h X (ei (w/2+1r))'
Note how we have distributed the factor 1/2 in (7.28) and (7.29) over the two
terms. The unitarity of U(e iw / 2) for each w means that this transformation
preserves the norm in C 2 . Thus we have
for all wE R.
The last step consists in using Parseval's equation (7.2), then (7.75), and a
change in integration variable from w/2 to w, and finally Parseval's equation
once more.
82 7. Lifting and Filters I
4~ 1
21r
jW
= (IX(e / 2W + IX(e j (W/2+ 1r )W) dw
= 2~ 1 1r
j
(IX(ejWW + IX(e (W+1r)W) dw
=~
27r Jo
r21r IX(ejwWdw
= Ilx11 2 .
This computation concludes the proof of the proposition.
Let us now apply the above results to some of the previously considered trans-
forms. We start as usual with the Haar transform. It is given by (3.28)-(3.31).
In the notation introduced here (compare with the example in Sect. 7.2) we
get
H(z) = [_ ~ ~] .
V2V2
Using (7.38) and (7.39) we get
1
Ho(z) = J2(1 + z) ,
1
H1(z) = J2(-I+z) ,
and then in the frequency variable (on the unit circle in the complex plane)
1.5 r - - - - , - - - - , - - - . . . . - - - , - - - - - , - - - - , - - - ,
0.5
O~---L---'----'----JL....-----'--_~
o 0.5 1.5 2 2.5 3
Fig. 1.5. Plot of IHo(ejW)1 and IH1 (e jW )1 for the Haar transform
of plots. We will now make the same computations for the Daubechies 4
transform. It is given by lifting steps in (3.18)-(3.22). Written in matrix
notation we have
H(z) = ~
0 [ 0 ] [1
v'3"Jf 0 1
-z] [-:I} - 1 !%-2 Z -I
0] [1 v'3l
1 0 1 J.
Multiplying we find
Using the equations (7.38) and (7.39) we get the Daubechies 4 filters
where
Note that while obtaining the filter taps from the lifting steps is easy, since
it is just a matter of matrix multiplications, it is by no means trivial to go
the other way. This is described in details in Chap. 12.
The absolute values of Ho(e jW ) and H 1(e jW ) have been plotted in Fig. 7.6.
We note that these filters give a sharper cutoff than the Haar filters.
1.5 .-----,.------r--~----.----.----.,....,
0.5
_
____J'__
OL..-.oo~_l_ _ _ _ _ _ J ' - - _ - - - '_ _____I.
_ __ " " _ . J
Fig. 1.6. Plot of IHo(eiw)1 and IH1(eiw)1 for the Daubechies 4 transform
3=~~
1 -14V2z
1 -1 2V21+ :V21z -1] .
H(z) =
[2V2
2V2 2V2 z V2
As above we compute
1 2 1 31 1
Ho(z) = ---z + - z + - + - z -1 - --z- 2
4V2 2V2 2V2 2V2 4V2 '
1 2
H 1(z) = - - z + - z - -1 .
1
2V2 V2 2V2
7.8 Some Examples 85
1.6 r----r-~=-=--.-------,r---------r---~
1.4
1.2
0.8
0.6
0.4
0.2
0
0 0.5 1.5 2 2.5 3
Fig. 7.7. Plot of IHo(ejW)1 and IH1(ejW)1 for the CDF(2,2) transform
The graphs are plotted in Fig. 7.7. The unusual frequency response is due to
the fact that these filters are not orthogonal.
Let us finally comment on available filters. There is a family of filters
constructed by I. Daubechies, which we refer to as the Daubechies filters and
also the Daubechies transform, when we think of the associated DWT. The
Haar filters and the Daubechies 4 transform discussed above are the first two
members of the family. The filters are often indexed by their length, which
is an even integer. All filters in the family are orthogonal. As the length
increases they (slowly) converge to ideal low pass and high pass filters.
Another family consists of the so-called symlets. They were also first con-
structed by I. Daubechies. These filters are orthogonal and are also indexed
by their length. They are less asymmetrical than the first family, with regard
to phase response.
A third family of orthogonal filters with nice properties is the Coiflets.
They are described in [5], where one also finds tables of filter coefficients.
We have already encountered some families of biorthogonal filters. They
come from the CDF-families described in Sect. 3.6, and in the notation
CDF(N,M) the integers Nand M denote the multiplicity of the zero at
z = -1 for the z-transforms Ho(z) and Go(z), respectively. We say that
Ho(z) has a zero of multiplicity N at z = -1, if there exists a Laurent
polynomial Ho(z) with Ho( -1) ¥- 0, such that Ho(z) = (z + l)N Ho(z).
The various toolboxes have functions for generating filter coefficients. We
will discuss those in Uvi_ Wave in some detail later.
86 7. Lifting and Filters I
Exercises
7.1 Carry out explicitly the change of summation variable, which proves
(7.9) in the time domain.
7.2 Verify that the update step in the CDF(2,2) transform example in
Sect. 7.2 is given by S(z) = ~(1 + Z-I).
7.3 Let h be a filter. Show that filtering by h preserves the finite energy
property, i.e. Ilh * xii::; cllxll for all x E £2(Z), by using the z-transform and
Parseval's equation.
7.4 Verify that in the polyphase representation from Sect. 7.2 the invertibil-
ity of the matrix (7.24) is equivalent with the perfect reconstruction property
in the two channel filter bank case.
7.5 Verify that the canonical basis defined in (7.48) satisfies all the require-
ments for an orthonormal basis for £2 (Z).
7.6 Carry out the remaining three cases in the verification of (7.65).
7.7 Let four filters h o , hI, go, and gl satisfy the equations (7.56), (7.58),
(7.60), and (7.62). Show that their z-transforms satisfy (7.31) and (7.32).
7.8 Go through the details in establishing the formulas (7.51), (7.52), and
(7.53). Try also to obtain these formulas from the polyphase formulation of
the filter bank.
7.9 Verify that (7.67) leads to (7.68).
7.10 Show that (7.53) is valid if and only if
and then show that this is true for all wavelet filters.
7.11 Carry out computations similar to those in Sect. 7.8 for the CDF(3,1)
transform defined in Sect. 3.6.
8. Wavelet Packets
Fig. 8.1. Block diagram for building block and its inverse, with signal elements
shown
Three consecutive transforms will look like Fig. 8.2(a). The dotted boxes show
the signal parts transferred without transformation from one application of
the building block to the next. Other examples are in Fig. 3.7, and in Table 2.1
and 3.1, which show the same with numbers and symbols. Note that the
orientation and location of the transformed components are different here
and in the examples mentioned.
Any collection of consecutive transforms of a given signal is called a de-
composition of this signal. We use the following terminology. The original
signal is said to be at the first level. Applying the transform once gets us to
the second level. Thus in the wavelet transform case the k scale transform
leads to a decomposition with k + 1 levels.
Note that the original signal always is the top level in a decomposition.
Depending on how we draw the diagrams, the top level is on the left, or on
the top of the diagram. Note that the placement of the s and d parts of each
transform step agrees with the diagram in Fig. 3.7.
1 2 3 4 1 2 3 4
I
I
I
I I
r ~
I I I
I I I
I I I
I I I
I I I
I I I
I I I
I I I
I I I
- " -"
(a) (b)
Fig. 8.2. The wavelet (a) and the full wavelet packet (b) decompositions of a signal
When looking at Fig. 8.2(a), one starts to wonder, why some signal parts
are transformed and other parts are not. One can apply the transform to all
parts, or, as we shall see soon, to selected parts. This idea is called wavelet
packets, and a full wavelet packet decomposition over four levels is shown in
Fig. 8.2(b). Note that in this case we have applied the transform T a 7 times.
The standard abbreviation WP will be used in the rest of the text. Each
signal part box in Fig. 8.2 is called an element. Note that this word might
also be used, when it is clear from the context, to denote a single number or
coefficient in a signal.
8.1 From Wavelets to Wavelet Packets 89
such that
1. the selected elements cover the original signal, and
2. there is no overlap between the selected elements.
The first condition ensures sufficient information for reconstruction, while the
second one ensures that no unnecessary information is chosen. Both condi-
tions are needed. Since any representation is equivalent with a change of basis
(here we view the original signal as given in the canonical basis), a choice of
representation corresponds to a choice of basis (this is elaborated in Chap. 5).
We will, in agreement with most of the wavelet literature, often use the for-
mulation 'choice of basis.' But one should remember that a representation is
different from a basis.
An example of a representation (notice how the two conditions are ful-
filled) of the signal decomposed above is
I 48 16 48 28 ~ 8 -6 I·
90 8. Wavelet Packets
Decomposition Reconstruction
56 40 8 24 48 48 40 16
56 40 8 24 48 48 40 16
Fig. 8.3. Decomposition of the signal, and reconstruction from one particular rep-
resentation.
chosen basis is the best one, according to our criterion. If more than one basis
satisfies our criterion for best basis, the method should find one of them. We
present such an algorithm below, in Sect. 8.2.2.
: _-- .
The number of bases grows extremely fast, approximately doubling the num-
ber of digits needed to represent it, for each extra level. It is worth noting
that the number of bases does not depend directly on the length of the signal.
A signal of length 128 transformed 3 times, to make a decomposition with
4 levels, has only 26 different representations. The number of levels, we can
consider, is limited by the length of the signal, since the decomposition must
terminate, when an element contains just one number. The minimum length
required for a given level is shown in the second column of Table 8.2, in the
first few cases. In general, decomposition into J levels requires a signal of
length at least 2J - I .
We can find an upper and a lower bound for Aj • Take two other equations
Bj+I = BJ, BI =2 and Cj +! = ci, CI = 2.
Clearly B j ~ Aj ~ Cj for j > O. Both B j and Cj are easily found. For B j
we have
8.2 Choice of Basis 93
The concept of the best basis depends on the application we have in mind.
To use the concept in an algorithm, we introduce a cost function. A cost
function measures in some terms the cost of a given representation, with the
idea that the best basis is the one having the smallest cost.
To be usable in an algorithm, the cost function must have some specific
properties. We denote a cost function by the symbol K here. The cost function
is defined on finite vectors of arbitrary length. The value of the cost function
is a real number. Given two vectors of finite length, a and b, we denote
their concatenation by [a bJ. This vector simply consists of the elements in a
followed by the elements in b. We require the following two properties.
1. The cost function is additive in the sense that K([a b]) = K(a) + K(b)
for all finite length vectors a and b.
2. K(O) = 0, where 0 denotes the zero vector.
As an example, we take the cost function, which counts the number of nonzero
entries in a vector. For example,
to calculate the cost values of all elements of the full decomposition. Note
that these two computations are performed only once. Their complexity is
proportional to the length of the given signal multiplied by the number of
levels chosen in the full decomposition.
Given this full decomposition with the cost of each element computed,
the algorithm performs a bottom-up search in this tree. It can be described
as follows.
1. Mark all elements on the bottom level J.
2. Let j = J.
3. Let k = O.
4. Compare the cost value V1 of element k on level j - 1 (counting from the
left on that level) to the sum V2 of the cost values of the elements 2k and
2k + 1 on level j.
a) If V1 ~ V2, all marks below element k on level j - 1 are deleted, and
element k is marked.
b) If V1 > V2, the cost value V1 of element k is replaced with V2.
5. k = k + 1. If there are more elements on level j (if k < 2j - 1 - 1), go to
step 4.
6. j = j - 1. If j > 1, go to step 3.
7. The marked basis has the lowest possible cost value, which is the value
currently assigned to the top element.
The additivity ensures that the algorithm quickly finds a best basis, which
of course need not be unique. Note that once the first two steps (full decom-
position and computation of cost) have been performed, then the complexity
of the remaining computations only depends on the number of levels J being
used. The complexity of this part is found to be O(Jlog J).
The algorithm is most easily understood with the help of an example.
For that purpose we reuse the decomposition given in Table 8.1. First the
cost value of each element is calculated. The cost values are represented in
the same tree structure as the full decomposition. As cost function in this
example we choose the count of numbers with absolute value> 1. Calculated
cost values and the marking of the bottom level are both shown in Fig. 8.7(1).
We start with the bottom level, since the search starts here. We then move
up each time it is possible to reduce total cost by doing so. The additivity
makes partial replacement of elements possible. The remaining crucial step is
the comparison of cost values. All comparisons are between an element and
the two elements just below it. If the sum of the cost values in the two lower
elements (V2 in the algorithm) is smaller than the cost value in the upper
element (V1 in the algorithm), this sum is inserted as a new cost value in the
upper element. This possibility is illustrated in the top row of Fig. 8.6. If,
on the other hand, the sum is larger than (or equal to) the cost value in the
upper element, this element is marked and all marks below this element are
deleted. This possibility is illustrated in the bottom row of Fig. 8.6.
8.2 Choice of Basis 95
All elements on each level is run through, and the levels are taken from the
lowest but one and up. In Fig. 8.7 the process is shown in four steps. Notice
56 40 8 24 48 48 40 16
48 16 48 28 8 -8 0 12
32 38 I 16 10 0 6 I 8 -6
35 I -3 I 13 I 3 3 I -3 I 1 I 7
-
(3)
C f---r------4-..,--
c
(4) I--.-+--.-
Fig. 8.7. An example showing the best basis search. The cost function is the count
of numbers in each element with absolute value > 1
how the cost value in the top element is the cost value of the best basis at
the end of the search. The best representation of this signal has been found
to be
I 48 16 48 28 I 0 6 ITL:D.
In the left half of the decomposition the cost value is 4 in all of the 5 possible
choices of elements. This means that with respect to cost value 5 different
best bases exist in this decomposition. The algorithm always finds one of
96 8. Wavelet Packets
these. The equal sign in step 4(a) has as a consequence that the best basis
with fewest transform steps is picked. Below we will use the term 'best basis'
for the one selected by this algorithm.
If we had chosen the cost function to be the count of numbers with ab-
solute value > 3, the best basis would have been the eight elements on the
bottom level, with a total cost value of only 3.
One particular type of best basis is the best level basis, where the chosen
basis consists solely of elements from one level. The number of best level
bases is equal to the number of levels. This type of basis is often used in
time-frequency planes.
In Sect. 11.8 it is shown how to implement the best basis algorithm in
MATLAB.
8.3.1 Threshold
One of the simplest cost functions is the threshold, which simply returns
the count of numbers above a specified threshold. Usually the sign of each
number is of no interest, and the count is therefore of numbers with absolute
value above the threshold. This was the cost function used in the example in
the previous section.
In the context of a cost function given by a threshold, 'large' means above
the given threshold, and 'small' below the threshold. Low cost then means
that the basis represents the signal with as few large values as possible. In
many cases the large values are the significant values. This is often the case,
when one uses the wavelet transform.
But there are certain pitfalls in this argument. The following situation
can easily arise. A signal with values in the range -1 to 1 is transformed into
two signal each with values in the range -2 to 2. One more transform would
make the range -4 to 4, and so on. It is apparent from the plots in Fig. 7.5,
7.6, and 7.7 that the one level wavelet transform has a gain above 1. But this
does not mean that we gain information just by transforming the signal. The
increase in the range of values is due to the normalization of the one level
DWT, which in the orthogonal case means that we have energy preserved
during each step in the decomposition.
8.3 Cost Functions 97
Let us give an example. Take the vector a = [1 1 1 1 1 1 1 1]. Then Iiall = VS.
Let b denote its transform under an energy preserving transformation, such
that IIbll = VS. Assume now that the transform has doubled the range of the
signal. This means that at least one of the entries has to be ±2. Thus one
could find for example b = [22000000]. Since energy is preserved, at most
two samples can have absolute value equal to 2. So the overall effect is that
most of the entries actually decrease in amplitude. This effect explains, at
least partially, why the wavelet transform is so useful in signal compression,
and in other applications.
The threshold is a very simple cost function. To satisfy the additivity
property the threshold has to be the same for all levels. Furthermore, an
inappropriate choice of threshold value can lead to a futile basis search. If
the threshold is chosen too high, then all cost values will be zero, and the
basis search returns the original signal. The same is the case, if the threshold
is too low.
The problem with the threshold cost function just mentioned leads one to
look for cost functions with better properties. In this section we describe
two possibilities. The first one is the so-called fP-norm. The second one is
a modified version of Shannon's entropy. Both have turned out to be very
useful in applications. The two cost functions are defined as follows.
Definition 8.3.1. For 0 < p < 00 the cost function based on the fP-norm is
given by
(8.1)
n
for all vectors a of finite length. Here we use the convention 0 10g(0) = O.
98 8. Wavelet Packets
Let us note that this cost function is not the entropy function, but a modified
one. The original entropy function is for a signal a computed as
This function fails to satisfy the additivity condition due to the division by
lIall. But the cost function defined here has the property that its value is
minimized, if and only the original entropy function is minimized.
Let us show that the cost function KShannon measures concentration in
a signal by an example. Let IN denote the vector of length N, all of whose
entries equal 1. Let SN = (E/N)1/2IN, Le. all entries equal (E/N)1/2. The
energy in this signal is equal to E, independent of N, while KShannon(SN) =
- E log( E / N). For a fixed E this function is essentially log( N). This shows
that the entropy increases, if we distribute the energy in the signal evenly
over an increasing number of entries. More generally, one can prove that for
signals with fixed energy, the entropy attains a maximum, when all entries
are equal, and a minimum, when all but one entry equal zero.
In Sect. 11.9 the implementation of the different cost functions is pre-
sented, and in Chap. 13 some examples of applications are given.
Exercises
8.1 Verify that the threshold cost function satisfies the two requirements for
a cost function.
8.2 Verify that the cost function KiP satisfies the two requirements for a cost
function.
8.3 Verify that the cost function KShannon satisfies the two requirements for
a cost function.
8.4 Let a = [a[O] all]] and b = [b[O] b[l]] be two nonzero vectors of length
2 with nonnegative entries. Assume that K i 2(a) = K i 2(b), but Kit(a) <
Kit (b). Assume that b[O] = b[l]. Show that either a[O] < all] or a[O] > all].
8.5 Assume that a full wavelet packet decomposition has been computed for
a given signal, using an energy preserving transform. Take as the cost function
K i 2. Go through the steps in the best basis search algorithm to verify that
the algorithm selects the original signal as the best basis.
8.6 Assume that a full wavelet packet decomposition has been computed
for a given signal. Assume that a threshold T is chosen, which is larger that
the largest absolute value of all elements in the decomposition. Choose the
threshold cost function with this threshold. Go through the steps in the best
basis search algorithm to verify that the algorithm selects the original signal
as the best basis.
9. The Time-Frequency Plane
See Chap. 7 for some results on Fourier series. The function X(w) is periodic
with period 27l', which means that X(w+27l'k) = X(w) for all k E Z. Therefore
the function is completely determined by its values on an interval of length
27l'. In this book we always take our signals to have real values. For a real
signal x we have X (w) = X (-w), as can be seen by taking the complex
conjugate of both sides in (9.1). As a consequence, the frequency contents is
determined by the values of X(w) on any interval of the form [hr, (k + 1)7l'],
where k can be any integer. Usually one chooses the interval [O,7l').
To interpret our signals we need to fix units. The discrete signal is indexed
by the integers. If we choose a time unit T, which we will measure in seconds,
then we can interpret the signal as one being measured at times nT, n E Z.
Let us assume that there is an underlying analog, or continuous, signal, such
that the discrete signal has been obtained by sampling this continuous signal
at times nT. The number 1IT is called the sampling rate, and Is = 271" IT the
sampling frequency. Note that some textbooks use Fourier series based on
the functions exp(-j271"nw). In those books the sampling frequency is often
defined to be liT.
H we now introduce the time unit explicitly in the Fourier series, then it
becomes
The function XT(W) is periodic with period 271" IT. After a change of variables,
Parseval's equation (7.2) reads
(9.3)
For a real discrete signal the frequency contents is then determined by the
values of XT(W) on for example the interval [0,71" IT]. This is often expressed
by saying that in a sampled signal one can only find frequencies up to half the
!
sampling frequency, Is, which is equal to 71" IT by our definition. This result
is part of Shannon's sampling theorem. See for example [5, 16, 22, 23, 28] for
a discussion of this theorem.
As mentioned above, for a real signal we can choose other intervals in
frequency, on which the values of XT(w) will determine the signal. Any in-
terval of the form [biT, (k + 1)7I"IT] can be chosen. This is not a viola-
tion of the sampling theorem, but simply a consequence of periodicity, and
the assumption that the signal is real. We have illustrated the possibilities
in Fig. 9.1. The usual choice is marked by the heavy line segment. Other
possibilities are marked by the thin line segments. Note how the symmetry
IXT(W)I = IXT(-w)1 is also shown in the figure.
IXT(w)!
311" W
T
Fig. 9.1. Choice of frequency interval for a sampled signal. Heavy line marks usual
choice
For a real signal we have i(w) = x(-w), such that it suffices to consider pos-
itive frequencies. Any positive frequency may occur. Suppose now we sample
an analog signal at a rate liT. This means that we take x[n] = x(nT). Re-
call that we use square brackets for discrete variables and round brackets for
continuous variables. The connection between the frequency contents of the
sampled signal and that of the continuous one is given by the equation
XT(W) = T1 "L.. x A (
w- 2k7r) .
T (9.6)
kEZ
This is a standard result from signal analysis, and we refer to the litera-
ture for the proof, see for example [16, 22, 23, 28]. The result (9.6) shows
that the frequencies outside the interval [-7r IT, 7r IT] in the analog signal are
translated into this interval. This is the aliasing effect of sampling.
We see from (9.6) that the frequency contents of the sampled and the
analog real signal will agree, if the nonzero frequencies are in the interval
[-7r IT, 7r IT]. If the nonzero frequencies of the analog signal lie in another
interval of length 27r IT, then we can assign this interval as the frequency
interval of the sampled signal.
The aliasing effect is illustrated in Fig. 9.2. It is also known from everyday
life, for example when the wheels of a car turn slowly on a film, although the
car is traveling at high speed.
Fig. 9.2. A 7Hz and a 1 Hz signal sampled 8 times per second yield the same
(sampled) signal
102 9. The Time-Frequency Plane
11'
T ..-----,---.------.--...,
o
OT IT 2T 3T 4T
Fig. 9.3. Time-frequency plane for a discrete signal
Suppose now that we down sample the signal x by two. Then the sampling
rate is Ij2T, and we choose [0, 1l' j2T] as the frequency interval. Since we have
fixed the units, we get the visual representation shown in Fig. 9.4.
11'
2T 1------.------...,
OT IT 2T 3T 4T
Fig. 9.4. Time-frequency plane for a discrete signal. The signal from Fig. 9.3, down
sampled by two
We will now define the time-frequency planes used to visualize the DWT.
Let us go back to the first example in Chap. 2. We had eight samples, which
9.2 Definition of the Time-Frequency Plane 103
we transformed three times using the Haar transform. We first use symbols,
and then the numbers from the example. The original signal is represented
by eight vertical boxes, like the four vertical boxes in Fig. 9.3. We will take
T = 1 to simplify the following figures. The first application of the transform
is in symbols given as
, ,
, ,
,, ,,,
,, ,
, ,
Fig. 9.5. The wavelet transform using the filters h and g in the frequency domain
(1) 56 40 8 24 48 48 40 16
(2) 48 16 48 28 8 -8 0 12
(3) 32 38 I 16 10 8 -8 0 12
(4) 35 1-3116 10 8 -8 0 12
(1) 8 -8 0 12 (2)
6 8 fl8 'i0
II
'i 0 4 8 6
48 16 48 28
(3) 8 -8 0 12 8 -8 0 12 (4)
16 10 16 10
32 38 -3
35
representation. For a given signal the boxes can then be colored according to
energy contents in each box. This way it becomes easy visually to identify a
representation, where the transformed signal has few large coefficients.
The partition of the time-frequency plane associated with a chosen wavelet
packet representation can be constructed as above. A different way of obtain-
ing it is to turn the decomposition 90 degrees counterclockwise. The partition
then becomes easy to identify. An example with a signal of length 32, decom-
posed over J = 4 levels, is shown in Fig. 9.10.
In Fig. 9.11 we have shown four possible representations for a signal with
8 samples, and the associated partitions of the time-frequency plane.
One more thing concerning the time-frequency planes should be men-
tioned. The linear scale for energy used up to now is often not the relevant
one in applications. One should choose an appropriate grey scale for coloring
the cells. Often one uses the logarithm of the energy. Thus the appropriate
measure is often 20Iog10 (lsj[kJl) (units decibel (dB)), displayed using a linear
grey scale. In the following figures we have used a logarithmic scale, slightly
modified, to avoid that coefficients with values close to zero lead to a com-
pression of the linear grey scale used to display these values. Thus we use
9.3 Wavelet Packets and Frequency Contents 107
-
--
--f-----l_
Fig. 9.11. Four different choices of bases and the corresponding time-frequency
planes. Note that the figure is valid only for signals of length 8, since there are 8
cells
We will now take a closer look at the frequency contents in the time-
frequency visualization of a wavelet packet analysis, for example those
shown in Fig. 9.11. The periodicity of XT(W) and the symmetry property
IXT(W)I = IXT( -w)1 together imply that when we take for example the fre-
quency interval [1l'/T, 21l'/T] to determine XT(w), then the frequency contents
108 9. The Time-Frequency Plane
r 0 2 4 6 8 fu~
~" I, Iv
o 2 468Hz 0 2 468Hz
~~~~
cf P cf P0 (0) 2 (2) 4 (4) 0 (8) 2 (6) 4 (4)
~~~l2
o (0) 2 (2) 4 (4) 0 (0) 2 (2) 4 (4) 0 (8) 2 (6) 4 (4) 0 (8) 2 (6) 4 (4)
in this interval is the mirror image of the contents in [O,71"/T], see Fig. 9.l.
Thus we have to be careful in interpreting the frequency contents in a wavelet
packet analysis. In the first step from Sj to Sj-l, d j - 1 we have assigned the
interval [0, 7r j2T] to Sj-l and the interval [7r j2T, 7r jT] to d j - 1 , in our con-
struction of the time-frequency plane. In the wavelet analysis we only decom-
pose Sj-l in the next step. Here the frequency interval is the one we expect
when applying low pass and high pass filters. In the wavelet packet analy-
sis we apply the filters also to the part d j - 1 . When we apply filters to this
part, the frequency interval has to be [0, 7r j2T]. But the frequency contents in
this interval is the mirror image of the contents in [7r j2T, 7r jT], which means
that the low frequency and high frequency parts are reversed. Two steps in
a wavelet packet decomposition are shown in Fig. 9.12.
It is important to understand the frequency ordering of the elements in a
wavelet packet analysis. A more extensive example is given in Fig. 9.13. We
°
have taken a 128 Hz signal, which has been sampled, such that the frequency
range is from Hz to 64 Hz. Three steps of the full wavelet packet decom-
position are shown, such that the figure shows a four level decomposition.
The elements at the bottom level have a frequency ordering 0, 1, 3, 2, 6,
I 0-64 I
°Hz 64 Hz
~ /G
I 0-32 0-32 II 32 - 64 32 - 0 I
°Hz 32 Hz 64 Hz 32 Hz
~ /G ~ /G
0-16 16 - 32 32 -16 16 - 0
o Hz
0-16 II
16 Hz 32 Hz
16 - 0 II
16 Hz 48 Hz
0-16 II
64 Hz 48 Hz
16 - 0
32 Hz
~ /G ~ /G ~ /G ~ /G
16 16
~
0-8
0
18 - 1 116 - 81
8-0
8 16
0-8 ~
8-0 ~
0-8 18 - 1 116 - 81
8-0
8 24 32 24 16 48 56 64 56 40 48 40 32
0-8 ~
8-0
0 1 3 2 6 7 5 4
000 001 011 010 110 111 101 100
Fig. 9.13. decomposition of a signal following the same principle as in Fig. 9.12.
The numbers in the cells shows the real frequency content before (in parentheses)
and after down sampling, while the numbers below the cells shows from which
frequency band the signal part originates. The last two lines show the frequency
order, in decimal and binary notation, respectively
110 9. The Time-Frequency Plane
(9.7)
The inverse can be found, again in binary representation, via the following
formula
The sum is actually finite, since for an integer n < 2N we have nk = a for all
k>N.
With these definitions we see that we get from the frequency ordering in
Fig. 9.13 to the natural (monotonically increasing) frequency order by using
the IGC map.
Once we have seen how the permutation arises in our scheme for finding
the wavelet packet decomposition, we can devise the following simple change
to the scheme to ensure that the elements appear in the natural frequency
order. Above we saw that after one step of the DWT, due to the down
sampling, the frequency contents in the high pass part appeared in reverse
order (see Fig. 9.12). Thus in the next application of the DWT to this part,
the low and high frequency parts appear in reverse order, see again Fig. 9.12.
This means that to get the elements in the natural frequency order, we have
to interchange the position of the low and high frequency filtered parts in
every other application of the DWT step. This method is demonstrated in
Fig. 9.14. Look carefully at the figure, notice where the Hand G filters are
applied, and compare in detail with Fig. 9.13.
Thus we have two possible ways to order the frequency contents in the
elements of a full wavelet packet decomposition of a given signal. Using the
original scheme we get the ordering as shown in Fig. 9.13. It is called filter
bank ordering. The other ordering is called natural frequency ordering. Some-
times it is important to get the frequency ordering right. In particular, if one
wants to interpret the time-frequency plane, then this is important. In other
cases, for example in applications to denoising and compression, the ordering
is of no importance.
9.4 More about Time-Frequency Planes 111
0-64
~ /G
0-32 II 64- 32
~ /G /G ~
0-16 II 32 -16 II 32 -48 II 64-48
~/G/G~~/G/G~
~ 116-81 ~ ~4-321 ~ ~8-401 ~6-481 ~
o 1 2 3 4 5 6 7
Fig. 9.14. We get the natural frequency order by swapping every other application
of the DWT. Compare this figure with Fig. 9.13
Before we explain the effects in Fig. 9.15 we look at a simpler example. Let us
first explain why we choose a level basis in this figure. It is due to the uneven
112 9. The Time-Frequency Plane
Time Time
-
1)'
i ~1i"~I;;.I.I~"""I;;"PI.
l:
u..
Time Time
Fig. 9.16. A signal with three frequencies in the time-frequency plane. Left hand
plot shows the time-frequency plane for the wavelet decomposition, and the right
hand plot the level basis from a wavelet packet decomposition, both with J =
6frequency localization
~ ~
1 I ' ,i \.'
\
; i
2
: , 10-2L-··_·····_······--'-:/~ --'-\-----'
0.25 0.5 0.75 o 0.25 0.5 0.75
Normalized frequency Normalized frequency
Time Time
Fig. 9.18. The left hand part is the time-frequency plane for the linear chirp from
Fig. 9.15, which is based on Daubechies 4. The same plot, based on Daubechies 12,
is shown in the right hand part
find the frequency response of the corresponding eight bandpass filters. They
are plotted in Fig. 9.19
Let us also illustrate the reflection of the line in a linear chirp due to
undersampling. If we increase the frequency range beyond the maximum given
by the sampling frequency, then we get a reflection as shown in Fig. 9.20.
This figure is based on Daubechies 12 filters.
3r---;::--------,-"..------------------,
2.5
1.5
0.5
;l~
o A I;[]r ;[].
o O;~
2
300·,'"
1
o
I
.
. !
! i
: :[].iill 3D:·,,:"
~ b.
o 0.5 1 o 0.5 1 0 0.5 1 o 0.5 1
3 r---"..-"..------.
2 2 ;
1 ,
1 '.
o 0: ; o
0.5 o 0.5 0 0.5 1 o 0.5 1
Fig. 9.19. The eight bandpass filters corresponding to the fourth level in a decom-
position based on CDF(4,6). The top part shows the eight plots together, and the
bottom part shows the individual responses. The ideal filter response is shaded on
each of these figures
domain the filter acts by convolution. Suppose that h = [h[l], h[2], ... ,h[NJ]
is a filter of length N. Then filtering the signal x yields
N
(h * x)[n] =L h[k]x[n - k] . (9.10)
k=l
Thus the computed value at n only depends on the preceding samples x[n-
1], ... ,x[n-N].
Let us illustrate the time localization properties of the wavelet decomposi-
tion and the best level decomposition, both with J = 6, Le. five applications
of the DWT. We use Daubechies 4 again, and take the following signal of
length 1024.
25 if n = 300 ,
x[n] = 1 if 500 ~ n ~ 700 , (9.11)
{ 15 if n = 900,
o otherwise .
116 9. The Time-Frequency Plane
Time
Fig. 9.20. This time-frequency plane shows the effect of undersampling a linear
chirp. Above the sampling rate the frequency contents is reflected into the lower
range. This plot uses Daubechies 12 as the DWT
The two time-frequency planes are shown in Fig. 9.21. We notice that the
wavelet transform is very good at localizing the singularities and the constant
part. The wavelet packet best level representation has much less resolution
with respect to time. The filter is so short (length 4) that the effects of the
filter length is not very strong. We see the expected broadening in the wavelet
transform of the contribution from the singularity, due to the repeated ap-
plications of the filters. You should compare this figure with Fig. 4.6.
Let us give one more illustration. This time we take the sum of the signals
used in Fig. 9.16 and Fig. 9.21. The two plots are shown in Fig. 9.22. Here we
can see that the wavelet packet best basis representation gives a reasonable
compromise between resolution in time and in frequency.
9.4.3 Alignment
In Fig. 9.23 we have plotted the impulse response (filter coefficients) of the
filters Daubechies 24 and Coifiet 24 (in the literature also called coif4), both
of length 24. The first column shows the IR of the low pass filters, and
the second column those of the high pass filters. We see that only a few
coefficients dominate. The Coifiet is much closer to being symmetric, which
is significant in applications, since it is better at preserving time localization.
Let us explain this is some detail.
It is evident from Fig. 9.23 that the large coefficients in the filters can be
located far from the middle of the filter. If we recall from Chap. 7 that with
9.4 More about Time-Frequency Planes 117
Time Time
Fig. 9.21. The left hand plot shows the time-frequency plane for the signal in
(9.11), decomposed using the wavelet transform, and the right hand plot the same
signal in a level basis decomposition, both with J = 6
Time Time
Fig. 9.22. The left hand plot shows the time-frequency plane for the signal in
(9.11) plus the one in (9.9), decomposed using the wavelet transform, and the right
hand plot the same signal in a level basis decomposition, both with J = 6
118 9. The Time-Frequency Plane
0.5 0.5
-0.5
5 10 15 20 5 10 15 20
0.5
-0.5 -0.5
5 10 15 20 5 10 15 20
Fig. 9.23. The first row shows the IR of the Daubechies 24 filters. The second row
shows the same plots for Coiflet 24. The left hand column shows the IR of the low
pass filters, the right hand one those of the high pass filters
orthogonal filters the high pass filter is obtained from the low pass filter by
reflection and alternation of the signs, see (7.68), then the center of the high
pass filter will be in the opposite end. This is also clear from Fig. 9.23.
For a filter h = [h[I], h[2], . .. ,h[N)) we can define its center in several
different ways. For a real number x we let LxJ denote the largest integer less
than or equal to x.
Maxima location The center is defined to be the first occurrence of the
absolute maximum of the filter coefficients. Formally this is defined by
C
mass
(h) =
L::=lklh[k] Ij.
lL::-l Ih[k]1
(9.13)
C
energy
(h) -lL::-l
- L::=lk1h[kWj
Ih[kJl2 .
(9.14)
As an example the values for the filters in Fig. 9.23 are shown in Table 9.1.
Suppose now that the signal x, which is being filtered by convolution by
hand g, only has a few large entries. Then these will be shifted in location by
9.4 More about Time-Frequency Planes 119
Daub24 h 21 19 20
Daub24 g 4 5 4
Coif24 h 16 15 15
Coif24 g 9 9 9
the filtering, and the shifts will differ in the low and high pass filtered parts.
In the full wavelet packet decomposition this leads to serious misalignment
of the various parts. Thus shifts have to be introduced. As an example, we
have again used the linear chirp, and the Daubechies 12 filters. The left hand
part of Fig. 9.24 shows the time-frequency plane based on the unaligned level
decomposition, whereas the right hand part shows the effect on alignment
based on shifts computed using Cmax '
Alignment based on the three methods for computing centers given above
is implemented in Uvi_ Wave. As can be guessed from Fig. 9.24, we have
used alignment in the other time-frequency plane plots given in this chapter.
We have used Cmax to compute the alignments. The various possibilities are
selected using the function wtmethod in UvL Wave.
~ ~
c: c:
Q) Q)
:::> :::>
0- 0-
l!! l!!
LL LL
Time Time
Fig. 9.24. The left hand part shows the time-frequency plane for the linear chirp
in Fig. 9.18 without alignment corrections. The right hand part is repeated from
this figure
120 9. The Time-Frequency Plane
It is evident from both Fig. 9.21 and Fig. 9.22 that the choice of basis de-
termines what kind of representation one gets in the time-frequency plane.
There are basically two possibilities. One can decide from the beginning that
one is to use a particular type of bases, for example a level basis, and then
plot time-frequency planes for a signal based on this choice. As the above
examples show this can be a good choice. In other cases the signal may be
completely unknown, and then the best choice may be to use a particular
cost function and find the best basis relative to this cost function. The time-
frequency plane is then based on this particular basis. As an example we have
taken the signal used in Fig. 9.22 and found the best basis using Shannon
entropy as the cost function. The resulting time-frequency plane is shown in
Fig. 9.25. One should compare the three time-frequency planes in Fig. 9.22
and Fig. 9.25. It is not evident which is the best representation to determine
the time-frequency contents of this very simple signal.
The simple examples given here show that to investigate the time-
frequency contents of a given signal may require the plot of many time-
frequency planes. In the best basis algorithm one may have to try several
different cost functions, or for example different values of the parameter p in
the fV-norm cost function.
Time
Fig. 9.25. The time-frequency plane for the signal from Fig. 9.22, in the best basis
determined using Shannon entropy as the cost function
9.5 More Fourier Analysis. The Spectrogram 121
We now present a different way to visualize the distribution of the energy with
respect to time and frequency. It is based on the short time Fourier transform,
and in practical implementations, on the discrete Fourier transform. The
resulting visualization is based on the spectrogram. To define it we need
some preparation.
Given a real signal x E £2(Z), and a sampling rate liT, we have visual-
ized the energy distribution as in Fig. 9.3. Here we have maximal resolution
with respect to time, since we take each sample individually. But we have no
frequency information beyond the size of the frequency interval, which is de-
termined by the sampling rate. On the other hand, if we use all samples, then
we can compute XT(W), which gives detailed information on the distribution
of the energy with respect to frequency. One can interpret i;;.IXT(wW as the
energy density, as can be seen from Parseval's equation (9.3). The energy in
a given frequency interval is obtained by integrating this density over that
interval.
We would like to make a compromise between the two approaches. This
is done in the short time Fourier transform. One chooses a window vector
w = {w[n]}nEZ' which is a sequence with the property that 0 ~ w[n] ~ 1
for all n E Z. Usually one chooses a window with only a finite number of
nonzero entries. In Fig. 9.26 we have shown four typical choices, each with
16 nonzero entries.
0.5 0.5
0'--------'-' 0'-----------'
o 5 10 15 o 5 10 15
0.5 0.5
o '---""""--~--- . . . . . -'
o 5 10 15
Fig. 9.26. Four window vectors of length 16. Top row shows rectangular and
triangular windows. Bottom row shows the Hanning window on the left and a
Gaussian window on the right
122 9. The Time-Frequency Plane
The window is moved to position k and then one computes the Fourier se-
ries of the sequence w[n - k]x[n], which is localized to this window. This is
repeated for values of k suitably spaced. Suppose that the length N of the
window is even. Then one usually chooses k = mN/2, mE Z. For N odd one
can take k = meN - 1)/2. Thus ones slides the window over the signal and
looks at the frequency contents in each window.
The function IXSTFT(k,wW is called a spectrogram. It shows the energy
density (or power) distribution in the signal, based on the choice of window
vector.
Take as the window vector the constant vector
then for all k we have XSTFT(k,w) = XT(W), the usual Fourier series. On
the other hand, if one chooses the shortest possible rectangular window,
w[n] = {1 for n = 0 ,
o for n¥-O ,
then one finds XSTFT(k,w) = x[k]e- ikTw , such that the time-frequency plane
in Fig. 9.3 gives a visualization of the spectrogram for this choice of window.
Concerning the window vectors in Fig. 9.26, then the rectangular one of
length N is given by w[k] = 1 for k = 1, ... ,N, and w[k] = 0 otherwise. The
triangular window is defined for N odd by
All values w[n] not defined by these equations are zero. The Hanning (or
Hann) window of length N is defined by
for a positive parameter a. In our example a = 0.03. Note that the four
window vectors can be obtained by sampling a box function, a hat function,
sin2(1Tt), and exp( -at2 ), respectively.
The above results can be applied to a finite signal, but for such signals
one usually chooses a different approach, based on the discrete Fourier trans-
form, here abbreviated as DFT. Since the Fourier expansion involves complex
numbers, it is natural to start with complex signals, although we very soon
restrict ourselves to real ones. A finite signal of length N will be indexed
by n = 0, ... ,N - 1. All finite signals of length N constitute the vector
space eN, of dimension N. We define
ek[n] = ei27rkn/N, n,k = 0, ... ,N -1. (9.16)
The vectors ek are orthogonal with respect to the usual inner product on eN,
see (7.44). Thus these vectors form a basis for the space of finite signals eN.
The DFT is then expansion of signals with respect to this basis. We use the
notation x for the DFT of x. The coefficients are given by
N-l
x[k] =L x[n]e-i27rkn/N . (9.17)
n=O
The inversion formula is
N-l
x[n] =~ L x[k]ei27rkn/N . (9.18)
k=O
Parseval's equation is for the DFT the equation
N-l
IIxl1 2
= ~ L Ix[kW . (9.19)
k=O
Let us note that the computations in (9.17) and (9.18) have fast implemen-
tations, known as the fast Fourier transform.
Comparing the definition of the DFT (9.17) with the definition of the
Fourier series (9.1), we see that
x[k] = X(27TkIN) .
Thus the DFT can be viewed as a sampled version of the Fourier series, with
the sample points 0, 21TIN, ... , 21T(N - 1)IN.
For a real x of length N we have
N-l N-l
irk] =L x[n]e i2 11"nk/N =L x[n]e- i21rn (N-k)/N = x[N - k] , (9.20)
n=O n=O
124 9. The Time-Frequency Plane
where we introduce the convention that x[N) = X[O). This is consistent with
(9.17). This formula allows us to define x[k) for any integer. It is then periodic
with period N.
We see from (9.20)that we need only half of the DFT coefficients to re-
construct x, when the signal is real.
Now the spectrogram used in signal processing, and implemented in the
signal processing toolbox for MATLAB as specgram, is based on the DFT. A
window vector w is chosen, and then one computes IXSTFT(k, 21rn/NW /21r
for values of k determined by the length of the window vector and for n =
0,1, ... ,N - 1. The spectrogram is visualized as a time-frequency plane,
where the cells are chosen as follows. Along the time axis the number of cells
is determined by the length of the signal N, the length of the window vector,
and the amount of overlap one wishes to use. The number of cells in the
direction of the frequency axis is determined by the length of the window
(the default in specgram). Assume the length of the window is L, and as
usual that the signal is real. If L is even, then there will be (L/2) + 1 cells
on the frequency axis, and if L is odd, there will be (L + 1)/2 cells. If the
sampling rate is know, then it is used to determine the units on the frequency
axis.
Let us give two spectrograms of the signal used in Fig. 9.22, and also
in Fig. 9.25. They are obtained using the specgram function from the signal
processing toolbox for MATLAB. In the plot on the left hand side of Fig. 9.27
a Hanning window of length 256 is used. In the right hand plot the window
length is 64. In both plots we have used a color map which emphasizes the
large values. Larger values are darker.
The trade-off between time and frequency localization is clearly evident in
these two figures. One should also compare this figure with Fig. 9.22 and with
Fig. 9.25. Together they exemplify both the possibilities and the complexity
in the use of time-frequency planes to analyze a signal.
Time Time
Fig. 9.27. The left hand part shows the time-frequency plane for the signal from
Fig. 9.22 obtained as a spectrogram with a Hanning window of length 256. In the
right hand part the window length is 64. The signal has 1024 samples
shortest window of length 64 in the STFT. But when using the best basis
algorithm to pick a basis, in this case based on Shannon's entropy, the time-
frequency plane is much improved. The different sized cells makes it possible
to target the long, slow oscillations in the lower half and the fast and short
oscillations in the upper half.
Exercises
After you have read Chap. 13, you should return to these exercises.
9.1 Start by running the basis script in Uvi_ Wave. Then use the Uvi_ Wave
functions tfplot and tree to display the basis tree graph and the time-
frequency plane tilings for a number of different basis.
9.2 Get the function for coloring the time-frequency tilings from the Web
site of this book (see Chap. 1) and reproduce the figures in this chapter.
9.3 Do further computer experiments with the time-frequency plane and
synthetic signals.
9.4 If you have access to the signal processing toolbox, do some experiments
with the specgram function to understand this type of time-frequency plane.
Start with simple signals with known frequency contents, and vary the win-
dow type and length.
126 9. The Time-Frequency Plane
Scalogram with best basis, Symlet 12, and the entropy cost function
~ 'C ~ .. ~ I~~~ ~ ~
,.-.= ~~
•. . ~~"Z',;;.;;,.;;;;
~·,,"",,,,':"'.cz:,,,.;;;"":,-~~·'·'·'-'
Time
Fig. 9.28. Four different time-frequency planes of the same signal. The signal is a
composite test signal consisting of one slow and fourteen very fast chirps, a fixed
frequency lasting the first half of the signal, and a periodic sinus-burst. The window
used in the Fourier analyses is a Hanning
10. Finite Signals
In the previous chapters we have only briefly, and in a casual way, consid-
ered the problems arising from having a finite signal. In the case of the Haar
transform there are no problems, since it transforms a signal of even length
to two parts, each of half the original length. In the case of infinite length
signals there are obviously no problems either. But in other cases we may
need for instance sample s[-I], and our given signal starts with sample s[O].
We will consider solutions to this problem, which we call the boundary prob-
lem. Theoretical aspects are considered in this chapter. It is important to
understand that there is no universal solution to the boundary problem. The
preferred solution depends on the kind of application one has in mind. The
implementations are discussed in Chap. 11. The reader mainly interested in
implementations and applications can skip ahead to this chapter.
Note that in this chapter we use a number of results from linear algebra.
Standard texts contain the results needed. Note also that in this chapter we
use both row vectors and column vectors, and that the distinction between
the two is important. The default is column vectors, so we will repeatedly
state when a vector is a row vector to avoid confusion. Some of the results in
this chapter are established only in an example, and the interested reader is
referred to the literature for the general case.
There is a change in notation in this chapter. Up to now we have used the
notation h o, hI, for the analysis filter pair in the filter bank version of the
DWT. From this chapter onwards we change to another common notation,
namely h, g (except for Chap. 12 which is closely connected to Chap. 7).
This is done partly to simplify the matrix notation below, partly because
the literature on the boundary problem typically uses this notation. We also
recall that we only consider filters with real coefficients.
To examine the extent of the problem with finite signals we use the lifting
steps for the Haar transform and Daubechies 4. We recall the definition of
the Haar transform
We start with a simple and obvious solution to the problem, which turns
out to be rather unattractive. Given a finite signal, we add zeroes before and
after the given coefficients to get a signal of infinite length. This is called zero
padding. In practice this means that when the computation of a coefficient
in the transform requires a sample beyond the range of the given samples in
the finite signal, we use the value zero.
If we take a signal with 8 samples, and apply zero padding, then we see
that in the Haar transform case we can get up to 4 nonzero entries in s(1) and
in d(1). Going through the steps in the Daubechies 4 transform we see that
in s(l) the entries with indices 0,1,2,3 can be nonzero, whereas in d(1) the
entries with indices 0,1,2,3,4 can be nonzero, and in S(2) those with indices
-1,0,1,2,3 can be nonzero. Thus in the two components in the transform
we may end up with a total of 10 nonzero samples.
This is perhaps unexpected, since up to now we have ignored this phe-
nomenon. Previously we have stated that the transform of a signal of even
10.1 The Extent of the Boundary Problem 129
length leads to two components, each of half the length of the input signal.
This is correct here, since we have added zeroes, so both the original signal
and the two transformed parts have infinite length. For finite signal the state-
ment is only correct, when one uses the Haar transform, or when one applies
the right boundary correction. Thus when we use zero padding, the number
of nonzero entries will in general increase each time we apply the DWT step.
It is important to note that all 10 coefficients above are needed to re-
construct the original signal, so we cannot just leave out two of them, if the
perfect reconstruction property is to be preserved. In general the number of
extra coefficients is proportional to the filter length. For orthogonal trans-
forms (such as those in the Daubechies family) the number of extra signal
coefficients is exactly L - 2, with L being the filter length. See p. 135 for the
proof.
When we use zero padding, the growth in the number of nonzero entries is
unavoidable. It is not a problem in the theory, but certainly in applications.
Suppose we have a signal of length N and a filter of length L, and suppose
we want to compute the DWT over k scales, where k is compatible with the
length of the signal, Le. N 2: 2k • Each application of the DWT adds L - 2
new nonzero coefficients, in general. Thus the final length of the transformed
signal can be up to N + k(L - 2).
The result of using zero padding is illustrated as in Fig. 10.1. As the
filter taps "slides" across the signal a number of low and high pass transform
coefficients are produced, a pair for each position of the filter. Since there are
(N + L)/2 - 1 different positions, the total number of transform coefficients
is twice this number, that is N + L - 2.
If one considers wavelet packet decompositions, then the problem is much
worse. Suppose one computes the full wavelet packet decomposition down to
a level J, Le. we apply the DWT building block J -1 times, each time to all
elements in the previous level. Starting with a signal of length N and a filter
of length L, then at the level J the total length of the transformed signal can
be up to N + (2 J - 1 - 1)(L - 2). This exponential growth in J makes zero
padding an unattractive solution to the boundary problem.
Thus it is preferable to have available boundary correction methods, such
that application of the corrected DWT to a signal leads to two components,
each of half the length of the original signal. Furthermore we would like
to preserve the perfect reconstruction property. We present four different
methods below. The first three methods use a number of results from lin-
ear algebra. The fourth method requires extensive knowledge of the classical
wavelet theory and some harmonic analysis. It will only be presented briefly
and incompletely.
The reader interested in implementation can go directly to Chap. 11.
The methods are presented here using the filter bank formulation of the
DWT step. Another solution to the boundary problem based directly on the
lifting technique is given in Sect. 11.4.2 with CDF(4,6) as an example. The
130 10. Finite Signals
--
2 taps Length L
Fig. 10.1. The result of zero padding when transforming a finite signal. The grey
boxes illustrates the positions of the filter taps as the filtering occurs. Each position
gives a low pass and high pass coefficient. The number of positions determines the
number of transform coefficients. In this figure we have omitted most of the 'interior'
filters to simplify it
connection between filter banks and lifting is discussed in Chap. 7 and more
thoroughly in Chap. 12.
(Hx) [0]
(Gx)[O]
(Hx)[l]
(Gx)[l] ,
(Hx)[2]
(Gx) [2]
h
V2 [3 -6 -16
= -128 38 90 38 -16 -6 3]
'
V2
g = - [1 -2 1]'
4
10.2 DWT in Matrix Form 133
h
-V2
= 4 [1 2 1],
g = ~ [3 6 -16 -38 90 -38 -16 6 3].
and, just as it was the case for orthogonal filters, the synthesis matrix consists
of the synthesis IR in forward order in the columns of T s , such that
Note that the alignment of hand g must match the alignment of hand g
in T a' We have now constructed two matrices, which perform the orthogonal
and biorthogonal wavelet transforms, when multiplied with the signal.
134 10. Finite Signals
length L
Fig. 10.2. The idea behind all types of boundary filter is to replace the filters
reaching beyond the signal (see Fig. 10.1) with new, shorter filters (light grey).
By having the right number of boundary filters it is possible to get exactly the
same number of transform coefficients as signal samples while preserving certain
properties of the wavelet transform
{~[nl
if n ~ -1,
sIn) = if n = 0,1, ... , N - 1 , (10.10)
if n '? N .
10.3 Gram-Schmidt Boundary Filters 135
°
Suppose that the filter has length L, with the nonzero coefficients having
indices between and L - 1. To avoid special cases we also assume that N
is substantially larger than L, and that both Land N are even. We then
examine the formula (see (7.51))
N-l
(Hs)[n] =L h[2n - k]s[k] =L h[2n - k]x[k]
kEZ k=O
for each possible value of n. If n < 0, the sum is always zero. The first
nonzero term can occur when n = 0, and we have (Hs)[O] = h[O]x[O]. The
last nonzero term occurs for n = (N +L-2)/2, and it is (Hs)[(N +L-2)/2] =
h[L-1]x[N -1]. The same computation is valid for the Gs vector. Thus in the
transformed signal the total number of nonzero terms can be up to N + L - 2.
This computation also shows that in the index range L/2 < n < N -(L/2)
all filter coefficients are multiplied with x-entries. At the start and the end
only some filter coefficients are needed, the others being multiplied by zero
from the zero padding of the signal s. This leads to the introduction of the
boundary filters. We modify the filters during the L/2 evaluations at both
the beginning and the end of the signal, taking into account only those filter
coefficients that are actually needed. Thus to adjust the h filter a total of L
new filters will be needed. The same number of modifications will be needed
for the high pass filter. It turns out that we can manage with fewer modified
filters, if we shift the location of the finite signal one unit.
Let us repeat the computation above with the following modification of
the zero padding. We define
o if n:::; -2,
SShift[n]= x[n+1] ifn=-1,0,1, ... ,N-2, (10.11)
{
° ifn~N-1.
With this modification we find that the first nonzero term in H s can be
this gives finite matrices it does not solve the problem that the transformed
signal can have more nonzero entries than the original signal. The next step is
therefore to alter the truncated matrices to get orthogonal matrices. We treat
only orthogonal filters, since the biorthogonal case is rather complicated.
Let us start with the example from the previous section. For a filter of
length 6 and a signal of length 8 the transformed signal can have 12 non-
vanishing elements, as was shown above. Let us remove the part of the matrix
that multiplies zeroes in Sshift. The reduced matrix is denoted by T~, and it
is given as
h[1] h[O] 0 0 0 0 0 0 y[O]
9[1] 9[0] 0 0 0 0 0 0 y[1]
h[3] h[2] h[1] h[O] 0 0 0 0 x[O] y[2]
9[3] 9[2] 9[1] 9[0] 0 0 0 0 x[1] y[3]
h[5] h[4] h[3] h[2] h[1] h[O] 0 0 x[2] y[4]
9[5] 9[4] 9[3] 9[2] 9[1] 9[0] 0 0 x [3] y[5]
T~x= (10.12)
0 o h[5] h[4] h[3] h[2] h[1] h[O] x [4] y[6]
0 o 9[5] 9[4] 9[3] 9[2] 9[1] 9[0] x[5] y[7]
0 0 0 o h[5] h[4] h[3] h[2] x[6] y[8]
0 0 0 o 9[5] 9[4] 9[3] 9[2] x[7] y[9]
0 0 0 0 0 o h[5] h[4] y[lO]
0 0 0 0 0 o 9[5] 9[4] y[l1]
It is evident from the two computations above with the original and the
shifted signal that the truncation of the T a matrix is not unique. As de-
scribed above, we have chosen to align the first non-vanishing element in x
with h[1] and 9[1]. This makes T~ "more symmetric" than if we had chosen
h[O] and 9[0]. Moreover, choosing the symmetric truncation guarantees linear
independence of the rows, see [11]' a property which we will need later. By
truncating T a to make the 12 x 8-matrix T~ we have not erased any infor-
mation in the transformed signal. Hence it is possible, by reducing T s to an
8 x 12 matrix, to reconstruct the original signal (see Exer. 10.6).
Now we want to change the matrix T~ such that y has the same number
of coefficients as x. When looking at the matrix equation (10.12) the first idea
might be to further reduce the size of T~, this time making an 8 x 8 matrix,
by removing the two upper and lower most rows. The resulting matrix is
denoted by T~. At least this will ensure a transformed signal with only 8
coefficients. By removing the two first and two last columns in T~ we get an
8 x 8 synthesis matrix. The question is now whether we can reconstruct x
from y or not. As before, if we can prove T~T~ = I, perfect reconstruction
is guaranteed. Although it is easily shown that we cannot obtain this (see
Exer. 10.7), the truncation procedure is still useful. For it turns out that the
matrices T~ and T~ have a very nice property which, assisted by a slight
adjustment of the matrices, will lead to perfect reconstruction. Moreover this
adjustment also ensures energy preservation, which is one of the properties
of orthogonal filters that we want to preserve in the modified matrix.
10.3 Gram-Schmidt Boundary Filters 137
n
2 Un .
(10.14)
If v is in the subspace spanned by the U vectors, v' will be the zero vector.
It is easy to verify that v'is orthogonal to all the vectors Un, n = 0, ... ,N.
Thus the set of vectors no, UI, ... ,UN,V ' consists of N + 2 mutually orthog-
onal vectors. In this manner any set of linearly independent vectors can be
transformed to a set of mutually orthogonal vectors, which span the same
subspace as the original set. This is the Gram-Schmidt orthogonalization
procedure. It desired, the new vectors can be normalized to have norm one,
to get an orthonormal set.
We want all the rows in M to be mutually orthogonal. Since m2 through ms
already are orthogonal (they have not been truncated), we need only orthog-
onalize mo, ml, m6, and m7 with respect to the remaining vectors. We start
by orthogonalizing mo with respect to m2 through ms,
(10.15)
138 10. Finite Signals
(10.16)
We continue with m7 and m6. Note that they are orthogonal to mo and mb
since the nonzero entries do not overlap. Thus if we compute
(10.17)
(10.18)
then these vectors are also orthogonal to ~ and m~. Actually the number
of computations can be reduced, see Exer. 10.8.
We now replace the first two rows in M with ~ and m~, respectively,
and similarly with the last two rows. The rows in the new matrix are or-
thogonal. We then normalize them to get a new orthogonal matrix. Since
m2 through m5 already have norm 1, we need only normalize the four new
vectors.
m~
/I
n = 0,1,6,7.
mn = Ilm~II'
The result is that we have transformed the matrix M to the orthogonal matrix
M'=
Note that the changes in the analysis matrix are only performed at the first
two and last two rows. The two new top rows are called the left boundary
filters and those at the bottom the right boundary filters.
If we need to transform a longer finite signal of even length, we can just
add the necessary pairs of hand g in the middle, since these rows are or-
thogonal to the four new vectors at the top and bottom. Let us verify this
10.3 Gram-Schmidt Boundary Filters 139
claim. Let us look at for example m~ from (10.16). The vectors roo and ml
are orthogonal to the new rows in the middle, since they have no nonzero
entries overlapping with the entries in the new middle rows, see (10.13). The
remaining vectors in the sums defining m~ are combinations of the vectors
m2, ... ,m5, which have not been truncated, and therefore are orthogonal to
the new middle rows. The orthogonality of the three remaining vectors to the
new middle rows is obtained by similar arguments.
roo
} L/2 - I left truncated IRs ,
mL/2-2
mL/2-1
M= } N - L + 2 whnle IRs , (10.19)
mN-L/2+2
mN-L/2+1
Then all the truncated rows are orthogonalized by the Gram-Schmidt proce-
dure (10.14). It is easy to show that (see Exer. 10.8) we need only orthog-
onalize roo through mL/2-2 with respect to themselves (and not to all the
IRs). So the left boundary filters mi, are defined as
and
140 10. Finite Signals
1 mk
k = 0, ... ,L/2 - 2 .
mk = IImkl1 2 '
In the same way the vectors mN-L/2+2 through mN-1 are converted into
L/2 -1 right boundary filters, which we denote by mo
through m~/2_1. The
Gram-Schmidt orthogonalization of the right boundary filters starts with
mN-I. The new orthogonal matrix then becomes
~
} L/2 - 1 left boundaxy filte" ,
1
m L / 2- 2
mL/2-1
M'= } N - L + 2 whole filte" , (10.20)
mN-L/2+2
mo
} L/2 -1 dght bonndaxy filt"" ,
r
m L / 2- 2
The length of the boundary filter m~/2_2 constructed this way is L - 2, and
the length of mi, is decreasing with k. The right boundary filters exhibit the
same structure.
The boundary filters belonging to the inverse transform are easily found,
since the synthesis matrix is the transpose of analysis matrix. The imple-
mentation of the construction and the use of the boundary filters are both
demonstrated in Chap. 11.
lOA Periodization
The simple solution to the boundary problem was zero padding. Another
possibility is to choose samples from the signal to use for the missing samples.
One way of doing this is to periodize the finite signal. Suppose the original
finite signal is the column vector x, of length N. Then the periodized signal
is given as
x
xP= x = [... x[N - 2] x[N -1] x[O] ... x[N -1] x[O] x[l] ...]T.
X
This signal is periodic with period N, since xP[k+N] = xP[k] for all integers k.
It is important to note that the signal x P has infinite energy. But we can still
IDA Periodization 141
transform it with T a, since we use filters of finite length, such that each row in
T a only has a finite number of nonzero entries. Let yP = T aXP, or explicitly
x[N-2] y[N-2]
h[5] h[4] h[3] h[2] h[l] h[O] 0 0 0 0 x[N-l] y[N-l]
g[5] g[4] g[3] g[2] g[l] g[O] 0 0 0 0 x[O] y[O]
0 o h[5] h[4] h[3] h[2] h[l] h[O] 0 0
0 o g[5] g[4] g[3] g[2] g[l] g[O] 0 0 =
0 0 0 o h[5] h[4] h[3] h[2] h[l] h[O] x[N-l] y[N-l]
0 0 0 o g[5] g[4] g[3] g[2] g[l] g[O] x [0] y[O]
x[l] y[l]
(10.21)
The transformed signal is also periodic with period N. We leave the easy
verification as Exer. 10.9. We select N consecutive entries in yP to represent
it. The choice of these entries is not unique, but below we see that a particular
choice is preferable, to match up with the given signal x.
We have transformed a finite signal x into another finite signal y of equal
length. The same procedure can be used to inversely transform y into x using
the infinite T s (see Exer. 10.9). Thus periodization is a way of transforming a
finite signal while preserving the length of it. In implementations we need to
use samples from x instead of the zero samples used in zero padding. We only
need enough samples to cover the extent of the filters, which is at most L - 2.
But we would like to avoid extending the signal at all, since this requires
extra time and memory in an implementation. Fortunately it is very easy to
alter the transform matrix to accommodate this desire. This means that we
can transform x directly into y.
We start by reducing the infinite transform matrix such that it fits the
signal. If the signal has length N, we reduce the matrix to an N x N matrix,
just at we did in the previous section on boundary filters. Although we do
not need a symmetric structure of the matrix this time, we choose symmetry
anyway in order to obtain a transformed signal of the same form as the
original one.
Let us use the same example as above. For a signal of length 10 and filter
of length 6 the reduced matrix is
142 10. Finite Signals
h[3] h[2]
h[l] h[O] 0 0 0 0 0 0
g[3] g[2]
g[l] g[O] 0 0 0 0 0 0
h[5] h[4]
h[3] h[2] h[l] h[O] 0 0 0 0
g[5] g[4]
g[3] g[2] g[l] g[O] 0 0 0 0
o 0 h[5] h[4] h[3] h[2] h[l] h[O] 0 0
o 0 g[5] g[4] g[3] g[2] g[l] g[O] 0 0
o 0 0 0 h[5] h[4] h[3] h[2] h[l] h[O]
o 0 0 0 g[5] g[4] g[3] g[2] g[l] g[O]
o 0 0 0 0 0 h[5] h[4] h[3] h[2]
o 0 0 0 0 0 g[5] g[4] g[3] g[2]
The periodization is accomplished by inserting all the deleted filter coeffi-
cients in appropriate places in the matrix. This changes the matrix to
h[3] h[2]
h[l] h[O] 0 0 0 0 h[5] h[4]
g[3] g[2]
g[l] g[O] 0 0 0 0 g[5] g[4]
h[5] h[4]
h[3] h[2] h[l] h[O] 0 0 0 0
g[5] g[4]
g[3] g[2] g[l] g[O] 0 0 0 0
TPa =
o 0 h[5] h[4] h[3] h[2] h[l] h[O] 0 0
(10.22)
o 0 g[5] g[4] g[3] g[2] g[l] g[O] 0 0
o 0 0 0 h[5] h[4] h[3] h[2] h[l] h[O]
o 0 0 0 g[5] g[4] g[3] g[2] g[l] g[O]
h[l] h[O] 0 0 0 0 h[5] h[4] h[3] h[2]
g[l] g[O] 0 0 0 0 g[5] g[4] g[3] g[2]
It can be shown (see Exer. 10.9) that y = T~x is the same signal as found
in (10.21). Now T~ is orthogonal, so the inverse transform is given by (T~) T.
The same principle can be applied to biorthogonal filters. A length 12
signal and a biorthogonal filter set with analysis low pass filter of length 9
and high pass filter of length 3 would give rise to the matrix
h[5] h[4] h[3] h[2] h[l] h[O] 0 0 0 h[8] h[7] h[6]
o g[2] g[l] g[O] 0 0 0 0 0 0 0 0
h[7] h[6] h[5] h[4] h[3]
h[2] h[l] h[O] 0 0 0 h[8]
o 0 0 g[2] g[l] g[O] 0 0 0 0 0 0
o h[8] h[7] h[6] h[5]h[4] h[3] h[2] h[l] h[O] 0 0
TPa =
o 0 0 0 0 g[2] g[l] g[O] 0 0 0 0
(10.23)
o 0 0 h[8] h[7] h[6] h[5] h[4] h[3] h[2] h[l] h[O]
o 0 0 0 0 0 0 g[2] g[l] g[O] 0 0
h[l] h[O] 0 0 0 h[8] h[7] h[6] h[5] h[4] h[3] h[2]
o 0 0 0 0 0 0 0 0 g[2] g[l] g[O]
h[3] h[2] h[l] h[O] 0 0 0 h[8] h[7] h[6] h[5] h[4]
g[l] g[O] 0 0 0 0 0 0 0 0 0 g[2]
The corresponding synthesis matrix cannot be found simply by transpos-
ing the analysis matrix, since it is not orthogonal. It is easily constructed,
however.
10.4 Periodization 143
and calculate the determinant (7.34), we find that (remember that a different
notation for filters is used in Chap. 7)
The odd shift in index due to the power Z5 is a consequence of the perfect
reconstruction requirement, as explained in Chap. 7. The immediate result
of (10.26) is
n n
and if we assume that g[n] =I 0 for n = 0,1,2 (as we implicitly did in (10.23)),
then we find that
h[-5]Z5 + h[-4]z4 + h[-3]z3 = _g[0]Z5 + g[1]z4 - g[2]z3 , (10.27)
144 10. Finite Signals
which seems to match poorly with our choice of index of h[n] in (10.24).
The reason is that while the index n = -5, -4, -3 of h[n] is the correct
one in the sense that it matches in the z-transform, we usually choose a
more convenient indexing in implementations (like n = 0,1,2). To complete
the calculation started in (10.25), we need to stick to the correct indexing,
however. We therefore substitute g[l] = h[-4]. Doing the same calculation
for g[n], we find the we can substitute g[4] = h[4] (this is left as an exercise).
Now (10.25), with the correct indexing of h, becomes
The second equality is valid since h[n] = 0 except for n = -5, -4, -3, and
the third follows immediately from (7.56).
10.4.1 Mirroring
o T
o T
Fig. 10.3. The top part shows periodic continuation of a signal, and the bottom
part mirroring
important, since it is equivalent with energy preservation. But there are other
properties beyond energy that it can be useful to preserve under transforma-
tion. One of them is related to moments of a sequence.
At the end of Sect. 3.3 we introduced the term moment of a sequence.
We derived
(10.29)
n n
which shows that the transform discussed in Sect. 3.3 (the CDF(2,2) trans-
form) preserves the first moment of a sequence. Generally, we say that
(10.30)
is the k'th moment of the sequence s. Since (10.29) was derived without
taking undefined samples into account, it applies to infinite sequences only.
A finite sequence can be made infinite by zero padding, but this method
causes the sequence Sj-l to be more than half the length of sequence Sj' If
we want (10.29) to be valid for finite sequence of the same length, a better
method is needed. The next two subsections discuss two important questions
regarding the preservation of moments, namely why and how.
for some M 2: 1. The M depends on the filter. For Daubechies 4 this property
holds for M = 2, while for CDF(2,2) we have M = 2, and for CDF(4,6) we
have M = 4. A sequence satisfying (10.31) for some M is said to have M
vanishing moments.
Assume that the filter g has M vanishing moments. Take a polynomial
M-l
j
p(t) =L Pjt
j=O
=L g[k]s[n - k]
k
M-l
= Lg[k] L pj(n - k)j
t (~)(_l)mkmnj-m
k j=O
= Lg[k] tlPj
to (~)
k 3=0 m=O
=0. (10.32)
Note that we work with a filter g of finite length, so all sum above are finite.
Thus filtering with g maps a signal obtained from sampling a polynomial
of degree at most M - 1 to zero. Note also that we do not have to sam-
ple the polynomial at the integers. It is enough that the sample points are
equidistant.
This property of the high pass filter g has an interesting consequence,
when we do one step in a DWT. Since we have perfect reconstruction, the
polynomial samples get mapped into the low pass part. This is consistent
with the intuitive notion that polynomials of low degree do not oscillate
much, meaning that they contain no high frequencies. The computation in
(10.32) shows that with the particular filters used here the high pass part is
actually zero, and not just close to zero, which is typical for non-ideal filters
(at this point one should recall the filters used in a wavelet decomposition
are not ideal).
10.5 Moment Preserving Boundary Filters 147
The idea for preserving the number of vanishing moments, and hence be able
to reproduce polynomials completely in the low pass part, is simple, although
the computations are non-trivial. We will only show the basic steps, and leave
out most of the computations.
We start our considerations by redoing the computation in (10.32), this
time for a general filter h of length L, and the same signal s. This time we
choose the opposite order in the application of the binomial formula. In the
second equality we use (7.9). Otherwise the computations are identical. We
get
n
(h * s)[n] = L h[n - k]s[n]
k=n-L+1
L-1
=L h[k]s[n - k]
k=O
L-1 M-1
=L h[k] L pj(n - k)j
't,' t. (~)
k=O j=O
~ ~ h[k] P;
m
n (_k);-m
M-1
= L qm nm , (10.33)
m=O
where we have not written out the complicated expressions for the coeffi-
cients qm, since they are not needed. We see from this computation that
convolution with any filter h of finite length takes a sampled polynomial of
degree at most M - 1 into another sampled polynomial, again of degree at
most M -1. If we have a finite number of nonzero samples, then the resulting
convolution will have more samples, as explained above.
We would like to be able to invert this computation, in the sense that
we start with the signal x of length N, obtained by sampling an arbitrary
polynomial of degree at most M - 1,
M-1
x[n] =L qm nm , n = 0, ... ,N -1,
m=O
148 10. Finite Signals
Exercises
10.1 Start by reviewing results from linear algebra on orthogonal matrices
and the Gram-Schmidt orthogonalization procedure.
10.2 Determine which results in Chap. 7 are needed to show that the syn-
thesis matrix T s in (10.9) is the same as the transpose of the analysis matrix
Ta in (10.7), or equivalently that TJTa = I.
10.3 Show that an orthogonal matrix preserves energy when multiplied with
a signal. In other words, IITxl1 2 = IIxl1 2 whenever T is orthogonal. Remember
that TT = T- 1 .
Exercises 149
lOA Show that the first two rows of T~ in (10.13) are linearly independent.
Hint: Let rl and r2 be the two rows, substitute the g's in r2 with h's, and
show that there does not exist a such that arl = r2.
10.5 Verify the following statement from Sect. 10.3.2: If (L - 2)/2 is even,
then the top row in the symmetrically truncated T a contains coefficients from
the filter h and the bottom row coefficients from the filter g. If (L - 2)/2 is
odd, the positions of the filter coefficients are reversed.
10.6 The purpose of this exercise is to construct the truncated synthesis
matrix T~ to match the truncated analysis matrix T~. Keep in mind the
difference in notation between this chapter and Chap. 7.
1. Write the T~ by reducing the matrix in (10.9) in such a way that its
structure matches that of T~ in (10.12).
2. Let h be an orthogonal low pass analysis filter, and define
5
H(z) =L h[n]z-n.
n=O
[h[4] g[4] h[2] g[2] h[O] g[O]] and [h[l] g[l] h[3] g[3] h[5] g[5]] .
Use the correctly indexed filters, which are the four filters H, G, iI, and
G found above.
5. Determine also the inner product of
[h[5] g[5] h[3] g[3] h[l] g[l]] and [h[l] g[l] h[3] g[3] h[5] g[5]] .
6. Describe why these calculations make it plausible that T~ is the matrix
which reconstructs a signal transformed with T~. Remember that the
condition for perfect reconstruction is T~ T~ = I.
10.7 Show that the matrix T~ in (10.13) is not orthogonal.
10.8 Most of the orthogonalization calculations in (10.15) - (10.18) are re-
dundant. Verify the following statements.
1. (10.15) is unnecessary.
2. (10.16) can be reduced to
I moml
m 1 = ml - Ilmol1 2 mo . (10.34)
150 10. Finite Signals
Let us assume that the signal is in Signal, and we want the means in the
vector s and the differences in the vector d. The Haar transform equations
are (see (3.1) and (3.2))
a+b
8=-2-'
d =a - 8.
Note that it is often a good idea to allocate the memory needed for the
output vectors. This can be done by typing s = zeros (1, Len) , where Len is
the desired length. Then MATLAB allocates all the memory at once instead
of as it is needed. With short signals the time saved is minimal, but with a
million samples a lot of time can be saved this way.
We now have a function, which can turn the first row in Table 11.1 into
the second row, and the first four entries in the second row into the first four
entries in the third row, and so on. The next step is to make a function,
which uses dwthaar an appropriate number of times, to produce the entire
decomposition. As input to this function we have again the signal, while the
output is a matrix containing the decomposition, equivalent to Table 11.1.
First the matrix T is allocated, then the signal is inserted as the first row.
The for loop uses dwthaar to calculate the three remaining rows.
T = zeros(4,S);
T(l,:) = Signal;
for j=1:3
Length = 2-(4-j);
T(j+l, l:Length) = dwthaar( T(j, l:Length) );
T(j+1, Length+l:S) = T(j, Length+l:S);
end
For each level the length of the elements, and hence the signal to be trans-
formed, is determined. Since this length is halved for each increment of j
(first 8, then 4, then 2), it is given as 2-(4-j) = 24 - j • Then the first part
of the row is transformed, and the remaining part is copied to the next row.
This piece of code can easily be extended to handle any signal of length 2N
for N E N. This is done with Function 2.2.
11.3 Implementing the DWT Through Lifting 155
N = size(Signal.2);
J = log2(N);
if rem(J .1)
error('Signal must be of length 2-N.');
end
T = zeros(J. N);
T(1.:) = Signal;
for j=1:J
Length = 2-(J+1-j);
T(j+1. 1:Length) = dwthaar( T(j. 1:Length) ):
T(j+1. Length+1:N) = T(j. Length+l:N):
end
The variable J is the number of rows needed in the matrix. Since rem is
the remainder after integer division, rem (J , 1) is the fractional part of the
variable. If it is not equal to zero, the signal is not of length 2N , and an error
message is displayed (and the program halts automatically).
Note that the representation in a table like Table 11.1 is highly inefficient
and redundant due to the repetition of the computed differences. But it is
convenient to start with it, in order to compare with the tables in Chap. 2.
s[n] = J3-1()
,j2 s 2 [n] , (11.4)
With the first method all the signal samples are 'sent through' equation
(11.1). Then all the odd signal samples and all the S(l) samples are sent
through equation (11.2), and so on. We will see this in more detail later.
With the second method the first equation is applied to first two signal
samples, and the resulting s(1) is put into the next equation along with one
odd signal sample and another s(1). Following this pattern we get one sand
one d from (11.4) and (11.5). This is repeated with the third and fourth signal
samples giving two more sand d values.
The first method is much easier to implement than the second one, espe-
cially in MATLAB. However, in a real application the second method might
be the only option, if for example the transform has to take place while the
signal is 'coming in.' For this reason we refer to the second method as the
real time method, although it does not necessarily take place in real time.
We start with the first method.
s1 = S(1:2:N-1) + sqrt(3)*S(2:2:N);
in MATLAB code. This type of vector calculation is exactly what MATLAB
was designed to handle, and this single line executes much faster than the for
loop. The next equation is (11.2), and it contains a problem, since the value
of s(l)[n - 1] is not defined for n = O. There are several different solutions
to this problem (see Chap. 10). We choose periodization, since it gives a
unitary transform and is easily implemented. In the periodized signal all
undefined samples are taken from the other end of the signal, Le. its periodic
continuation. This means that we define s(1)[-I] == S(l) [N/2]. Let us review
equation (11.2) in vector form when we periodize.
d(1)[I]]
d(l) [2] [8[2]]
8[4] v'3 [ s(1)[I]
s(1)[2] ] v'3 - 2 [ s(1)[N/2]
s(1)[I] ]
This method for implementing lifting steps is actually quite easy, and since
the entire signal is usually known in MATLAB, it is definitely the preferred
one.
If implementing in another environment, for example in C, the vector
operations might not be available, and the for loop suggested in the begin-
ning of this section becomes necessary. The following function shows how to
implement Function 3.1 in C.
158 11. Implementation
Note that the periodization leads to two extra lines of code, one prior to the
first loop, and one posterior to the second loop. The indexing now starts at O.
Consequently, the C implementation is closer to the Daubechies 4 equations
(11.1) through (11.5) than to the MATLAB code.
There are a few things that can be improved in the above MATLAB and
C implementations. We will demonstrate this in the following example.
%
function P = cpv(S, k)
if k > 0
P = [S(k+1:end) S(1:k)];
else if k < 0
P = [S(end+k+1:end) S(1:end+k)];
end
With this function we could write the second and third lines of the Daube-
chies 4 implementation in Function 3.1 as
d1 = S(2:2:N) - sqrt(3)/4*s1 - (sqrt(3)-2)/4*cpv(s1,-1);
s2 = s1 - cpv(d1,1);
With these two things in mind, we can now write a compact implementation
of CDF(4,6).
The three dots in the third line just tell MATLAB that the command con-
tinues on the next line. Typing the entire command on one line would work
just as well (but this page is not wide enough for that!).
The C implementation of CDF(4,6) is shown in the next function. Notice
that no less than five entries in s must be calculated outside one of the for
loops (three before and two after).
N = N/2;
5[0] += (35*d[N-3]-265*d[N-2]+998*d[N-1]+998*d[0]-265*d[1]
+35*d[2])/4096:
5[1] += (35*d[N-2]-265*d[N-1]+998*d[0]+998*d[1]-265*d[2]
+35*d[3])/4096;
5[2] += (35*d[N-1]-265*d[0]+998*d[1]+998*d[2]-265*d[3]
+35*d[4])/4096:
K = 4/5qrt(2):
for (n = 0; n < N; n++) {
5[n] *= K:
d[n] /= K;
}
Due to the limited width of the page some of the lines have been split. Ob-
viously, this is not necessary in an implementation.
d1 = d / «5qrt(3)+1)/5qrt(2»:
52 = 5 / «sqrt(3)-1)/sqrt(2»;
51 = 52 + cpv(d1,1):
S(2:2:N) = d1 + sqrt(3)/4*51 + (sqrt(3)-2)/4*cpv(s1,-1):
S(1:2:N-1) = 51 - sqrt(3)*S(2:2:N);
that all transforms have references back and/or forth in time, for example
the second and third equations in Daubechies 4 read
1 1
d(1)[n] = S[2n + 1] - 4V3s(1)[n] - 4(V3 - 2)s(1)[n - 1] , (11.11)
s(2)[n] = s(l)[n] - d(l)[n + 1] , (11.12)
where s(1)[n -1] refers to a previously computed value, and d(l)[n + 1] refers
to a not yet computed value. Both types of references pose a problem, as will
be clear in the next section. The advantage of the real time implementation
is that it can produce two output coefficients (an s and a d value) each time
two input samples are ready. Hence this method is suitable for a real time
transform, which is a transformation of the signal as it becomes available.
Again we see the problem mentioned above. The most obvious one is d1 (n+1)
in the third line of the loop, since this value has not yet been computed. A
less obvious problem is sl (n-1) in the second line of the loop. This is a
previous calculated value, and as such is does not pose a problem. But in the
very first run through the loop (for n = 1) we will need s1(O). Requesting
this in MATLAB causes an error! The problem is easily solved by doing an
initial computation before starting the loop.
Since the value d1(n+1) is needed in the third line, we could calculate
that value in the previous line instead of d1 (n). This means changing the
second line to
d1(n+1) = S(2*(n+1» - sqrt(3)/4*s1(n+1) - (sqrt(3)-2)/4*s1(n);
Now we no longer need s1(n-1). Instead we need sl (n+1), which can be
calculated in the first line by changing it to
162 11. Implementation
for n=1:N/2-1
sl(n+l) = S(2*(n+l)-1) + sqrt(3)*S(2*(n+l»;
dl(n+l) = S(2*(n+l» - sqrt(3)/4*sl(n+l) - (sqrt(3)-2)/4*sl(n);
s2(n) = sl(n) - dl(n+l);
sen) = s2(n) * K;
den) = dl(n) / K;
end
Notice how periodization is used when calculating d1 (1) and 82 (N/2). In the
case of d1(1) it causes a problem, since it seems that we need S(N-1) and
S (N), and they are not necessarily available. One solution would be to use
another boundary correction method, but this would require somewhat more
work to implement. Another solution is to shift the signal by two samples, as
demonstrated in Function 4.3.
for n=1:N/2-2
sl(n+1) = S(2*(n+l)-1+2) + sqrt(3)*S(2*(n+l)+2);
d1(n+l) = S(2*(n+1)+2) - sqrt(3)/4*sl(n+1) - (sqrt(3)-2)/4*sl(n);
s2(n) = sl(n) - d1(n+l);
sen) = s2(n) * K;
den) = d1(n) / K;
end
5 (N/2-1) s2(N/2-1) * K;
d(N/2-1) d1(N/2-1) / K;
Notice how one more loop has to be extracted to accommodate for this
change.
Now, once the first four signal samples are available, Function 4.3 will
produce the first two transform coefficients s(l) and d(l), and for each
subsequent two signal samples available, another two transform coefficients
can be calculated.
There is one major problem with the implementation in Function 4.3. It
consumes a lot of memory, and more complex transforms will consume even
more memory. The memory consumption is 5 times N /2, disregarding the
memory needed for the signal itself. But it does not have to be that way. In
reality, only two entries of each of the vectors sl, s2, and dl are used in a
loop. After that they are not used anymore. The simple solution is to change
all sl and s2 to s, and all dl to d.
for n=1:N/2-2
s(n+l) = S(2*(n+l)-1+2) + sqrt(3)*S(2*(n+l)+2);
d(n+l) = S(2*(n+l)+2) - sqrt(3)/4*s(n+l) - (sqrt(3)-2)/4*s(n);
sen) = sen) - d(n+l);
sen) = sen) * K;
den) = den) / K;
end
In this case it does not cause any problems - the function still performs a
Daubechies 4 transform. But it is not always possible just to drop the original
indexing, as we shall see in the next section.
The inverse transform is, as always, easy to implement. It is shown in the
following function.
164 11. Implementation
d(N/2-1) = d(N/2-1) * K;
s(N/2-1) = s(N/2-1) / K;
s(N/2-1) = s(N/2-1) + d(N/2);
S(2) = d(N/2) + sqrt(3)/4*s(N/2) + (sqrt(3)-2)/4*s(N/2-1);
S(l) = s(N/2) - sqrt(3)*S(2);
for n=N/2-2:-1:1
den) = den) * K;
sen) = sen) / K;
sen) = sen) + d(n+l);
S(2*(n+l)+2) = d(n+l) + sqrt(3)/4*s(n+l) + (sqrt(3)-2)/4*s(n);
S(2*(n+l)-1+2) = s(n+l) - sqrt(3)*S(2*(n+l)+2);
end
As before, we start with the raw equations for CDF(4,6). Note that the scaling
factor K = 4/ sqrt (2) is omitted.
s[n] = s[n]- I~8 (5d[n - 2]- 29d[n - 1]- 29d[n] + 5d[n + 1]) .
We will apply this boundary correction method to our current transform, and
we will use CDF(I,I), CDF(4,2), and CDF(4,4), so we start by stating these
(except for CDF(I,I), which is actually the Haar transform).
The advantage of using transforms from the same family (in this case the
CDF(4,x) family) is that the first two lifting steps and the scaling steps are
the same.
First we examine the loop in Function 4.7 for n = 3. The first two lines
cause not problems, but the third would require d(3-3), which is an undefined
sample. Using CDF(4,4) instead, as suggested above, the first three lines read
8(3+3) = 5(2*(3+3)-1) - 1/4*( 5(2*(3+3)-2) + 5(2*(3+3» );
d(3+2) = 5(2*(3+2» - 8(3+2) - 8(3+3);
8(3) = 8(3) - 1/128*( 5*d(3-2) -29d(3-1) -29*d(3) +5*d(3+1) );
11.4 The Real Time Method 167
for n = 4:N/2-3
5(n+3) = 8(2*(n+3)-1) - 1/4*( 8(2*(n+3)-2) + 8(2*(n+3» );
d(n+2) = 8(2*(n+2» - 5(n+2) - 5(n+3);
5(n) = 5(n) - 1/4096*( -35*d(n-3) +265*d(n-2) -998*d(n-1) ...
-998*d(n) +265*d(n+1) -35*d(n+2) ); %CDF(4,6)
5(n-3) = 5(n-3) * K;
d(n-3) = d(n-3) / K;
end
When the same considerations are applied to the end of the signal (the last
three run through of the loop), we get the final function.
for n = 4:N/2-3
s(n+3) = S(2*(n+3)-1) - 1/4*( S(2*(n+3)-2) + S(2*(n+3» );
d(n+2) = S(2*(n+2» - s(n+2) - s(n+3);
s(n) = s(n) - 1/4096*( -35*d(n-3) +265*d(n-2) -998*d(n-l) ...
-998*d(n) +265*d(n+l) -35*d(n+2) );
s(n-3) = s(n-3) * K;
d(n-3) = d(n-3) / K;
end
for k=5:-1:0
s(N/2-k) = s(N/2-k) * K;
d(N/2-k) = d(N/2-k) / K;
end
N = N/2;
d[N-1] = S[2*N-1] - s[N-1];
s[N-3] += (35*d[N-6]-265*d[N-5]+998*d[N-4]+998*d[N-3]-265*d[N-2]
+35*d[N-1])/4096;
s [N-2] ( 5*d [N-4] -29*d [N-3] -29*d[N-2] +5*d[N-1]) /128;
s[N-1] (-3*d[N-2] -3*d[N-1])/16;
for n = N/2-3:-1:4
d(n-3) = d(n-3) * K;
s(n-3) = s(n-3) / K;
s(n) = s(n) + 1/4096*( -35*d(n-3) +265*d(n-2) -998*d(n-1)
-998*d(n) +265*d(n+1) -35*d(n+2) );
S(2*(n+2)) = d(n+2) + s(n+2) + s(n+3);
S(2*(n+3)-1) = s(n+3) + 1/4*(S(2*(n+3)-2) + S(2*(n+3)));
end
for n = 5:-1:1
S(2*n) = d(n) + s(n) + s(n+1);
S(2*(n+1)-1) = s(n+1) + 1/4*(S(2*(n+1)-2) + S(2*(n+1)));
end
S(1) = s(1) + S(2);
170 11. Implementation
N = length(8)/2;
cdf2 = 1/16 * [-3 -3];
cdf4 = 1/128 * [5 -29 -29 5];
cdf6 = 1/4096 * [-35 265 -998 -998 265 -35];
In the two previous sections we have shown how to implement the Daube-
chies 4 and the CDF(4,6) transforms. In both cases the function implementing
the transform consists of a core, in the form of a for loop, which performs
the main part of the transformation, and some extra code, which handles
the boundaries of the signal. While there are many choices for a boundary
handling method (two have been explored in the previous sections), the core
of the transform always has the same structure.
Based on the two direct transforms, Daubechies 4, implemented in Func-
tion 4.4, and CDF(4,6), implemented in Function 4.9, we give an algorithm
for a real time lifting implementation of any transform.
11.5 Filter Bank Implementation 171
1. Write the raw equations in a for loop, which runs from 1 to N/2 (see
Function 4.1).
2. Remove any suffixes by changing 51, 52, and so on to 5, and likewise
with d.
3. Start with the last equation (except for the two scale equations) and find
the largest index, and then change the previous equation accordingly. For
example with CDF(4,6)
d(n) = S(2*n) - s(n) - s(n+1);
s(n) = s(n) - 1/4096*( -35*d(n-3) +265*d(n-2) -998*d(n-1) ...
-998*d(n) +265*d(n+1) -35*d(n+2) );
is changed to
d(n+2) = S(2*(n+2» - s(n+2) - s(n+3);
s(n) = s(n) - 1/4096*( -35*d(n-3) +265*d(n-2) -998*d(n-1) ...
-998*d(n) +265*d(n+1) -35*d(n+2) );
If the largest index is less than n, the previous equation should not be
changed.
4. Do this for all the equations, ending with the first equation.
5. Find the smallest and largest index in all of the equations, and change
the for loop accordingly. For example in CDF(4,6) the smallest index is
d(0-3) and the largest 5(0+3). The loop is then changed to (see Func-
tion 4.7)
for n=4:N/2-3
6. Change the two scaling equations such that they match the smallest
index. In CDF(4,6) this is 0-3, and the scaling equations are changed to
s(n-3) = s2(n-3) * Kj
d(n-3) = d1(n-3) / K;
The following MATLAB function is the main part of the Uvi_ Wave function
wt . m, which performs the wavelet transform. It takes the signal, a filter pair,
and the number of scales as input, and returns the transformed signal. The
function uses the MATLAB function cony (abbreviation of convolution which
is filtering) to perform the lowjhigh pass filtering, and then subsequently
decimates the signal (down sample by two). This is a very easy solution (and
actually corresponds to the usual presentation of filter banks, see for example
Fig. 7.4), but it is also highly inefficient, since calculating a lot of samples, just
to use half of them, is definitely not the way to do a good implementation.
Note that there is no error checking in the function shown here (there is in the
complete wt . m from UvL Wave, though), so for instance a too large value of k
(more scales than the length of the signal permits) or passing S as a column
vector will not generate a proper error. The structure of the output vector R
is described in help wt. The variables dIp and dhp are used to control the
alignment of the output signal. This is described in more detail in Sect. 9.4.3
on p. 116.
The filter bank implementation is well suited for the C language. It is more
efficient to use pointers than indices in C, and the structure of the filter bank
transform makes it easy to do just that. The following function demonstrates
how pointers are used to perform the transform. In this case we have chosen
to use boundary filters instead of periodization. The method of boundary
filters is presented in Sect. 10.3. The construction of these boundary filters is
shown later in this chapter, in Sect. 11.6 below.
To interpret this function a certain familiarity with the C language is
required, since we make no attempt to explain how it works. The reason for
showing this function is that an efficient C implementation typically trans-
forms 1.000 to 10.000 times faster than the various Uvi_ Wave transform im-
plementations.
In this function N is the length of the signal, HLen the length of the
ordinary filters (only orthogonal filters can be used in this function). HA,
GA, and LBM are pointers to the ordinary and boundary filters, respectively.
Finally, EMN is the number of boundary filters at each end. In contrast to the
174 11. Implementation
SigPtr1 = &RetSig[GCP*N/2]i
SigPtr2 = &RetSig[(1-GCP)*N/2];
SigPtr = Signali
*SigPtr2 = *BM++ * *SigPtr++i
for (m = 1; m < EMM-1; m++) *SigPtr2 += *BM++ * *SigPtr++;
*SigPtr2++ += *BM++ * *SigPtr++i
}
if (lfmod(HLen,4»
{
SigPtr = Signal;
*SigPtr1 = *BM++ * *SigPtr++;
for (m = 1; m < EMM-1; m++) *SigPtr1 += *BM++ * *SigPtr++;
*SigPtr1++ += *BM++ * *SigPtr++;
SigPtr = SigPtr1;
SigPtr1 SigPtr2;
SigPtr2 = SigPtr;
}
1* THE ORDINARY WAVELET TRANSFORM (ON THE MIDDLE OF THE SIGNAL). *1
for (n = 0; n < N/2-EMNi n++)
{
SigPtr = &Signal[2*n]i
Hptr HAi
Gptr = GA;
SigPtr = &Signal[EndSig];
*SigPtr2 = *BM++ * *SigPtr++;
for (m = 1; m < EMM-1; m++) *SigPtr2 += *BM++ * *SigPtr++;
*SigPtr2++ += *BM++ * *SigPtr++;
}
if (!fmod(HLen,4))
{
SigPtr = &Signal[EndSig];
*SigPtr1 = *BM++ * *SigPtr++;
for (m = 1; m < EMM; m++) *SigPtr1 += *BM++ * *SigPtr++;
}
The disadvantage of using pointers instead of indices is that the code becomes
difficult to read. This can be counteracted by inserting comments in the
code, but it would make the function twice as long. We have chosen to omit
comments in this function, and simply let it illustrate what a complete and
optimized implementation of a filter bank DWT looks like in C. The original
function dwte has many comments inserted.
There are may types of boundary filters, and we have in Chap. 10 presented
two types, namely the ones we called Gram-Schmidt boundary filters, and
those that preserve vanishing moments. Both apply, as presented, only to
orthogonal filters. The first method is quite easy to implement, while the
second method is more complicated, and it requires a substantial amount of
computation.
Because of the complicated procedure needed in the vanishing moments
case, we will omit this part (note that a MATLAB file is electronically avail-
able), and limit the implementation to Gram-Schmidt boundary filters.
176 11. Implementation
The theory behind this method is presented in Sect. 10.3, so in this section
we focus on the implementation issues only. We will implement the method
according to the way the M and M' matrices in (10.19) and (10.20) were
constructed. The only difference is that we will omit the ordinary filters in
the middle of the matrices, since they serve no purpose in this context.
We start the construction with a matrix containing all possible even trun-
cations of the given filters.
h[l] h[O] 000 0
g[l] g[O] 000 0
end
The first for loop constructs the left matrix, as shown in (11.20), and the
right matrix, followed by a truncation to the last half of the rows. Note that
RBM is upside down. Then the Gram-Schmidt procedure is applied. Here we
take advantages of MATLAB's ability to handle matrices and vectors to do
the sum required in the procedure (see (10.14)). Of course, the sum can
also be implemented as a for loop, which would be the only feasible way
in most programming environments. The normalization is done after each
orthogonalization.
This function only calculates the analysis boundary filters, but since they
are constructed to give an orthogonal transform, the synthesis boundary fil-
ters are found simply by transposing the analysis boundary filters.
It is relatively simple to use the Gram-Schmidt boundary filters. The
matrices constructed with Function 6.1 is multiplied with the ends of the
signal, and the interior filters are applied as usual. To determine exactly
where the boundary and interior filters are applied, we can make use of the
transform in matrix form, as discussed in Chap. 10.
It is a bit more tricky to do the inverse transformation of the signal.
First we note that the matrix form in for example (10.12) results in a mixing
of the low and high pass transform coefficients, as described in Sect. 10.2.
We therefore have two options. Either we separate the low and high pass
parts prior to applying the inverse transform (the inverse transform then has
the structure known from the first several chapters), or we apply a slightly
altered transform, which fits the mixing of low and high pass coefficients. In
the former case we use the ordinary synthesis filters, and since the synthesis
boundary filters are given as the transpose of the analysis boundary matrices
LBM and RBM, they have to be separated, too. In the latter case the ordinary
synthesis filters do not apply immediately (the boundary filters do, though).
We will focus on the latter case, leaving the former as an exercise.
To see what the inverse transform looks like for a transformed signal with
mixed low and high pass coefficients, we first turn to (10.9). We see that the
synthesis filters are columns of the transform matrix, but when that matrix
is applied to a signal, the inner products, the filtering, happens row-wise.
Examining the two full rows, however, we see that the low and high pass
filters coefficients are mixed, which corresponds nicely to the fact that the
signal is also a mix of the low and high pass parts. Therefore, if we use
the two full rows in (10.9) as filters, we get a transform which incorporates
178 11. Implementation
both up sampling and addition in the filters. At least the addition is usually
a separate action in a filter bank version of the inverse transform (see for
instance Fig. 7.2 and Fig. 7.4).
The matrix of inverse transform is given as the transpose of the direct
transform matrix. The synthesis matrix is shown in (10.9) before trunca-
tion. The analysis filters occur vertically in the matrix, but we show them
horizontally below. For instance, if the analysis filters are given by
Note also how these new filters are used both as whole filters and as truncated
filters.
This alternative implementation of the synthesis matrix is also illustrated
in Fig. 11.1. The analysis matrix is given as a number of interior (whole) filters
and the left and right boundary filters. Here the boundary filters are shown
as two matrices. The inverse transform matrix is the transpose of the analysis
transform matrix, and when we consider the transposed matrix as consisting
of filters row-wise, the structure of the synthesis matrix is as shown in the left
matrix in Fig. 11.1. The boundary filters are still given as two submatrices,
which are the transpose of the original boundary filter matrices. This figure
is also useful in understanding the implementation of the direct and inverse
transform in the filter bank version. The Function 6.2 demonstrates the use
of the boundary filters to transform and inversely transform a signal.
N = length(S):
'l. Initialize transform signals
T = zeros (i.N) ;
11.6 Construction of Boundary Filters 179
£-2
[ [
LBM
-h-
] L/2-1
]
." ]
." ]
'"
L,-
,
hr- ]
[ -g- ] l,,- gr - ]
[ -h- ] [ -hr - ]
[ - gr - ]
~
[ -hr - ]
[ - g - ]
[ - gr - ]
[ - h - ] h ' "
[ - r -"J
[ - g - ]
[ - gr -"J
L/2-1 [::~ ]
\.
[
[
,,'
'"
Fig. 11.1. The direct (left) transform matrix is constructed by the left and right
boundary matrices and a number of ordinary, whole filters. The inverse (right)
transform matrix is the transpose of the direct transform matrix, and the structure
shown here is a result of interpreting the matrix as consisting of filters row-wise
T2 = Tj
S2 = T2j
Yo Direct transform with GS boundary filters
T(1:L/2-1) = LBM * S(1:L-2)'j Yo Apply left matrix
T(N-L/2+2:N) = REM * S(N-L+3:N)'j Yo Apply right matrix
for k = 1:2:N-L+1
T(k+L/2-1) = h * S(k:L+k-1)'j Yo Apply interior filters
T(k+L/2) = g * S(k:L+k-1)'j
end
for k = 1:2:L-3
S2(k) = hr(L-k:L) * T2(L/2:L/2+k)'j Yo Apply truncated
S2(k+1) = gr(L-k:L) * T2(L/2:L/2+k)'j Yo interior filters
end
180 11. Implementation
for k = 1+(L/2-1):2:N-L+l-(L/2-1)
S2(k+L/2-1) = hr * T2(k:L+k-l)'; Yo Apply whole
S2(k+L/2) = gr * T2(k:L+k-l)'; Yo interior filters
end
for k = N-L+3:2:N-l
S2(k) = hr(l:N-k+l) * T2(k-L/2+1:N-L/2+1)'; Yo Apply truncated
S2(k+l) = gr(l:N-k+l) * T2(k-L/2+1:N-L/2+1)'; Yo interior filters
end
S2(N-L+3:N) = S2(N-L+3:N) + (RBM' * T2(N-L/2+2:N)')'; Yo Right matrix
function 0 = wpd(S,h,g,J)
N = length(S);
if J > floor(log2(N»
error('Too many levels.');
else if rem(N,2 A (J-l»
error(sprintf('Signal length must be a multiple of 2 A Yoi.',J-l»;
end
o = zeros (J ,N) ;
0(1,:) = S;
end
end
There are two loops in this function. One for the levels in the decomposition,
and one for the elements on each level. Alternatively, the dwt function could
be made to handle more than one element at the time. The electronically
available function dwte takes a number of signals as input, and transforms
each of them. Thus the two for loops in the previous function can be reduced
to
for j=1:J-1
D(j+1,:) = dwte(D(j,:),h,g,2 A (j-1»;
end
The fourth argument gives the number of signals within the signal D(j,:).
There are two different ways to represent a basis in a wavelet packet de-
composition in MATLAB. In UvL Wave the basis is described by a binary
tree, and the basis is represented by the depth of the terminal nodes, start-
ing from the lowest frequency node, located on the left. See the left hand
part of Fig. 11.2. The other representation is given by going through the
entire binary tree, marking selected nodes with 1 and unselected nodes with
0, starting from the top, counting from left to right. This principle is also
shown in Fig. 11.2 In both cases the representation is the vector containing
the numbers described above.
The choice of representation is mostly a matter of taste, since they both
have advantages and disadvantages. In this book we have chosen the second
representation, and the following MATLAB functions are therefore based on
this representation. A conversion function between the two representations is
available electronically, see Chap. 14.
182 11. Implementation
original original
signal level signal
1
2
3
o
4
[1332] [0 . 1 0 . 0 0 0 1 . 0 0 0 0 1 1 0 0]
Fig. 11.2. Two different basis representation. Either we write the level of each
element, starting from the left, or we go through the elements from top to bottom,
marking the selected elements with 1 and unselected elements with 0
20 + 21 + ... + 2 J - 1 = 2J - 1
elements, and we enumerate them as shown in Fig. 11.3. The best basis search
1
2 3
4 I 5 6 7 I
819110111 12113114115
Fig. 11.3. The enumeration of the elements in a full wavelet decomposition with
four levels
uses two vectors, each of length 2J - 1. One contains the cost values for each
elements, and the other contains the best basis, once we have completed the
basis search.
In the following we assume that D is a matrix containing the wavelet
packet decomposition of a signal S of length 2N , down to level J. This de-
composition could for example be the output from Function 7.1. An element
in this decomposition is a vector consisting of some of the entries of a row in
the matrix D. We will need to extract all the elements in the decomposition,
and we therefore need to know the position and length of each element. First,
the level of the element is found in MATLAB by j=floor(log2(k» + 1. As
an example, the elements enumerated as 4, 5, 6, and 7 are on the third level,
and the integer parts of 10g2 of these are 2, so the formula yields j=3. Note
that the levels start at 1 and not 0 (as prescribed by the theory). This is
solely due to MATLAB's inability to use index O. Thus the reader should
11.8 Wavelet Packet Bases 183
keep this change in numbering of the levels in mind, when referring back to
the theory.
Now we find the length of an element on the j'th level as (with j = 1
being the first level)
length of signal = 2N = 2N - j +l
number of elements on the j'th level 2j-l
The vector, which is the first element on the j'th level is then found by
D(j,l:L), where L=2~(N-j+l). The second element is D(j,1+L:2*L), and
the third is D(j ,1 +2*L: 3*L), an so on. Generally, the m'th element at level
j is D(j, 1+(m-l)*L:m*L).
The next step is to find the best basis. We let a vector Basis of the same
length as CostValues represent the basis. The indexing of the two vectors is
the same, that is the elements are enumerated as in Fig. 11.3.
In Fig. 11.4 we have marked a basis with shaded boxes. This basis is then
represented by the vector
Basis = [0 0 1 1 0 0 0 0 0 1 1 0 0 0 0] .
184 11. Implementation
Most cost functions are easily implemented in MATLAB, since they are just
functions mapping a vector to a number. For example, the £P norm is calcu-
lated as sum (abs (a) . -p)-O/p), where a is a vector (an element from the
decomposition), and p is a number between 0 and 00.
The Shannon entropy can be a problem, however, since it involves the
logarithm to the entries in a. If some of these are 0, the logarithm is undefined.
°
We therefore have to disregard the entries. This is done by a(find(a»,
because find(a) in itself returns the indices of non-zero entries. Hence, the
Shannon entropy is calculated as
-sum( a(find(a».A2 .* log(a(find(a».A2)
Note that log in MATLAB is the natural logarithm.
Exercises
11.1 Modify dwthaar such that the transform becomes energy preserving
(see (3.28)-(3.31)), Le. such that norm(Signal) = norm (dwthaar (Signal) )
186 11. Implementation
1
s(l)[n] = S[2n] - 3S[2n - 1] ,
1
d(l)[n] = S[2n + 1] - -(9s(1)[n] + 3s(1)[n + 1]) ,
8
s(2)[n] = s(l)[n] + 361 (3d(1)[n - 1] + 16d(1)[n] - 3d(1)[n + 1]) ,
V2 [n] ,
s[n] = _s(2)
3
3
d[n] = V2d(l) [n] .
1. Write out the transform in matrix form.
2. Show that the corresponding filters are given by
h = -V2
64
[3 -9 -74545 -7 -9 3]
'
V2
g = """8 [-13 -3 1] .
Exercises 187
There are basically three forms for representing the building block in a
DWT: The transform can be represented by a pair of filters (usually low
pass and high pass filters) satisfying the perfect reconstruction conditions
from Chap. 7, or it can be given as lifting steps, which are either given in the
time domain as a set of equations, or in the frequency domain as a factored
matrix of Laurent polynomials. The Daubechies 4 transform has been pre-
sented in all three forms in previous chapters, but so far we have only made
casual attempts to convert between the various representations. When trying
to do so, it turns out that only one conversion requires real work, namely
conversion from filter to matrix and equation forms. In Chap. 7 we presented
the theorem, which shows that it is always possible to do this conversion,
but we did not show how to do it. This chapter is therefore dedicated to dis-
cussing the three basic forms of representation of the wavelet transform, as
well as the conversions between them. In particular, we give a detailed proof
of the 'from filter to matrix/equation' theorem stated in Chap. 7. The proof
is a detailed and exemplified version of the proof found in 1. Daubechies and
W. Sweldens [7].
Equation form:
s[n] = J3-1()
V2 S 2 [n] , (12.5)
Filter form:
1
h = M [1 + J3, 3 + J3, 3 - J3, 1 - J3] , (12.7)
4y2
1
g = M [1- J3, -3 + J3, 3 + J3, -1- J3] (12.8)
4y2
Depending on the circumstances each form has its advantages. In an imple-
mentation it is always either the equation form (when implementing as lifting
steps) or the filter form (when implementing as a filter bank) which is used.
However, when concerned with the theoretical aspects of the lifting theory,
the matrix form is very useful. Moreover, if we want to design a filter via
lifting steps (some basic steps for this were presented in Sect. 3.2 and 3.3),
but use it in a filter bank, we need a tool for converting the lifting steps, in
either matrix or equation form, to the filter form. On the other hand, if we
want to use existing filters as lifting steps, we need to convert the filter form
to the equation form. In brief, it is very useful to be able to convert between
the three forms. Here is a list of where we present the various conversions.
Matrix B equation Sect. 12.2
Matrix -t filter Sect. 7.3
Equation -t filter Sect. 12.3
Filter -t matrix Sect. 12.4
Filter -t equation Sect. 12.4
The only real challenge is converting the filter form to the matrix form, or
the equation form. But first we do the easy conversions.
The factored matrix form (12.1) is closely related to the equation form. Each
2 x 2 matrix corresponding to one equation, except for the first matrix, which
corresponds to the two scale equations. Note that due to the way matrix
multiplication is defined, the steps appear in the reverse order in the matrix
form. The last matrix is the first one to be applied to the two components of
the signal, and the first matrix in the product is the normalization step.
When using the matrix form for transforming a signal, the signal is given
by its z-transform S(z), which is split into its even and odd components and
placed in a vector. So
12.2 From Matrix to Equation Form 191
H(z) [SO(Z)]
Sl(Z)
= [SL(Z)]
SH(Z) ,
where SL(z) and SH(Z) denote the z-transform of the low and high pass
transformed signals respectively. We now apply H(z) one matrix at a time.
where S(1)(z) is the intermediate step notation for So(z) + J3S1(Z). Multi-
plication with the second matrix gives
Finally the scaling matrix is applied. Collecting all the three equations we
have
SCl)(Z) = So(z) + v'3s1 (z) ,
J3 J3-2
D(1)(z) = Sl(Z) - 4S(1)(z) - -4-z-1S(1)(z) ,
S(2)(Z) = SCl)(Z) - ZDCl)(z) ,
S(z) = J3 -1 S(2)(z) ,
v'2
D(z) = V:;;-l D(1)(z).
To get the equation form we use the definition of the z-transform and the
uniqueness of the z-transform representation. The original signal is in the
time-domain given by the sequence {S[n]}. Thus
n n
n n
192 12. Lifting and Filters II
-
d[n] = v'3+1 v'3
..;2 (s[2n + 1] - 4 s(1)[n] -
v'3-2
-4-s(1)[n - 1]) .
where g is the high pass impulse response (12.8) of Daubechies 4 (except for
a change of sign). In the same manner we find
where h is the low pass impulse response (12.7) of Daubechies 4. The rewrit-
ten expressions for s[n] and d[n] show that they correspond to a convolution
of the impulse responses and four samples. As n takes the values from 0 to
half the length of the original signal, a filtering has occurred.
There are two distinct differences between the filter form and the equation
form. Filtering the signal requires approximately twice as many calculations
compared to 'lifting it' (see Exer. 12.1), but the filter form is much more
easily implemented, since the convolution is independent of the structure of
the signal and of the transform. It is unfortunately not possible to have at the
same time both efficient and general implementations of the equation form.
such that
H(z)
K
= [0
0] lIM [10 Sk(Z)]
K- 1 k=l 1
[ 1 0]
Tk(Z) 1 . (12.10)
according to Proposition 7.2.1 det H(z) = a-I z-n for some a -j 0 and n.
Consequently,
(12.12)
Since the degree of the remainder decreases by at least one, it takes at most
Ib(z)1 + 1 steps to achieve a remainder equaling O. This argument proves the
following theorem.
Theorem 12.4.2 (Euclidean Algorithm for Laurent Polynomials).
Given two Laurent polynomials a(z) and b(z) =f. 0, such that la(z)1 ~ Ib(z)l.
Let ao(z) = a(z) and bo(z) = b(z), and iterate the following steps starting
from n = 0
an+1 (z) = bn(z) , (12.13)
bnH(z) = an(z)%bn(z) . (12.14)
Let N denote the smallest integer with N ~ Ib(z)1 + 1, for which bN(Z) = o.
Then aN(z) is a greatest common divisor for a(z) and b(z).
We note that there is no unique greatest common divisor for a(z) and b(z),
since if d(z) divides both a(z) and b(z), and is of maximal degree, then
azmd(z) is also a divisor of the same degree.
This theorem is the key to constructing the 2 x 2 matrix lifting steps,
since each iteration will produce one matrix, as we show below.
It is important to note that q(z) and r(z) in (12.11) are not unique. Usu-
ally there is more than one valid choice. This is easily seen with an example.
Let
a(z) = _Z-I +6 - z .
b(z) = 2z- + 2 .1
By proper choice of c and d we can match at least two of the three terms
(if we could match all three terms we would have an exact division and thus
r(z) = 0). Let us match the two first in (12.15), that is terms z-I and zoo
Then
1 1
c =- 2 and 2(- 2 + d) = 6 {::>
The first step in proving Theorem 12.4.1 is to examine the iterations defined
in Theorem 12.4.2 and rewrite them in the form of a product of 2 x 2 matrices,
whose entries are Laurent polynomials. If we let qn+l (z) = an(z)/bn(z), then
the first step in the algorithm is
al(z) = bo(z) ,
b1(z) = ao(z) - bO(Z)ql(Z) ,
a2(z) = b1 (z) ,
b2(z) = al(z) - bl (z)q2(Z) ,
aN(z) = bN-I(Z) ,
0= bN(Z) = aN-I(z) - bN-I(Z)qN(Z) .
Note that according to the theorem bN(Z) = 0. The first step can also be
written
al(z)]
[ bl(z) -
[01 -ql(Z)
1 ] [a(z)]
b(z)'
Finally we get
[ °
aN(z)] = III [0 -qn(z)
1
1 ] [a(z)]
b(z)
.
n=N
12.4 From Filters to Lifting Steps 197
Note the order of the terms in this product, as given by the limits in the
product. The term with index N is at the left end, and the one with index 1
is at the right end. We now note that the inverse of
qn(Z)
[ 10'
1]
as the reader immediately can verify. Thus we can multiply by these inverse
matrices on the in the equation. Consequently
[~~;~] = IT
N
z
[qni ) ~] [aN~Z)] . (12.16)
Let us now apply this to the low pass filter Ho(z). The polyphase components
of Ho(z) are Hoo(z) and HOl(z), and if we let a(z) = Hoo(z) and b(z) =
H Ol (z) we get
HOO(Z)] = rrN
[H 01 (z)
[qn(z)
1
1] [K0ZC] .
0
(12.17)
n=l
(12.19)
Multiplying Hoo(z) with z-c only shifts the indices in the z-transform, and
hence does not change the fact that it is the even coefficients of the low pass
impulse response. In other words by choosing the right z-transformation of
the low pass impulse response, it is always possible to end up with aN(z) = K.
v'2
8" [ -1262 -1] .
-z -1 + 6 - z 2z + 2)· (1
= (-1 7) -
-2 + 2z 8z , (12.21)
such that
1 7
ql (z)= - 2 + 2z ,
rl(z) = -8z.
The next steps is then
such that
q2 (Z )
1_1
= -41 z-2 - 4z ,
r2(z) = 0 .
Finally
Since b2 (z) = 0, we have found a greatest common divisor of ao(z) and bo(z),
namely a2(z) = -8z. Putting all this into (12.17) yields
HOO(Z)] = [-Z-l +1 6 - z]
[HOl(z) 2z- +2
_[-t + ~z 1]
- 1 0
[-tz-2 -
1
tz-1 01] (12.22)
Unfortunately we did not get a constant in the last vector. This can be
achieved through multiplication by Z-l on both sides
[
_Z-2+ 6z-
1
2z- 2 + 2z- 1
-1] = [-t +1 ~z 01] [-t z - 1 2
- t z - 1 1]
0
[-08] . (12.23)
instead of (12.20) the gcd would have been a constant. Note that choosing a
factorization that does not give a constant gcd is by no means fatal. In fact,
no matter what z-transform we start with, we get the same matrices (provide
that the same matching of terms is used), and the only difference is the gcd.
So if the gcd is not constant, simply keep the coefficient and discard whatever
power of z is present. This is exactly what we just did; the only difference
between the lifting steps (the right hand sides) in (12.22) and (12.23) is that
the z in the former is discarded in the latter.
But this factorization is not our only option. If we had chosen another
matching in the first step, say
means that although the output of the complete transform is never larger than
2 times the input, intermediate calculations has the potential of becoming
at least 3.5 times larger than the input. This may not seem to be a serious
problem. However, for longer filters the values in the intermediate calculations
can becomes significantly larger. In Sect. 12.5 we give another example which
demonstrates this phenomenon. Stated briefly, it is important to choose the
right factorization.
We still have some more work to do before the final factorization is achieved,
and from now on we assume that the factorization is done such that aN(z)
is a constant. The form of (12.19) is not entirely the same as the form of
(12.10). It can be made a little more alike if we observe that
q(Z)
[ 1 0
1] = [10 q(Z)]
1
[0 1] = [0 1] [ 1 0]
1 0 1 0 q(z) 1 .
Using the first equation for odd n, and the second one for even n, gives
g [~q2nl1(z)]
N/2
we get
HOO(Z) H~o(Z)]
[H01 (z) H ll (z)
= IT [1
n=l
0
Q2n-l(Z)] [
1
1 0] [K0 K-01] ,
Q2n(Z) 1
(12.25)
where these equations define Hfo(z) and Hh (z). By transposing both sides
(remember that the transpose of a matrix product is the transpose of each
matrix, multiplied in the reverse order) we get the following result, which is
closer to the goal.
HOO(Z) H01(Z)] _
[Hfo(z) Hfl(z) -
[K0 K-0] IT [10 Q2n(Z)]
1 n=M 1
[ 1 0]
Q2n-l(Z) 1 .
(12.26)
All we need to do now is to find out how Hfo(z) and Hfl (z) are connected
with H lO (z) and H ll (z).
To do this we observe that if the analysis filter pair (Ho(z), Hi (z)) has a
polyphase representation with determinant 1, then any other analysis filter
pair (Ho(z),Hfew(z)) is related by
12.4 From Filters to Lifting Steps 201
[-~Z) ~]
gives
H 0-
- [.!.±.fl ~ 3-0 1-°]
4.,12 4.,12 4.,12 4.,12 .
3+v'3 1-v'3
Hoo(z) = ao(z) = ~4y2
+ ~z
4y2
,
1+v'3 3-v'3
HOl(z) = bo(z) = ~4y2
+ ~z
4y2
.
Remember that the choice of z-transform does not matter for the final fac-
torization (see end of Sect. 12.4.3), and we choose the z-transform with no
negative powers. The first step is to find q1 (z). Since ao(z) and bo(z) have
the same degree, the quotient is a monomial. Matching from the left yields
This time the quotient has degree 1, since b1(z) is one degree less than a1(z).
More specific, q2(Z) most be on the form cz- 1 + d. Matching from the left
means determining c first, and matching from the right means determining
d first. We will do the latter. Thus d, the constant term in Q2(Z), is
3-0 M
d- 4.,/2 3-v3
Z _
- 1-0 z - 4(1 - J3)
.,/2
Since Ib 1(z)1 = 0 we know that r2(z) = 0 (the remainder always has degree
less than the divisor), so we are looking for Q2(Z) such that a1 (z) = b1(Z)Q2(Z).
Consequently,
( 1 + J3 + 3 - J3 z) = 1 - J3 z . (cz- 1 _ J3)
4V2 4V2 V2 4 '
which is valid for only one value of c, namely
!±fl
4.,/2
M
1+v3 2+v3
M
c=--= =---
l=.Y:1 4(1 - J3) 4
.,/2
Therefore
2 + J3 -1
Q2(Z) = - - 4 - Z - 4J3 '
r2(z) =0 ,
1-J3
a2(z) = b1(z) = V2 z.
In order to have the correct high pass filtering, we need to apply (12.27).
First we use (12.26) to find Hfo and Hh. Note that we use 1~z as the
multiplier in this case.
(12.29)
204 12. Lifting and Filters II
(12.30)
and thus
We now insert these H lO and H ll together Hio and Hil from (12.29) into
(12.27), which yields (we skip the intermediate calculations)
-(2 + V3)z
_1(1-v'J
J2 z)2 = z ,
(notice again that we use the multiplier I-Xz) and then entire H(z) can
Wm~
now be reconstructed as
Table 12.1. Note that the inverse transform is the right one, up to the number
of digits used in the numerical computation, since this is how lifting steps
work.
We begin by giving the Coiflet 12 filter taps. They can be found in several
software package (but not in UvL Wave), and in the paper [6, p. 516].
We choose a z-transform representation for the odd and even filter taps
ao(z) = 0.0164z- 2
- 0.0674z- 1 + 0.8127 - 0.0765z 1 + 0.0237z 2 - 0.0018z 3 ,
bo(z) = -0.0415z- 2
and carry out the first step in the algorithm. We choose to match the two
Z-2 terms.
0.0164
ql(Z) = -0.0415 = -0.3952,
Tl (z) = 0.0852z- + 0.9775 -
1
0.1000z 1 + 0.0259z 2 - 0.0021z 3 .
a1(z) = -0.0415z- 2
+ 0.3861z- 1 + 0.4170 - 0.0594z 1 + 0.0056z 2 - 0.0007z 3 ,
b1(z) = 0.0852z- 1 + 0.9775 - 0.1000z 1 + 0.0259z 2 - 0.0021z 3 ,
and the quotient q2(Z) is obviously of the form cz- 1 + d. We have three
options: Either we match both from the left, both from the right, or c from
the left and d from the right. The three cases yield
-0.0415
-0.0415 -1 0.3861 - 0.0852.0.9775
Q2(Z) = 0.0852 z
+ 0.0852
= -0.4866z- + 10.11 ,
1
(12.33)
-0.0007
-0.0007 0.3861 - -0.0021 . 0.0259 -1
Q2(Z) = -0.0021 + 0.0852 z
= 1.5375z- 1 + 0.3418 , (12.34)
Q2
( ) = -0.0415 z -1 -0.0007 =
z 0.0852 + -0.0021
-04866 -1
. z +
0.3418
, (12.35)
206 12. Lifting and Filters II
respectively. Here we see the problem mentioned at the end of Sect. 12.4.3,
namely that some factorizations lead to numerically unstable solutions. In an
effort to keep the dynamic range of the coefficients at a minimum, we choose
to continue with the numerically smallest q2(Z), i.e. the one in (12.35). In
fact, all of the following q's are chosen this way. The next five factorizations
are given by
Since the next step is setting b6(z) = r6(z) = 0, we have now reached the first
index with bn equal to zero. Hence, according to Theorem 12.4.2, we have
found a greatest common divisor of H oo and H 01 , namely a6(z) = b5(z) =
r5(z) = 0.7403. This is also the scaling factor, the K in Theorem 12.4.1, as
was shown in (12.16) and (12.17).
Inserting now into (12.24)
Hoo(z)]
[HOl(z)
= II
N/2
[10 Q2n-l(z)]
1
[ 1 0] [K]
Q2n(Z) 1 0
n=l
reproduces the even and odd part of the low pass filter. By substituting
we also get the two filters Hfo and Hfl in (12.25). These can be converted
to the right high pass filter by means of (12.27). In this case we find
12.6 Factorizing Coifiet 12 into Lifting Steps 207
t(z) = 22.74z- l .
We have omitted the intermediate calculations, since they involve the prod-
ucts of large Laurent polynomials.
It
1
Hoo(z) HOl(z) _ K 0 1 0 1 Q2n(Z) 1 0
[HlO(Z) Hu(z) ] - [ 0 K- l ] [-K 2t(z) 1] [0 1 ] [Q2n-l(z) 1]
2
= [.7403 0 ] [ 1 0] [1 -.0253z - .0218Z ]
o l
1.351 -12.46z- 1 0 1
0] [1 1.480z- + .3648]
l
1
[9.492z- l - 2.017 1 0 1
l
1 0] [1 -.4866z- + .3418] [ 1 0]
[ .1024 + .4941z 1 0 1 -.3952 1 .
which was also valid for the Daubechies 4 factorization (compare (12.31) and
(12.32)). The equations needed for implementing Coiflet 12 is easily derived
from the above matrix equation.
Note that the coefficients in these equations are rounded version of more
accurate coefficients, which are given in Table 12.1. The rounded coefficients
yield a transformed signal which deviates approximately from 0.1% to 2%
from the transformed signal obtained using the more accurate coefficients.
Table 12.1. More accurate coefficients for the Coiflet 12 lifting steps
d(ll[n] -0.3952094886 d(3 l [n] 9.491856450
s(ll[n] -0.4865531265 -2.017253240
0.3418203790 s(3 l [n] -0.02528002562
d(2 l [n] 0.1023563847 -0.02182215161
0.4940618204 d(3 l [n] -12.46443692
s(2 l [n] 1.479728699 s[n] 0.7403107249
0.3648016173 d[n] 1. 350784159
with the numerically smallest, that is (12.35). To see just how bad a factor-
ization can get, we will now repeat the factorization, this time proceeding
with (12.33) instead. Moreover, we choose the left most matching of term
each time. The resulting factors are then
ql(Z) = -0.3952,
Tl (z) = 0.08522z- 1 + 0.9775 - 0.09998z + 0.02590z 2 - 0.002108z 3 ,
q2(Z) = 0.4866z- 1
+ 10.11 ,
T2(Z) = -9.516 + 0.9641z - 0.2573z 2 + 0.02059z 3 ,
Q3(Z) = 0.008956z- 1 - 0.1036,
T3(Z) = -0.002370z - 0.0005804z 2 + 0.00002627z 3 ,
Q4(Z) = 4014z- 1 - 1390 ,
T4(Z) = -1.1695z + 0.05710z 3 ,
2
Exercises
s[n] = 3V2s(2)[n] ,
d[n] = V2 d(2)[n] .
6
Construct the corresponding lifting steps in 2 x 2 matrix form.
12.5 The Symlet 10 is an orthogonal filter, and the IR is given by
1 0.01953888273525 6 0.72340769040404
2 -0.02110183402469 7 0.19939753397685
3 -0.17532808990805 8 -0.03913424930231
4 0.01660210576451 9 0.02951949092571
5 0.63397896345679 10 0.02733306834500
The coefficients can also be generated using symlets from Uvi_ Wave in MAT-
LAB. Convert this filter into lifting steps in the equation form.
A. Jensen et al., Ripples in Mathematics
© Springer-Verlag Berlin Heidelberg 2001
212 13. Wavelets in Matlab
multiresolution function this order is reversed. For the wavelet packets the
situation is even more complicated. The result of a full wavelet decomposi-
tion is a matrix, where each level is stored in a column. The first column is
the original signal, and the last column the final level permitted by a given
signal. However, in graphical output the original signal is at the top, and
the last level at the bottom. So it is important that the reader consults the
documentation for the various function to find out how the output is stored
in a vector or a matrix.
Due to changes in MATLAB in versions 5.x, some functions in version
3.0 of Uvi_ Wave produce errors and warnings. We suggest how to fix these
problems, see Chap. 14.
~:~I _~IUUlUfl~flflflUI!UlUfl"~""'''''~UUlU''~
~
o'~1 l:~
~~
o.~~ o~L-~~~~
...{).2 ...{).J--~-~--~-~ __J
_~f\/\/\/Y\/VS/\M _::~~
3WvWWWWV\!\M
o 100
~~F-----------\J
200 300 400 500 0 100 200 300 400 500
Fig. 13.1. Graphical output from line 1. 9 (left) and line 1.13 (right)
_~I j !:I
t R
1.5
o'~1
f
-1l.5~==:===~==:==
-1o'~t
l.5 H
: B
--~--"'----~--
-1O'~F:
l.5 ~
_~fS2S2SZ\2SJ--~--~-
100 200 300 400 500 0 100 200 300 400 500
Fig. 13.2. Graphical output from line 2.5 (left) and line 2.7 (right)
0.9
:1
-2
nlllll~'''';1~ t.llllllIl!
J
O.B
0.7
'1~111.I;II~II! flU. I
~O.6
~0.5
:E.:~ I
:RF
LL0.4 -2
0.3
0.2 -2 : I
0.1
Fig. 13.3. Graphical output from line 3.3 (left) and line 3.7 (right)
Before going through this section the reader should be familiar with the
concept of a time-frequency plane from Chap. 9, and the function specgram
from the signal processing toolbox for MATLAB.
We have a number of times stressed that h and g are low and high pass
filters, respectively, Le. they can separate (more or less) the low and high
frequencies in a signal. To see what effect this property has on the wavelet
transform, we will now use multires on a signal containing all frequencies
from 0 to half the sampling frequency.
3.1 > close all
3.2 > S = sin([1:2000] .-2/1300);
With a Fourier spectrogram we immediately see that the signal, a so-called
chirp, actually does contain all frequencies.
3.3 > specgram(S) (see Fig. 13.3)
The filter is chosen to be a 16 tap filter, Le. a filter of length 16, from the
Daubechies family, in order to have a reasonable frequency localization.
3.4 > [h,g,rh,rg]=daub(16);
3.5 > Y = multires(S,h,rh,g,rg,4);
3.6 > figure
3.7 > split(y) (see Fig. 13.3)
13.2 Frequency Properties of the Wavelet Transform 217
The left part of Fig. 13.3 shows that the energy is distributed along a line
in the time-frequency plane. This agrees with the linear dependence between
time and frequency in a chirp, which here is obtained by sampling the function
sin(t 2 /1300). The MRA graphs on the right in Fig. 13.3 do not show a linear
dependence. Approximately half of the energy is located in the top graph, a
quarter in the second graph, and so on. Each graph seems to contain about
half of the energy of the one above. This partitioning of the energy comes
from the repeated use of the filters on the low pass part in each step of the
DWT. As a consequence, the relation between time and frequency becomes
logarithmic, not linear.
As another example of the ability of the DWT to separate frequencies, we
look at a signal mixed from four signals, each containing only one frequency,
and at different times. To experiment with another kind of filter, we choose
to use a biorthogonal filter, the CDF(3,15) filter, which is obtained from
4.1 > [h,g,rh,rg]=wspline(3,15);
As explained in Chap. 7, biorthogonal filters do not necessarily have an equal
number of low and high pass filter taps.
4.2 > h
4.3 > g
For our experiment we want four different signals (different frequency content
at different times)
4.4 > 51 = [sin([1:1000]/1000*2*pi*20) zeros(1,1000)];
4.5 > 82 = [zeros(1,1000) sin([1:1000]/1000*2*pi*90)];
4.6 > s3 [zeros(1,1200) sin([1:400]/400*2*pi*2)
zeros(1,400)] ;
4.7 > s4 = [zeros(1,250) ...
sin([1:250]/250*2*pi*125+pi/2) zeros(1,250) ...
sin([1:500]/500*2*pi*250+pi/2) zeros(1,750)];
where s4 contains a high frequency, s3 contains a low frequency, while sl
and 52 have frequencies in between. This can be verified by plotting the four
signals. The plot also shows how the energy is distributed in time.
4.8 > 5ubplot(511)
4.9 > plot(51)
4.10 > 5ubplot(512)
4.11 > plot (s2)
4.12 > 5ubplot(513)
4.13 > plot (s3)
4.14 > 5ubplot(514)
4.15 > plot (54) (see Fig. 13.4)
We combine the four signals by addition.
4.16 > S = 51+s2+53+54;
218 13. Wavelets in Matlab
_~f\l\l\l\l\l\l\l\l\l\l\l\l\l\l\l\l\l\l\l\;~------------------------------
1 r----r----r---....---,--~
01-------------
-1 L - _ - - L_ _- l -_ _L - _ - - - ' - - _ - - - - - l
_~I : : : : : :\/\;,...---:-
_~I :_: _ ' - - - -
o.~
- 0 . 5 .
o 200 400 600 800 1000 1200 1400 1600 1800 2000
Fig. 13.4. Graphical output from lines 4.8 to 4.15, and from line 4.19
To see how the DWT reacts to noise, we will test the MRA on this signal
S both with, and without, noise. Normal distributed random numbers are a
common type of simulated noise.
4.17 > s5 = randn(1,2000)/8;
The probability that randn generates numbers with absolute value larger
than 4 is very small. Division by four leads to a signal s5 with almost all its
values between -0.5 and 0.5.
4.18 > subplot (515)
4.19 > plot (s5) (see Fig. 13.4)
Thus we have the following two signals for our experiments.
4.20 > figure
4.21 > subplot (211)
4.22 > plot(S)
4.23 > subplot (212)
4.24 > plot (S+s5)
Let us first look at the MRA for the signal S without noise.
4.25 > ym1 = multires(S,h,rh,g,rg,5);
4.26 > figure
4.27 > split (ym1)
When interpreting the graphs, it is essential to notice that they have different
vertical scales. If we want the same scale on all graphs, the function set (gca,
... ) is useful (it can be used to alter graphs in many other ways, too).
4.28 > for n=1: 6 (see Fig. 13.5)
subplot(6,1,n)
13.2 Frequency Properties of the Wavelet Transform 219
Fig. 13.5. Graphical output from line 4.28 and line 4.40
The intensity of the noise can be varied by choosing a number different from
10 in the division in line 5.7. As our filter we can choose for example a
member of the CDF family (often called spline wavelets)
5.15 > [h,g,rh,rg]=wspline(3,9);
or near-symmetric Daubechies wavelets, from the symlet family.
5.16 > [h,g,rh,rg]=symlets(30);
Our experiments here use the symlets. Since symlet filters are orthogonal,
the transform used here preserves energy.
To make a wavelet packet decomposition, the function wpk is used. Since
it operates by repeatedly applying wt, and since it always does a full de-
composition, it is relatively slow. This does not matter in our experiments
here. But if one needs to be concerned with speed, then one can use de-
composition functions implemented in C or FORTRAN, or, as we will see
later, one can specify which basis to find. Some results on implementations
are given in Chap. 11, and information on available libraries offunctions for
wavelet analysis is given in Chap. 14. The function wpk is sufficient for our
experiments.
5.17 > Y = wpk(S,h,g,O);
The fourth argument determines the ordering of the elements on each level.
The options are filter bank ordering (0) and natural frequency ordering (1).
The meaning of these terms is described in Sect. 9.3. In this case the ordering
does not matter, since we are only concerned with the amplitude of the
wavelet coefficients (in line 5.29 small coefficients are set equal to zero).
With wpk we get a decomposition of llog2(N)J + 1 levels, where N is the
length of the signal. So wpk(S,h,g,O) returns a 4096 x 13 matrix, since
llog2 (4096)J + 1 = 13, and the first column of this matrix contains the original
signal. Note that the ordering of the graphs in a plot like Fig. 13.6 corresponds
to the transpose of the y obtained from wpk. The ordering of elements in y
is precisely the one depicted in Fig. 8.2(b).
At the bottom level (i.e. in the last column of y) the elements are quite
small, only one coefficient wide. Since they are obtained by filtering the el-
ements in the level above (where each element is two coefficients wide) only
222 13. Wavelets in Matlab
Fig. 13.6. Graphical output from line 5.19 (with symlets 30 from line 5.16) and
line 5.32
2 of the 30 filter taps are used. Hence 28 of the filters taps do not have any
influence on the bottom level, and one should therefore be careful when inter-
preting the lowest level. This also applies (in lesser degree) to the few levels
above it. However, it is still possible to reconstruct the original signal from
these elements, so the lowest levels does give a representation of the original
signal, although it might not be useful in some applications.
A plot of all 13 levels in the same figure would be rather cluttered. We limit
the plot to the first 5 levels here. Note that wpk produces a decomposition in
a matrix, where each column corresponds to a level. With set (gca, ... ) the
time axis is set to go from 0 to 4096, and tick marks are applied at 0, 1024,
2048,3072, and 4096. On the fifth level there are 16 elements (see Fig. 13.6),
four between each pair of tick marks.
5.18 > figure
5.19 > for n=l: 5 (see Fig. 13.6)
subplot(5,1,n)
plot (y(: ,n))
set(gca, 'XLim', [0 4096], 'XTick', [0:1024:4096])
end
Visually, the decomposition of the noisy signal does not deviate much from
the first decomposition.
5.20 > yn = wpk(S+noise,h,g,O);
5.21 > figure
5.22 > for n=1:5
sUbplot(5,1,n)
plot (yn(: ,n))
set(gca, 'XLim', [0 4096], 'XTick', [0:1024:4096])
end
13.3 Wavelet Packets Used for Denoising 223
There is nonetheless an important difference (on all levels but for the sake
of simplicity we focus on the fifth level): While most of the fifth level in the
decomposition of the signal without noise consists of intervals with coefficients
very close to zero, the fifth level in the decomposition of the noisy signal is
filled with small coefficients, which originate from the noise we added to the
signal.
This gives rise to an important observation. The energy of the signal is
collected in fewer coefficients as we go down in the levels. Energy is conserved,
since we have chosen orthogonal filters. Consequently, these coefficients must
become larger. The noise, however, since it is random, must stay evenly dis-
tributed over all levels. Thus due to the energy preservation, most of the
coefficients coming from the noise must be small. The growth of the coeffi-
cients is clearly visible in Fig. 13.6 (note the changed scaling on the vertical
axes). It is therefore reasonable to hope that the signal can be denoised by
setting the small coefficients equal to zero. The property of concentrating
desired signal information without concentrating the noise is important in
many applications.
We have already looked at level 5, so let us look at level 7, for example.
We plot level 7 from the two decompositions in the same figure.
5.23 > figure
5.24 > plot(y(:,7))
5.25 > hold on
5.26 > plot(yn(:,7),'r')
Since there are 4096 points in each signal, the graphs do not clearly show the
differences. By typing
5.27 > zoom
(or by choosing zoom on the figure window menu) we can enlarge a chosen
area of the graph. Mark an area with the mouse, and MATLAB zooms to
this area. By examining different parts of the signals, one gets the impression
that the difference between the two signals is just the noise. Hence after six
transforms the noise remains as noise. This examination also reveals that
setting all coefficients below a certain threshold (between 0.5 and 1) equal to
zero will make the two signal much more alike. To try to determine the best
threshold, we look at the coefficients on the seventh level order according to
absolute value.
5.28 > figure; plot(sort(abs(yn(: ,7))))
The choice of threshold value is not obvious. We have chosen 1, but judging
from the sorted coefficients, this might be a bit to high. To change all values
in yn(: ,7) with absolute value less than or equal to 1 to zero we type
5.29 > yc = yn(:,7) .* (abs(yn(:,7)) > 1);
224 13. Wavelets in Matlab
The part abs(yn(:, 7) »1 returns a vector containing O's and l's. A 0, when-
ever the corresponding value is below or equal to 1, and 1 otherwise. Multi-
plying coefficient by coefficient with yn(: ,7) leaves all coefficients above 1
unchanged, while the rest is changed to zero. Note that . * is coefficient-wise
multiplication and * is matrix multiplication.
Now we want to used the modified seventh level to reconstruct a hopefully
denoised signal. This is done using iwpk. Since this is an inverse transform,
we need to use the synthesis filters (rh and rg).
5.30 > yr = iwpk(yc,rh,rg,0,6*ones(1,64));
The fifth argument passed to i wpk is the basis to be used in the reconstruc-
tion. As we saw in Chap. 8, many possibilities exist for the choice of a basis
(or a representation), when we use a full wavelet packet decomposition. Here
we have chosen the representation given by all elements on the seventh level.
This basis is in Uvi_ Wave represented as a vector of length 64 consisting of
only 6's (given as 6*ones(1,64) in MATLAB), where 6 is the level (counting
from zero) and 64 the number of elements on the seventh level. The basis rep-
resentation notation is described by Fig. 11.2 on page 182, and in Uvi- Wave
by typing basis at the prompt. The reconstruction in line 5.30 is performed
exactly as shown in Fig. 8.3 on page 90.
Now yr contains a reconstructed, and hopefully denoised, signal. Let us
look at the spectrogram of this signal.
5.31 > figure
5.32 > specgram(yr,1024,8192,256,192) (see Fig. 13.6)
5.33 > caxis([-35 35])
5.34 > sound(yr, 8192)
We can visualize our denoising success by looking at the difference between
the original signal and the denoised signal. Ideally, we should only see noise.
Often a (small) part of the signal is also visible in the difference. This means
that we also have removed a (small) part of the signal.
5.35 > figure
5.36 > specgram«S+noise)-yr',1024,8192,256,192)
5.37 > caxis([-35 35])
5.38 > sound(yr'-(S+noise), 8192)
Finally, we can inspect the difference between the original, clean, signal, and
the denoised signal. This is only possible, because the signal in our case is
synthetic; the point of denoising a signal is usually that the clean signal is
not available. Having the clean signal available gives us a chance to examine
the efficiency of our denoising algorithm.
5.39 > figure
5.40 > specgram(yr'-S,1024,8192,256,192)
5.41 > caxis([-35 35])
5.42 > sound(yr'-S), 8192)
13.4 Best Basis Algorithm 225
3 3 4 4 3 2 2
Fig. 13.7. The basis representations basis and b are quite different, and yet they
represent the same basis
It is not difficult to reconstruct the original signal from v, which is the rep-
resentation of the signal in the basis basis. The process is exactly the one
described by Fig. 8.3.
6.23 > 82 = iwpk(v,rh,rg,O,basis);
6.24 > plot (82-8)
The best basis can be presented using the two commands tree and tfplot.
They both take a basis as input arguments. Both types of representations
have been demonstrated in previous chapters. The former relates to the
type of visualization presented in Sect. 3.5, although only wavelet decom-
position is discussed there. The tfplot command shows the corresponding
time-frequency plane without any coloring, like the time-frequency planes in
Fig. 9.11.
6.25 > tree(basis)
13.4 Best Basis Algorithm 229
The first one displays the tiling of the time-frequency plane associated with
basis B, as in Fig. 9.11. The second one displays the basis as a tree graph.
Further explanations are given in the script basis.
Multiresolution analysis. The concept of a multiresolution analysis was ex-
plained in Chap. 4. The relevant commands are
y=multires(S,h,rh,g,rg,k)
split(y)
y=mres2d(S,h,rh,g,rg,k,T)
Here k is the number of scales. The result for a length N signal is a (k + 1) x N
matrix. For k less than 10 the result can be displayed using split (y). The
two-dimensional version works a little differently. The output is selected with
the parameter T. If the value is zero, then both the horizontal and vertical
part of the separable transform used the low pass filter. Other values give
the other possibilities, see the help pages. Note the ordering of the filters in
these functions.
Exercises
14.1 Applications
Wavelets have been applied to a large number of problems, ranging from pure
mathematics to signal processing, data compression, computer graphics, and
so on. We will mention a few of them and give some pointers to the literature.
Data compression is a large area, with many different techniques being used.
Early in the development of wavelet theory the methods were applied to data
compression. One of the first successes was the development of the FBI fin-
gerprint compression algorithm, referred to as Wavelet/Scalar Quantization.
Further information on this particular topic can be found at the URL 2 and
the URL 3.
Let us briefly describe the principles. There are three steps as shown on
Fig. 14.1. The given signal s is transformed using a linear transformation T.
This could be a wavelet packet transform, which is invertible (has the perfect
reconstruction property). The next step is the lossy one. A quantization is
performed. The floating point values produced by the wavelet transform are
classified according to some scheme. For example an interval [Ymin, Ymax] of
values is selected as relevant. Transform values above and below are assigned
to the chosen maximum and minimum values. The interval is divided into
N subintervals of equal length (or according to some other scheme), and the
interval numbers are then the quantized values. (Note that the thresholding
used in Chap. 4 can be viewed as a particular quantization method.) Finally
these N values are coded in order to get efficient transmission or storage of the
quantized signal. The coding is usually one of the entropy coding methods,
for example Huffman coding.
Fig. 14.1. Linear data compression scheme. The signal s is first transformed using
a linear transform T. It is then quantized by some scheme Q. Finally the quantized
signal is coded using entropy coding, to get the result Sc
It is clear from this very short description that there are many aspects beyond
the wavelet transform step in getting a good compression scheme. We refer
to the books [16, 28] for further results, related to wavelet based methods.
Applications to many other areas of science exist. For some examples from
applied mathematics, see the collection of articles [14], and also the book [18].
For applications to the solution of partial differential equations, see [9]. The
collection of articles [1] contains information on applications in physics. The
books [21] and [29] discusses applications in statistics. Applications to me-
teorology are explained at the URL 6. Many other applications could be
mentioned. We finish by mentioning an application involving control theory,
in which one of the authors is involved, see the URL 7.
14.2 Outlook
unstable. Our suggestion is at least initially to rely on the well known or-
thogonal or biorthogonal families, where it is known that these problems do
not occur. If the need arises to construct new transforms using lifting, one
should be aware of the possibility of numerical instability.
The reader having read this far and wanting to learn more about wavelets
is faced with the problem of choice of direction. One can decide to go into
the mathematical aspects, or one can learn more about one of the many
applications, some of which were mentioned above. There is a large number of
books that one can read. But one should be aware that each book mentioned
below has specific prerequisites, which vary widely.
Concerning the mathematical aspects, then the book by 1. Daubechies [5]
might be a good starting point. Another book dealing mainly with math-
ematical aspects is the one by E. Hernandez and G. Weiss [12]. For those
with the necessary mathematical foundations the book by Y. Meyer [17], and
the one by Y. Meyer and R. Coifman [19], together provide a large amount
of information on mathematical aspects of wavelet theory. There are many
other books dealing with mathematical aspects. We must refer the reader
to for example Mathematical Review, were many of these books have been
reviewed.
A book which covers both the mathematical aspects and the applications
is the one by S. Mallat [16] that we have mentioned several times. It is a
good source of information and pointers to recent research. There are many
other books dealing with the wavelets from signal analysis point of view.
We have already referred to the one by M. Vetterli and J. Kovacevic [28]. It
contains a lot of information and many references. The book by G. Strang
and T. Nguyen [24] emphasizes filters and the linear algebra point of view.
The understanding of wavelets is enhanced by computer experiments. We
have encouraged the reader to do many, and we hope the reader has carried
out all suggested experiments. We have based our presentation on the public
domain MATLAB toolbox UvL Wave, written by a number of scientist at
Universidad de Vigo in Spain. It is available at the URL 8. Here one can also
find a good manual for the toolbox. There are some problems in using this
toolbox with newer versions of MATLAB. Their resolution is explained at
the URL II.
For further work on the computer there exists a number of other toolboxes.
We will mention two of them. One is the public domain MATLAB toolbox
WaveLab. It contains many more functions than Uvi_ Wave, and it has been
updated to work with version 5.3 of MATLAB. The many possibilities also
mean that it is more demanding to use. Many examples are included with
the toolbox. WaveLab is available at the URL 9. The other toolbox is the
official MATLAB Wavelet Toolbox, which recently has been released in a new
version. It offers a graphical interface for performing many kinds of wavelet
analysis. FUrther information can be found at the URL 10. There exist many
other collections of MATLAB functions for wavelet analysis, and libraries of
14.3 Some Web Sites 237
for example C code for specific applications. Again, a search of the Web will
yield much information.
Finally, we should mention once more that the M-files used in this book
are available at the URL 11. The available files include those needed in the
implementation examples in Chap. 11, and all examples in Chap. 13. There
is also some additional MATLAB and C software available, together with a
collection of links to relevant material. It is also possible to submit comments
on the book to the authors at this site.
Here we have collected the Web sites mentioned in this chapter. The reader
is probably aware that the information in this list may be out of date by the
time it is read. In any case, it is a good idea to use one of the search engines
to try to find related information.
1. http://www/wavelet.org
2. http://www.c3.1anl.gov/-brislawn/FBI/FBI.html
3. ftp://wwwc3.1anl.gov/pub/misc/WSQ/FBI_WSQ_FAQ
4. http://www.jpeg.org
5. http://www.cselt.it/mpeg/
6. http://paos.colorado.edu/research/wavelets/
7. http://www.beamcontrol.com
8. ftp://ftp.tsc.uvigo.es/pub/Uvi_Wave/matlab
9. http://www-stat.stanford.edu/-wavelab/
10. http://www.mathworks.com
11. http://www.bigfoot.com/-alch/ripples.html
References
Symbols biorthogonal, 23
P,14 - basis, see basis
U,14 - filter, see filter
T a ,22 - transform, 133
T s ,22 biorthogonality, 75
f2(Z), 12 biorthogonality condition, 78
x(w), 101 boundary
SSj_I,53 - correction, 49, 129, 166
Sj, 14 - filter, 128, 134-140, 144-148, 173,
evenj_I,14 175-180
oddj-l, 14 - problem, 49, 127, 127, 128, 165, 231
dj-l, 14, 15, 19 - problem solved with lifting, 165-168
Sj-l, 14, 19 building block, 14, 22, 23, 41, 53, 59,
2D, see two dimensional 79, 87, 129, 165, 166, 189
butter, 229
A Butterworth filter, 34
additivity property, 93
adjustment of grey scale, see grey scale C
affine signal, 17 caxis, 219
algorithm for best basis, see basis CDF, 23, 24, 85, 221, 230, abbr. Cohen,
aliasing, 101 Daubechies, Feauveau
alignment, 116-119 CDF(2,2), 23, 24, 31-34, 46-50, 54-58,
analysis, 22, 48, 72 66, 84-86, 113, 145, 146, 197
asymmetry, see symmetry CDF(2,4), 132
CDF(3,1), 86
B CDF(3,3), 186, 187
basis CDF(3,15), 217
- best, 93-96, 120, 126, 183-185 CDF(4,6), 113-115, 129, 146, 155,
- best basis search, 93-96, 125, 158-160, 164-171
225-230 CDF(5,3), 209
- best level, 96,111-113,117,120,126 change of basis, 89
- biorthogonal, 74-75, 78 chirp, 33, 111, 112, 114, 116, 119, 126,
- canonical, 38, 75, 89 216, 217, 220
- change of, 89 choice of basis, see basis
- choice of, 89-96, 120, 224 Coiflet 12, 204-208
- in software, see basis, representation Coiflet 24, 118, 119
- near-best, 93 Coiflets, 85
- number of, 91-93 colorbar, 220
- orthonormal, 74, 75, 78 completeness, 74
- representation, 181, 224-226 complexity, 39, 94, 193, 209
basis, 226 components
best basis, see basis - even, see even entries
242 Index
- odd, see odd entries energy, 40, 62, 80, 96-98, 102, 106, 140,
compression, 8, 16, 97, 110 213, 214, 217, 223
concentration, 96, 98, 229 - center, 118
continuous vs. discrete, 100-101 - color scale, 106
conv, 173 - concentration, 229
convolution, 1, 63, 66, 69, 74, 76, 103, - density, 121, 122
115, 118, 130, 147, 172, 193, see also - distribution, 102, 105, 121, 213, 217
filter - finite, 11, 12, 40, 69
correction, 14 entropy, 96-98, 120, 125, 126, 185, 225,
correlation, 7, 14, 52 226, 229, 231
cost function, 90, 93-94, 96, 98, 120, equation form, 23-24
126, 183, 185, 225, 226, 229, 231 error, 155
- examples of, 96-98 Euclidean algorithm, 194, 195
- Shannon entropy, see entropy even entries, 14, 15, 59, 65, 66, 190, 202
- threshold, see threshold
cyclic permutation, 157, 159 F
factorization, 73, 194, 196, 197, 199,
D
200, 202, 204, 206-209
daub, 212, 230
features, 7, 8, 10, 14
Daubechies 2, see Haar transform
filter, 61, 69, 74, 190, 192-194
Daubechies 4, 20, 41, 45-47, 83-85,
111-115,127,128,146,155-164,170, - biorthogonal, 85, 114, 132, 142, 217,
230
171, 186, 189, 192, 193, 202-204, 209
Daubechies 8, 212, 215 - CDF(2,2), 84
Daubechies 12, 113, 114, 116, 119 - Coiflet 12, 205
Daubechies 16, 216 - Daubechies 4, 83, 202
Daubechies 24, 118, 119 - Haar transform, 82
Daubechies filters, 85, 113, 114, 212, - low pass, 70
230 - orthogonal, 78-82, 85, 114, 118, 131,
decomposition, 22, 54, 57, 87, 88, 132, 136, 148, 173, 175, 209, 212, 221,
89-96, 103, 104, 106, 107, 109-113, 223, 230
115, 117, 119, 129, 146, 152-154, - Symlet 10, 209
180-183, 185-187, 212-215, 221-226, - taps, see impulse response
228-230 filter, 229
degree, see Laurent polynomial filter bank, 68, 69-74, 76-80
denoise, 28, 31, 33, 110, 220-225, 229, filter bank ordering, 110, 112, 221, 231
see also noise finite energy, see energy
details, 7 finite impulse response, 69, 80
determinant, 68, 71, 143, 193, 194, 200, finite sequence, see finite signal
201 finite signal, 11, 12, 18
diagonal lines, see image FIR, abbr. finite impulse response
difference, 7, 10, 12, 13, 15 first moment, see moment
directional effect, see image Fourier spectrogram, see spectrogram
discrete signal, 11 Fourier transform, 39, 61, 99, 100, 103,
discrete vs. continuous, 100-101 123
DWT, abbr. discrete wavelet transform frequency
DWT building block, see building block - content, 99-101, 109, 110, 112, 113,
DWT decomposition, see decomposi- 116, 125, 217
tion - localization, 111-114, 124, 216, 219
- ordering, 109, 110, 112, 221
E - response, 69, 83-85, 113, 114
element, 10, 87, 88, 89, 91, 92, 94-97, function, 151
103, 107, 109-112, 129, 136, 153, 154, fundamental building block, see
181-184, 221, 224, 226, 227 building block
Index 243
- of energy, 14, 69, 80, 81, 86, 96-98, short time Fourier transform, 99, 121,
136, 145, 148, 185, 186, 221, 223, see 122, 219
also energy signal, 12
- of length, 134, 141 - affine, see affine signal
- of mean, 14, 16, 59 - linear, see linear signal
- of moment, 18, 24, 128, 144-148, 175 - synthetic, 25-34, 53
- of perfect reconstruction, 128, 129, size, 155
134 sort, 223
- of time localization, 116 sound, 221
procedure specgram, 216
- prediction, see prediction spectrogram, 121-124, 216, 219, 220,
- update, see update 224
pruneadd, 225, 231 spline wavelet, 221
split, 14
Q split, 213, 232
quincunx lattice, 60 stability, 75
quotient, 194, 202, 203, 205 STFT, abbr. short time Fourier
transform
R structure, 7, 14
randn,218 subplot, 215
random numbers, see noise Symlet 12, 126
reconstruction, 7-9, 31, 32, 38, 43, 58, Symlet 30, 221
66, 72, 89, 90, 129, 132, 185, 214, symlets, 221
224, 228 symmetry, 85, 100, 107, 113, 116, 136,
regularity, 46 139, 141, 144, 149, 198, 221
rem, 155 synthesis, 22, 72
remainder, 194, 195, 199, 202, 203 synthetic signal, see signal
rescaling, see normalization
right boundary filter, 140, 176
T
S tfplot, 228, 231
sampling, 11, 42, 43, 100, 101, 111, 112, theorem
123, 146-148 - Euclidean algorithm, 195
- frequency, 100, 112, 114, 216, 220, - factorization of polyphase matrix, 73,
229 193
- rate, 100, 102, 116, 121, 124 threshold, 8, 9, 94, 96-98, 223, 224
- theorem, 100 time localization, 111, 114-116, 219
sampling theorem, 100 time shift, see shift in time
scale, 22, 23, 28, 38, 39, 48, 88, 129, time-frequency plane, 96, 102-107,
172, see also level 109-114, 116, 117, 119, 120, 122,
scaling, 42, 43, 46, 161, 164-166, 124-126,185,216,217,228,231
171, 191, 198, 199, 206, see a~o transform
normalization - 'in place', see 'in place'
scaling function, 42, 43, 46, 48, 50 - Daubechies, see Daubechies
- CDF(2,2), 48 - Haar, see Haar transform
script, 151 transient, 213-215
separable, 51, 53, 57, 144, 231, 232, 234 translation, 39, 42, 43, 46-48
sequence, 12 tree, 228, 231
set, 222 truncate, 135, 137, 139, 144, 149, 178
shanent, 225, 231 two channel filter bank, see filter bank
Shannon entropy, see entropy two dimensional
Shannon's sampling theorem, 100 - Haar transform, 53-54
shift in time, 63-65, 73, 79, 119, 135, - transform, 51-60
162 two scale equation, 171, 190
246 Index
W Z
wavelet, 42, 43, 46-49 z-transform, 62-63
- CDF(2,2), 49 zero index, 11
- Daubechies 4, 46, 47 zero padding, 10, 21, 49, 128-130, 134,
wavelet filter, see filter 135, 140, 141, 145
wavelet packet, 81-90, 103, 106-111, zeros, 152, 215
113, 119, 129, 180-185, 212, 220, 221, zeroth moment, see moment
224, 225, 229, 231 zoom, 223