the fast wavelet transform (fwt)

72
The Fast Wavelet Transform (FWT)

Upload: others

Post on 03-Feb-2022

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The Fast Wavelet Transform (FWT)

The Fast Wavelet Transform (FWT)

byKeith G. BoyerB.S.E.E.T., DeVry Institute of Technology, 1984A thesis submitted to theUniversity of Colorado at Denverin partial fulfillmentof the requirements for the degree ofMaster of ScienceApplied Mathematics1995

Page 2: The Fast Wavelet Transform (FWT)

This thesis for the Master of Sciencedegree byKeith G. Boyerhas been approved by

William L. Briggs William E. Cherowitzo Weldon A. Lodwick

Date

Page 3: The Fast Wavelet Transform (FWT)

Boyer, Keith G. (M.S., Applied Mathematics)The Fast Wavelet Transform (FWT)Thesis directed by Professor William L. BriggsABSTRACT

A mathematical basis for the construction of the fastwavelet transform (FWT), based on the wavelets ofDaubechies, is given. A contrast is made between thecontinuous wavelet transform and the discrete wavelettransform that provides the fundamental structure for thefast wavelet transform algorithm. The waveletsconsidered here lead to orthonormal bases. To realizethe orthonormality of these bases, the Fourier transformis used to construct equivalent realizations of thewavelet recursions in the spectral domain. Thesespectral representations lead to a complementary pair offilter transfer functions, from which the inverse Fourier transform can be used to generate equivalent Daubechies'convolution coefficients. The discrete wavelettransform, generated from the convolution filteroperations, is incorporated into a recursive filterdecimation algorithm that is the FWT. Finally, the FWTis applied to the image compression problem. This abstract accurately represents the content of thecandidate's thesis.

Signed William L. Briggs

Page 4: The Fast Wavelet Transform (FWT)

ContentsChapter1. Introduction . . . . . . . . . . . . . . . . . . . . . 11.1 Wavelets and Signal Analysis . . . . . . . . . . . . . 11.2 The Continuous Wavelet Transform . . . . . . . . . . . 21.3 Discretization of the Continuous Wavelet Transform . . 52. Multiresolution Approximations . . . . . . . . . . . . 72.1 Wavelet and Scaling Function Coefficients . . . . . . 112.2 Orthonormality of Compactly Supported Wavelets . . . . 122.3 Bi-Orthogonal Decomposition . . . . . . . . . . . . . 162.4 z-Transform and Filter Coefficients . . . . . . . . . 193. Daubechies' Construction . . . . . . . . . . . . . . . 223.1 Spectral Factorization of |Q(>)| . . . . . . . . . 272 3.2 Daubechies' Examples for N=2 and N=3 . . . . . . . . . 294. Fast Wavelet Transform (FWT) . . . . . . . . . . . . . 344.1 The FWT Algorithm . . . . . . . . . . . . . . . . . . 454.2 The FWT and Image Compression . . . . . . . . . . . . 464.3 The FWT Image Compression Algorithm . . . . . . . . . 48AppendixA. Matlab Code and Compression Images . . . . . . . . . . 52References . . . . . . . . . . . . . . . . . . . . . . . . 66

Page 5: The Fast Wavelet Transform (FWT)

1

1. Introduction1.1 Wavelets and Signal AnalysisA signal may exist in its original form as acontinuous entity. This continuous signal may then beconverted into a quantized form as a sequence of sampledvalues that describe the signal at discrete points intime. A signal may also be generated in its original formas a discrete sequence. Images and audio signals areexamples of signals that originate in a continuous form,and are stored as discrete sequences on compact disks.These signals may also be generated directly as discretesequences. Signal analysis is born out of the need tounderstand the composition of both discrete andcontinuous signals. This analysis usually takes the formof a sub-space decomposition into a linear combination ofbasis functions. The classic decomposition tool is theFourier transform, which decomposes a signal into alinear combination of complex exponential functions(equivalently, sines and cosines).The concept of signal stationarity plays a key rolein determining the effectiveness of the signaldecomposition obtained from the Fourier transform. Thestationarity of a signal is judged by its statisticalinvariance over time. If the probability of a signalbeing a certain value is constant over time, then thesignal is said to be stationary. If, however, transientstatistical events occur that cannot be predicted, thesignal becomes nonstationary. Due to the periodic natureof the Fourier transform, it is ideal for thedecomposition and analysis of stationary signals. On theother hand, transient nonstationary signals require abasis that is more localized in both time and frequency. To see how the Fourier transform is not localized in timeand frequency, consider the transformation of a squarepulse in the time domain. The Fourier transform of this

Page 6: The Fast Wavelet Transform (FWT)

2

(1.1)

(1.2)

pulse is a sinc (sin(x)/x) function in the spectraldomain, a function for which the energy is clearly notlocalized. As for the time domain, the periodic basisfunctions of the Fourier transform are clearly notlocalized [5]. Wavelets solve this problem by having a prescribedsmoothness, with energy that is well-localized in bothtime and frequency. In general, not only do waveletsrequire fewer basis functions than trigonometric basisfunctions, but the well-localized nature of the waveletbasis ameliorates such reconstruction anomalies as theGibbs' phenomenon [9]. To understand the wavelet basis,we will consider a continuous transformation in L (ú). 21.2 The Continuous Wavelet TransformThe wavelet basis is a family of functions based ona well-localized oscillating function R(t) of the realvariable t. R(t) is called the "mother wavelet" becauseall other wavelet functions within the family aregenerated from translations and dilations of R(t). Actually, the mother wavelet R(t) is the function withzero translation and a dilation of 1. Equation (1.1)shows the family of functions generated from R by translation and dilation . In (1.1), b is thetranslation variable and a is the dilation variable.

A simple example of a wavelet might be the Mexicanhat functionThe mother wavelet of (1.2) is the solid function isthe center of figure (1.1), together with two translateddilations.

Page 7: The Fast Wavelet Transform (FWT)

-15 -10 -5 0 5 10 15-1

-0.5

0

0.5

1

1.5

3

Figure 1.1: Translations anddilations of R(x).

(1.3)

A restriction on R(t) is that it have a zerointegral. Actually, for reasons we will discover later,a further restriction on R(t) requires that the first m+1moments vanish. This gives us condition (1.3), a seriesof integral moments equal to zero.

Figure (1.2) shows plots of the integrands of (1.3)as an example of the vanishing moments of R(x) in (1.2). In this case, if we consider the integral of thefunctions in figure (1.2), moments 0 and 1 vanish, whilemoment 2 does not.

Page 8: The Fast Wavelet Transform (FWT)

-10 -8 -6 -4 -2 0 2 4 6 8 10-2

-1.5

-1

-0.5

0

0.5

1

Moment 0

Moment 1

Moment 2

4

Figure 1.2: Moments of (1.2)With a mother wavelet R meeting the restriction of(1.3), a corresponding set of functions {R } in the formabof (1.1) can be considered. The translation and dilationparameters a,b will range over a continuous set S, suchthat the set of functions {R } has sufficient cardinalityabto allow any function f in L (ú) to be reconstructed from2the coefficients of the wavelet transform defined by theinner product of f and R , <f,R >. The inner product ofab abthe vector space L (ú) of square-integrable, measurable2functions is defined by

The inner product can be used to define the continuouswavelet transform F(a,b) of f 0 L (ú) as2

for f,R 0 L (ú).2

Page 9: The Fast Wavelet Transform (FWT)

5(1.4)

This is the analysis of the function or signal that isthe motivation for the construction of the waveletfamily. The synthesis of f(x) from F involves a linearcombination of the original wavelets using thecoefficients of F(a,b). The synthesis or inversionformula is given by

These formulas, from a historical perspective, areinteresting in that they show the basic analysis involvedin the early development of wavelets. However,continuous analysis is usually impractical, which gaverise to discrete solutions of the wavelet analysisproblem. For an extensive historical perspective,reference [5] is very complete.1.3 Discretization of the Continuous Wavelet TransformFor the same reasons that we discretize differentialequations, we will consider a discretization of thecontinuous wavelet transform in the (a,b) plane. Thisdiscretization will allow for numerical solutions basedon a summation rather than a continuous integral. Obviously, many possible discretizations of thecontinuous (a,b) plane exist. However, only certainrestrictions on (a,b) will give the desired basisfunctions {R }. One classic choice for restricting (a,b)abis a binary discretization that leads to the wavelets ofDaubechies [2]. This binary discretization sets a=2 and-jb=ak, where j,k 0 Z. The discretization of F(a,b) thenbecomes F(2 ,2 k), j,k 0 Z, where the corresponding-j -jdiscrete wavelet functions are defined by

Page 10: The Fast Wavelet Transform (FWT)

6

Equation (1.4) is one of three formal definitions of awavelet [5]. To introduce further wavelet definitions,we must first define the Fourier transform. The Fouriertransform of the function f in L (ú) is 2

The inverse Fourier transform is the expression

With the Fourier transform pair defined, we can considerthe formal wavelet definitions. (1) A wavelet is a function in L (ú) whose Fourier2transform satisfies the condition almosteverywhere, (continuous sense).(2) A wavelet is a function in L (ú) whose Fourier2transform satisfies the condition almosteverywhere, (discrete sense).(3) A wavelet is a function in L (ú) such that 2is an orthonormal basis for L (ú).2From definitions (2) and (3) above, we can see thateach subspace is defined by an integer power of 2. Theseinteger subspaces form a nested sequence of subspaces ofL (ú) known as a multiresolution analysis2(approximation), which is the subject of the nextchapter.

Page 11: The Fast Wavelet Transform (FWT)

7

(2.1)

2. Multiresolution ApproximationsThe construction of the fast wavelet transform (FWT)begins by splitting L (ú) into a sequence (V ),j 0 Z, of2 jclosed subspaces, each of which is spanned by anorthonormal basis of translates of a single function N, such that the following properties hold [14].

Given the properties for the basis of V above, wejcan define an approximation of a function f(x) 0 L (ú),2at the resolution 2 , as the orthogonal projection ofjf(x) onto V . This is an orthogonal projection becausejeach basis function involved in the approximation of f(x)is orthogonal to every other. The construction of theorthogonal projection above begins by finding a uniquefunction N(x) 0 L (ú). 2A wavelet basis, related to N(x), then evolves fromthe additional information of an approximation at aresolution 2 compared with the resolution 2 . Thisj+1 jadditional information is just the projection of theorthogonal complement of V in V . That is, V = V r W ,j j+1 j+1 j jwhere W is the space defined by the projection of thejorthogonal complement of V in V . The space W will bej j+1 j

Page 12: The Fast Wavelet Transform (FWT)

8

(2.2)spanned by the wavelet orthonormal basis defined by

We can summarize the relationship of these subspacesat every level by

To understand the projection of f onto any of theparticular subspaces, let's consider the simple Haarbasis defined by

N(x) is known as the scaling function or father wave. N(x) is a solution to the dilation equation

for a finite number of non zero coefficients (For theHaar basis, c = c = 1). The corresponding wavelet or0 1mother wave is defined by

For the same finite set of coefficients {c }, thencorresponding Haar wavelet is R(x)=N(2x)-N(2x-1), whichis given explicitly by

Page 13: The Fast Wavelet Transform (FWT)

9

Figure 2.1: The Haar scalingfunction N (top) and the Haarwavelet R (bottom).

Figure (2.1) shows the Haar scaling function N(x) andcorresponding wavelet R(x). This is one of the onlywavelet functions that can be described explicitly. Thewavelets that we will see throughout the rest of thiswork are recursively defined. As such, they cannot beviewed in the usual way. In later chapters we will seehow to view these recursive functions.

If we consider the projection of a function f ontothe Haar basis at two resolutions, we would get figure(2.2).

Page 14: The Fast Wavelet Transform (FWT)

f

Proj. V_0

Proj. V_1

10

Figure 2.2: Some f(x) and itsprojection onto V and V ,0 1spanned by two resolutions ofthe Haar basis.In figure (2.2), f is projected by the scaling functionN(x) onto V . But we know that V d V ; that is, V is a0 0 1 1higher resolution than V . This explains why the0projection of f onto V is more accurate than the1projection onto V . It is also important to realize that0since V d V , the projection of f onto V can exist in V ,0 1 0 1but the projection of f onto V cannot exist in V . 1 0We briefly introduced the scaling function andrestrictions on the coefficients {c } in the abovenexample. We will now develop restrictions on the waveletand scaling function coefficients more formally.

Page 15: The Fast Wavelet Transform (FWT)

11

(2.3)

(2.4)

2.1 Wavelet and Scaling Function CoefficientsWith V d V and N(x) 0 V ZY N(2x) 0 V , itj j+1 j j+1follows that for some set of coefficients {c }, N(x) cannbe written as a linear combination of N(2x),Alternatively, if we consider equation (2.3) written as alinear combination of N(x) in the scaled form defined inequation (2.1), the recursion for N(x) can be written interms of a new set of coefficients {h } asnso that

To normalize N(x) we require , from which

This gives us a requirement on what will become the setof filter coefficients {h }. In a later derivation, thisnrequirement will become an integral part of thenormalization of the filter transfer functions thatdefine the multiresolution analysis.

Page 16: The Fast Wavelet Transform (FWT)

12

(2.5)Now that we have defined N(x), R(x) can be expressedso that it is orthogonal to N(x), namely

To make R(x) orthogonal to N(x), we require so that the coefficient set {g } is orthogonal to {h },n ni.e., h g = 0.tFrom equation (1.3) of the introduction, we requiredthat the zero moment or the mean of R(x) equal zero(vanish). From this condition, we can derive thefollowing requirement for the filter coefficients {g }.n

2.2 Orthonormality of Compactly Supported WaveletsAt this point, we have defined two basis functions:N(x) and R(x). The problem now becomes how to pick thecoefficients {h } and {g } to ensure that the functionsn nN(x) and R(x) form orthonormal bases. To answer thisquestion, we will turn to the Fourier transform. Thespectral representation of these functions greatlysimplifies the analysis of orthonormality.To construct the spectral representation of thesebasis functions, we start with the multiresolutionanalysis defined by the filter coefficients {h },n

Page 17: The Fast Wavelet Transform (FWT)

13

(2.6)(2.7)

Using the following properties of the Fourier transform,

with a=2 and t =n, the Fourier Transform of N(x) is0

As such, we can define a transfer function m (>) so that0

whereThe transfer function m (>) is 2B-periodic in0L ([0,2B]). As we will see later, the construction of2m (>) will yield a low pass filter corresponding to the0scaling function N(x), and a complementary high passfilter m (>) corresponding to R(x). This low pass/high1pass relationship makes sense because R(x) evolved fromthe additional information of an approximation at aresolution 2 compared with the resolution 2 . Thej+1 jadditional information can be looked at as a high passoperation, namely the change between two resolutions. Asa function of time, N(x) and R(x) will provide analysisthrough convolution operations. Because convolution inthe time domain is equivalent to multiplication in thespectral domain, the convolution operations will beequivalent to multiplication by m (>) and a complementary0

Page 18: The Fast Wavelet Transform (FWT)

0 1 2 3 4 5 6 70

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

M0

M1

14

Figure 2.3: Low pass filterm (>) and complementary high0pass filter m (>), in the1frequency domain.

(2.8)

filter m (>), which will be developed later. Figure1(2.3) shows the relationship of the complementary highpass/low pass 2B-periodic filters m (>) and m (>). 0 1

Finally, what are the necessary and sufficientconditions that will ensure that {N } forms ankorthonormal basis? To begin this construction, considerthe definition of orthogonality in L (ú). If the scaling2function N(x) forms an orthonormal basis, then

or equivalently

Page 19: The Fast Wavelet Transform (FWT)

15

To take the Fourier transform of (2.8), we turn toParseval's theorem.Theorem 2.1 (Parseval):

where X(f) and Y(f) are the Fourier transform of x(t) andy(t), respectively.By this theorem, the integrand becomes . By the delay property of the Fourier transform, the timeshift of (-k) results in a phase shift term e . Theik>Fourier transform of the right side is 1, by the propertythat the Fourier transform of the delta function equals1. Consequently, taking the Fourier transform of (2.8)yields

It follows that

Evaluating the integral, we see that

Page 20: The Fast Wavelet Transform (FWT)

16

(2.9)

Now, with reference to (2.6)

and

Since m is 2B-periodic, we can split the sum into odd and0 even k, which gives us

Again, becausewe havea necessary condition on m (>) given that N is0 o,northonormal.2.3 Bi-Orthogonal DecompositionAs stated earlier, the space W spanned by R evolvedj jfrom the additional information of the approximation atthe resolution 2 compared with the resolution 2 . Inj+1 jterms of the spaces spanned by N and R , this becomes Wj j jr V = V or V = V r W . This implies that anyj j+1 j j-1 j-1function f(x) 0 V can be decomposed in terms of the bi-jorthogonal spaces at resolution (j-1). With respect tothe Fourier transform of f(x), this decomposition can bestated as follows.

Page 21: The Fast Wavelet Transform (FWT)

17

Since N forms a basis, we can express f(x) as ajlinear combination of N,The Fourier transform of f(x) iswhereis a 2B-periodic function. For the purpose of thisdecomposition we define

for the coefficients {h } and {g } defined previously (Wen nuse H(>) instead of m (>) here for ease of discussion). 0If we recall that V = V r W , we can decompose0 -1 -1into the next lower resolution for some B-periodic functions b(>) and c(>) as

Substituting

Page 22: The Fast Wavelet Transform (FWT)

18

we getFrom this decomposition, a paraunitary linear system canbe constructed, through which a necessary condition forthe operator of this linear system can be realized. From a(>) = b(>)H(>) + c(>)G(>) the following linearsystem can be constructed,

Here we need to show that

is unitary (U U = UU = I), so that* *

This is a necessary condition so that if U is thetransform operator for the fast wavelet transform, U is-1just U . If U is unitary, then*

Page 23: The Fast Wavelet Transform (FWT)

19

Consequently, the system is unitary ifandActually, all the diagonal elements need to be 1 and theoff diagonal elements need to be 0, so that U is unitary. However, only the elements listed are necessary due tothe 2B-periodicity and symmetry of H(>) and G(>).2.4 z-Transform and Filter Coefficients At this point, from equation (2.7), we can defineH(>) in terms of m (>) as 0That is, H(>) is the Fourier transform of the filtercoefficients {h }. Similarly, G(>) is defined as thenFourier transform of the filter coefficients {g ). nTherefore, we can look to the definition of the filtercoefficients {g ) provided in (2.5), where, because R(x)nis defined as the orthogonal to N(x), g = (-1) h . n 1-nn *From this definition, we can use the z-transform todefine a suitable solution for G(>). First consider that R(x) is, in reality, defined interms of a finite sequence, so that equation (2.5)becomes

Page 24: The Fast Wavelet Transform (FWT)

20

(2.10)From this, we can re-define {g ), as a re-indexed finiteksequence, as g = (-1) h , k=0,1,2,...,2N-1 (here h =h,k 2N-1-k k *since h is real). Now let z = e , and define thei>following z-transform properties (here 76 denotes thetransform, Z{f } = F).k

From these properties, it follows that

But, we know that e = e e = -z, and F(z )=F(z ). i(>+B) i> iB -1 *From this, if we let F(z)=m (z)/m (>), we can define m (>)0 0 1in terms of m (>):0

Restated, the paraunitary high pass/low pass filter pairare defined by

Page 25: The Fast Wavelet Transform (FWT)

21

where

Putting this all together, if we define m (>) such0that H(>) and G(>) form a paraunitary filter pair (i.e.,such that the linear transformation matrix U, constructedof H(>) and G(>), is unitary), then the IFFT (InverseFast Fourier Transform) can be used to generate thesequence of filter coefficients {h } and , therefore,n{g }. The following construction and examples willnhopefully clarify this entire process.

Page 26: The Fast Wavelet Transform (FWT)

22

(3.1)

3. Daubechies' ConstructionThe construction of the Daubechies' orthonormalwavelet basis ([1][2]) begins with the concept ofregularity and vanishing moments. Now that have definedm (>) and its relationship to the Fourier transform of1the filter coefficients {g } k

from (2.6) the Fourier transform of (2.10) becomes

Equation (1.3) puts the restriction on R(t) that thefirst m+1 moments vanish. We must show that thisrestriction implies mth order differentiability of . This differentiability will lead to a uniquefactorization of m (>), which will be needed in the0construction of the Daubechies' wavelet basis. First,consider the Fourier transform of R(t),

The first derivative with respect to > yields

Continued differentiation within the integral gives

Page 27: The Fast Wavelet Transform (FWT)

23

(3.2)

(3.3)

so that

Now, from (1.3) From this condition, (3.2) becomes

But we know that

Therefore, with (3.3) showing mth order differentiabilityat >=0, we have that m is m times differentiable at >=B:0

This implies that m has a zero of order m+1 at >=B. At0this point, we factor m (>) into a polynomial R(>) that0

Page 28: The Fast Wavelet Transform (FWT)

24

(3.4)

is the multiple zero at >=B and another polynomial Q(>),such that m (>) = R(>)Q(>) (where R is order N=m+1 and Q0is order m). To construct R(>), we realize that whennormalized m (0)=(1) Q(0), and m (B)=(0) Q(B). This0 0m+1 m+1gives the following factorization of m (>), 0

This factorization is important because it allows for thedevelopment of the polynomial Q in z=e , from which thei>polynomial m in z can be realized directly from the0factorization of (3.4).We now have everything necessary to develop atrigonometric polynomial for

such thatFirst, consider the factorization for m (>):0

From this representation, it follows that

With the coefficients of |Q(>)| being real, it can be2written as a real polynomial in cos(>), or equivalentlyas a polynomial P in sin (>/2). Letting y = sin (>/2) =2 2

Page 29: The Fast Wavelet Transform (FWT)

25

(3.5)

(1-cos(>))/2, we can write

as a polynomial is sin (>/2) such that from (2.9)2As a polynomial in y = sin (>/2), P must satisfy2To solve for P, I. Daubechies' [2,pp 169] introduces arather obscure theorem by Bezout that succinctly statesthe unique existence and order of P given (3.5). Theorder of P is important since P will ultimately bewritten as a truncated Taylor expansion.Theorem 3.1 (Bezout): If p ,p are two polynomials of1 2degree n ,n respectively, with no common zeros, then1 2there exists unique polynomials q ,q of degree n -1,n -1,1 2 2 1respectively, so that

By this theorem, there exist unique polynomials q , q of1 2degree # N-1 such thatNow substituting y for (1-y)

Page 30: The Fast Wavelet Transform (FWT)

26

Then, by the uniqueness in Bezout's theorem (3.1),q (y)=q (1-y), so that2 1Solving for q (y) we get 1Since q is degree # N-1, (1-y) can be written as the1 -Nfirst N terms of its Taylor expansion plus residual as

Substituting the Taylor expansion into q (y) gives1

Again, since q (y) is degree # N-1, q (y)/P(y) becomes1 1

We can now return to the previous substitutiony=sin (>/2), which give us P as a polynomial in sin (>/2)2 2instead of y:

Page 31: The Fast Wavelet Transform (FWT)

27

With this representation, we can write the transferfunction for M (>):0What we are really interested in, however, is Q(>), sothat we have the necessary polynomial m (>) and hence0H(>) in z=e to obtain the filter coefficients {h } viai> nthe inverse Fourier transform.To extract Q(>) from |Q(>)| , we realize that |Q(>)|2 2= P(sin >/2)=Q(>)Q (>). This yields a spectral2 *factorization for the roots of |Q(>)| , from which the2"square root" of |Q(>)| can be extracted [2, pp. 172-2173].3.1 Spectral Factorization of |Q(>)|2

The process of extracting the square root from|Q(>)| begins by considering the spectrum of the roots2of the polynomial

Realizing that this polynomial is a real product ofconjugate factors (|Q(>)| = Q(>)Q (>)), the resultant2 *polynomial can be written as a real polynomial inx=cos(>). Stated as a polynomial in x, it can befactored aswhere the c s appear as complex conjugate pairs or realjsinglets. Because these roots are a product of conjugatefactor, we can extract a polynomial in z=e by writing ai>new polynomial as a product of averaged factors in z,with |z|=1,

Page 32: The Fast Wavelet Transform (FWT)

28

That is, for each linear term of the polynomial x=cos(>)we will get a quadratic that averages the roots in z. The roots (r ) of this new polynomial form the spectrumjof C (z). By the quadratic formula, these roots are ofAthe form

By spectral factorization, Q(z) can then be extracted byconsidering the roots of C (z) outside the unit circle:AWe now have all the necessary roots to create thetransfer functions H(>) and G(>), where

Page 33: The Fast Wavelet Transform (FWT)

29

3.2 Daubechies' Examples for N=2 and N=3The following examples use spectral factorization toconstruct the N=2 and N=3 Daubechies' polynomials m (>). 0From these polynomials, H(>) and G(>) can be created,from which the corresponding filter coefficients {h } andn{g } can be realized via the inverse Fourier transform. nWe will start the examples with the Daubechies N=2 case.N=2: Let x=cos(>) and z=e .i>

Now let m=N-1, and place the root c into P (z).1 A

The roots of P (z) are r = 3.7321 and r = 0.2679. ByA 1 2spectral factorization we take the root outside the unitcircle. In this case, that is r . Consequently,1

The (1-r ) factor simply normalizes Q(z). This factor1can be realized simply by evaluating Q at >=0, that isQ(1). Now that we have Q(z), m (>) becomes0

Page 34: The Fast Wavelet Transform (FWT)

30

Finally m (>) must be normalized so that 0 This gives

Now since we can take the inverse discrete Fourier transform (usingan IFFT) of the 2B-periodic function H(>) to obtain theDaubechies' coefficients {h }. Using the Matlab (A.1)ncode in appendix A, the coefficients {h } become nh = 0.48296291314453 - 0.00000000000000i 0.83651630373781 - 0.00000000000000i 0.22414386804201 - 0.00000000000000i -0.12940952255126 + 0.00000000000000iAfter the coefficients are created, Matlab (A.1) testthem to see that they do, in fact, equal the square rootof 2. Matlab (A.1) further test that the transferfunctions H(>) and G(>) do create a unitary operator, asdiscussed in section (2.3).

Page 35: The Fast Wavelet Transform (FWT)

31

As a contrast for these examples, we will show aplot of H (>) together with H (>) after the next example. 2 3We now show the Daubechies' example for N=3.N=3: Let x=cos(>) and z=e .i>

Now let m=N-1 and place the root c into P (z).1 A

The roots of P (z) are r ,r = 2.7127 ± 1.4439j and r ,rA 1 1 2 2* *= 0.2873 ± 0.1529j. Again, by spectral factorization wetake the roots outside the unit circle. In this case,that is r and r . Consequently,1 1*

Again, the denominator simply normalizes Q(z) at >=0.

Page 36: The Fast Wavelet Transform (FWT)

0 5 10 15 20 25 300

0.5

1

1.5 Transfer Functions: H2(solid), H3(dashed)

30 points: 0 to 2*pi

mag

nitu

de

32Figure 3.1: H(>) for N=2 and N=3

From this we get

Using Matlab (A.2), we again take the IFFT of the2B-periodic function H(>) to obtain the six Daubechies'coefficient set {h }.nh = 0.33267055295008 + 0.00000000000000i 0.80689150931109 - 0.00000000000000i 0.45987750211849 - 0.00000000000000i -0.13501102001025 + 0.00000000000000i -0.08544127388203 + 0.00000000000000i 0.03522629188571 + 0.00000000000000iThe rest of Matlab (A.2) checks, again, that the sum ofthe coefficients is the square root of 2, and that thelinear operator comprised of H(>) and G(>) is unitary.

Page 37: The Fast Wavelet Transform (FWT)

33

Figure (3.1) shows H(>) for N=2 and N=3 as acomparison of the higher degree of vanishing moments ofH verses H . Another way of looking at this is that H3 2 3has a steeper low-pass "roll-off" than H .2

Page 38: The Fast Wavelet Transform (FWT)

34

(4.1)

4. Fast Wavelet Transform With the coefficient set {h } defined, we can returnnto the multiresolution analysis defined previously by(2.4) and (2.5)

In terms of the spectral domain, we have writtenthese recursions as

where, as a finite sequence

From this multiresolution analysis, a recursivedecimation in frequency algorithm can be realized. Inthis algorithm developed by Mallat, H provides a low passfilter operator and G a high pass filter operator.

Page 39: The Fast Wavelet Transform (FWT)

35

Figure 4.1: Recursive operationsof the FWT algorithm, where H isthe low pass operator and G thehigh pass operator.Figure (4.1) shows the operation of the FWT algorithmwith respect to the spectral operators H and G. The barwith an 'x' in it represents a vector in the spectraldomain. After each operation, a vector of the samelength is created. The left half of the vector is theresult of the low pass operator H operating on 'x' (Hx),and the right half is the result of the high passoperator G operating on 'x' (Gx). Consequently, theright half of the new vector is the change between Hx andthe original vector 'x'. This follows themultiresolution analysis relationship V = V r W0 -1 -1discussed in section (2.). That is, the vector x thatlives in V can be represented as a the sum of two0vectors at the next lower resolution. At each step infigure (4.1), equation (4.1) shows us that there is adecimation in frequency of 1/2. Now, since this is awavelet basis operation for R, the result needs to followthe operator G at each resolution. In other words, weneed to leave what has been operated on by G and continueto the next resolution, which is a vector of half thesize. It also follows that since G operates on thescaling function or father wave N, Hx is what is operatedon at the next resolution. Remember, H relates to N(x)and G to R(x). This algorithm continues until the vectorat the current resolution can no longer be decimated.Since multiplication in the spectral domain isequivalent to convolution in the time domain, we can

Page 40: The Fast Wavelet Transform (FWT)

36

create a discrete convolution operator that is equivalentto the decimation in frequency operator derived from therecursions

from which

With a decimation in frequency of 2>, every otherconvolution is discarded yielding a discrete convolutionoperator of the form,

For the case where N=2, the linear operation of Ax=bbecomes,

Page 41: The Fast Wavelet Transform (FWT)

37

This is the Fast Wavelet Transform (FWT). The InverseFast Wavelet Transform (IFWT) operator A is just the-1Hermitian since A is unitary. Actually, since A has realentries in the Daubechies' case, A is just the transpose-1of A, and

With the FWT operator defined, an algorithm based onthis operator can be developed. Also, we can take ourfirst look at the time domain representation of theDaubechies' functions. Until this point, N(x) hasexisted only as a recursive function which could not bedisplayed.

Page 42: The Fast Wavelet Transform (FWT)

0 200 400 600 800 1000 1200-0.1

-0.05

0

0.05

0.1

0.15

38

Figure 4.2: The mother wave R(x)for Daubechies' N=2.

Suppose for a moment that we have the recursive FWTdecomposition algorithm written. To view a basisfunction we look to another orthogonal basisdecomposition algorithm, the FFT. Each element in thediscrete spectral domain of the FFT corresponds to adiscrete frequency in the time domain (a basis function). Similarly, if we take a single discrete non-zero elementin the decomposition domain of the FWT and take the IFWT,a basis function should appear in the discrete timedomain. For example, in the Daubechies case where N=2,the vector e(5) (which is a 1 in the fifth position -zero elsewhere) put through a 1024-point IFWT gives thebasis function R in figure (4.2).2

Similarly, we can view the more regular basis function R3(figure (4.3)):

Page 43: The Fast Wavelet Transform (FWT)

0 200 400 600 800 1000 1200-0.1

-0.05

0

0.05

0.1

0.15

39

Figure 4.3: The mother wave R(x)for Daubechies' N=3.Notice how the higher number of coefficients for N=3versus N=2 makes R more regular than R . This3 2progression continues, as the number of coefficients isincreased. Figure (4.4) shows this clearly in the plotof R .10

Page 44: The Fast Wavelet Transform (FWT)

0 200 400 600 800 1000 1200-0.15

-0.1

-0.05

0

0.05

0.1

0.15

40

Figure 4.4: The mother wave R(x)for Daubechies' N=10.Not only can we now view the mother wave R(x), butwe can decompose some sample signals using the FWT. Inviewing these examples, keep figure (4.1) and thediscussion describing it in mind. The first examplesstep through the FWT one resolution at a time. Figure(4.5) shows the first level operation on a square pulse. Notice how the right side of the resultant vector is thechange between the two resolutions.

Page 45: The Fast Wavelet Transform (FWT)

0 200 400 600 800 1000 12000

0.2

0.4

0.6

0.8

1

0 200 400 600 800 1000 1200-0.5

0

0.5

1

1.5

2

41

Figure 4.5: Top: originalsignal. Bottom: First level FWToperation.Figure (4.6) shows the next level of the FWTdecomposition. Again, if we follow figure (4.1), thenext change between resolutions is represented by themiddle spikes, and the signal that is left is the almostsquare pulse on the left.

Page 46: The Fast Wavelet Transform (FWT)

0 200 400 600 800 1000 12000

0.2

0.4

0.6

0.8

1

0 200 400 600 800 1000 1200-0.5

0

0.5

1

1.5

2

2.5

42

Figure 4.6: Top: originalsignal. Bottom: Second level FWToperation.If these operations are continued to the lowestresolution, we get figure (4.7) - the full FWTdecomposition of a square pulse. The important thing torealize hear is that most of the energy is welllocalized. This is contrary to what a similardecomposition using the FFT would give, which is whywavelets were invented in the first place. Additionally,Since each operation of the FWT is simply a sparse realmatrix multiplication of a (NxM) matrix and a (Mx1)vector (where M is the size of the vector beingtransformed, and N is the size of the filter coefficientset), the complexity of the FWT algorithm is O(M). Thiscompares to the FFT which is O(M*log(M)). This isanother attractive attribute of the FWT over the FFT.

Page 47: The Fast Wavelet Transform (FWT)

0 200 400 600 800 1000 12000

0.2

0.4

0.6

0.8

1

0 200 400 600 800 1000 1200-4

-2

0

2

4

6

43

Figure 4.7: Top: originalsignal. Bottom: Full FWTdecomposition.One final signal decomposition that is rather interestingis that of sine wave (figure (4.8)). This is a signalthat the Fourier transform is very good at decomposing(it is just a single frequency in the spectral domain). The FWT, however, doesn't do well at localizing theenergy of this signal. Not to worry! This is NOT thetype of signal being targeted by the FWT.

Page 48: The Fast Wavelet Transform (FWT)

0 200 400 600 800 1000 1200-1

-0.5

0

0.5

1

0 200 400 600 800 1000 1200-4

-2

0

2

4

6

44

Figure 4.8: Top: originalsignal. Bottom: Full FWTdecomposition.Now that we have seen what the FWT algorithm can do,and how it is derived, we can detail the actual Matlabcode that performs these operations.

Page 49: The Fast Wavelet Transform (FWT)

45

4.1 The FWT AlgorithmLike the FFT, the FWT is a power-of-two algorithm. Each successive decomposition of the FWT operates on avector half the size of the previous operation. This isdue to the decimation in time of the multiresolutionanalysis defined by

Consequently, this power of two algorithm and the FWToperator A, defined previously, define the structure ofthe FWT algorithm. The core of this algorithm isstructured correspondingly, into two Matlab functions. The first function "waveletn.m" (Matlab A.3, appendix A)calls the core operator function "daubn.m" (Matlab A.4,appendix A) for each resolution of either the transformor inverse transform operation depending on whether thevariable transform "xform" is greater than zero or not,respectively.If "transform" is true, the operation continuesuntil the length of the vector is no longer greater thanor equal to four. The algorithm stops after four becauseno more decimation is possible. Each time through the"while" loop the vector is divided in half, correspondingto the multiresolution analysis decimation describedabove. If "transform" is false, then the inversetransform core operation is called recursively from thelowest resolution (nn=4) to the highest resolutiondefined by the original vector space size (n).The function "daubn.m" is relatively straightforward. The transform operation follows the Row vectormultiplies defined by the operator A. The main thing torealize here, and in the inverse transform operation, isthat these are convolution operations (this is the sameas saying that they are filter operation), and, as such,

Page 50: The Fast Wavelet Transform (FWT)

46

wrap-around of the filter coefficients {h } and {g } mustn nbe accounted for. In this algorithm, the wrap-around isaccounted for by the check and compensation of thepointer variable "jk" greater then "n".If the transforming operation follows Rowoperations, then we would expect the inverse transformoperation to follow column operations, and this is thecase. The column operations continue for each Rowelement at column index "i" and "i+nh", where "nh" issimply half the vector length. Like the transformoperation, the inner-loop has two multiplies. The loopsdiffer mainly in how the two multiplies are contained inone sum for the inverse transform operation and twoseparate sums for the transform operation.Probably the easiest way to understand thisalgorithm is to follow the Row/column operations of 4.2 The FWT and Image CompressionThe need to efficiently store and transmit digitizedimages is becoming increasingly important. The idea isto reduce the amount of data necessary to define animage, thereby reducing storage and transmissionbandwidth requirements.Compression of a digitized image takes two forms: lossy and lossless. Loseless data compression dates atleast as far back as the 1970s when Lempel and Ziv, andindependently Huffman, developed string matchingalgorithms that remove the redundancy from a string ofcharacters. More recently, Langden and Rissanen of IBMCorp. developed a probability-based algorithm known asArithmetic Coding [20]. These lossless algorithmsoperate recursively on the data set, removing theredundancy, until a certain level of entropy is reached. They are all lossless because the compressed sequence canbe decompressed to obtain the exact original sequence.

Page 51: The Fast Wavelet Transform (FWT)

47

Lossy data compression techniques also seek toreduce the size of the data set; however, they do notattempt to exactly reconstruct the original sequence whendecompressed. This is where the science of lossycompression gets interesting. How much and what type ofinformation can be lost, such that a reasonable facsimileof the original will exist upon decompression? Lossytechniques make sense only in situations such as imageand audio compression because, as long as enough of theoriginal content remains, the brain can discern what itis seeing or hearing. For example, a very detailed imageof a house can be reduced to a stick drawing, and thebrain can still realize the image content.This stick drawing example really gets to the cruxof the image compression problem. That is, what cannotbe lost in a lossy image compression algorithm is theedge information. This is what has brought localizedwavelet bases to the forefront in image compressionalgorithms. Because of the localized time and frequencynature of the wavelet basis, the edge information in thetransform domain is also localized. This is contrary tothe classic Fourier basis, where discontinuities aredistributed throughout the spectral domain. This is notto say that the Fourier transform cannot be used in imagecompression. In fact, the classic JPEG image compressionalgorithm is based on the real Fourier transform (cosinetransform). Very recently, however, wavelet based imagecompression algorithms have begun to overtake Fourierbased algorithms in a big way with compression ratios onthe order of 100:1, without loss of image quality. Thisis what the HARCC (Houston Advanced Research Centre)wavelet-based algorithm, released recently, boasts. HARCC is proprietary. As such, it will be a while beforewe know how these incredible ratios are obtained. There are two applications of the FWT in imagecompression, one being lossless and the other lossy. Ina lossless application the FWT is used to localizeessential details, such that an image that would notcompress due to its randomness will become compressible. In the lossy application, the FWT is performed on the

Page 52: The Fast Wavelet Transform (FWT)

48

image. Less significant coefficients of the transformedimage are discarded, leaving a highly compressed image. The decompression process then involves performing theIFWT with the reduced coefficient set. Since the largercoefficients retain the essential detail, an arbitrarilyclose approximation to the original image can be obtainedas more coefficients are allowed.4.3 The FWT Image Compression AlgorithmThe FWT image compression algorithm is differentthan the complete FWT multiresolution decompositiondiscussed in section (4.). In this algorithm, twodimensions must be considered. Each resolution mustoperate on both rows and columns of the image matrix.Accordingly, the algorithm performs just onedecimation on each row vector. This separates theessential detail in the horizontal dimension. Next, eachcolumn vector is decimated in the same way, thusseparating the essential detail in the verticaldimension. Matlab A.5 of Appendix A. shows an examplethat takes an original 512 X 512 gray-scale image (matrix"I", Matlab A.5) and performs the above two dimensionaldecomposition twice, creating two multiresolutiondecompositions. Each time the subspace divides itsdimension by two. The wavelet basis used in this exampleis the Daubechies' N=3, six coefficient basis detailed insection (3.2). Figures A.1,A.2,A.3,A.4,A.5, and A.6 ofAppendix A. follow the code in Matlab A.5. Figure A.1 isthe original image of a mandrill (baboon), contained inthe matrix "I" of MATLAB A.5. Figure A.2 shows the firsttwo dimensional decomposition of mandrill image containedin matrix "I". Actually, the original image is 480 X500, and as such, has been padded with zeros to a powerof 2 (512 X 512). This can be seen as bars on the bottomand side of each quadrant of figure A.2, matrix "C" ofMatlab A.5.

Page 53: The Fast Wavelet Transform (FWT)

49

At this point the original image does not compress(lossless), but the first resolution decomposition (figure A.2) compresses lossless at approximately 3:1.This is what we expect from the wavelet transform, sinceit tends to localize the energy of the signal beingtransformed. As such, changes in the image that tend tobe dispersed will become localized. The result of thiswill be more change in less area, leaving the remainingarea with less change. The remaining area will, as aresult of having less change, compress better (lossless). Now we may ask: what would the upper left quadrantof figure (A.2) (which, using the notation of figure(4.1), becomes (HH) in two dimensions), 1/4 of theinformation, look liked if it were inverse transformedwith all other quadrants zero. This image is in FigureA.3 (matrix "D" of Matlab A.5) . Since the quadrant (HH)is the low-pass filter region, the inverse transform willhave an averaging effect. Notice how with only 1/4 thedata of the original image a reasonable facsimile of theoriginal image evolves from the inverse transform. Consequently, this is one possibility of lossycompression. That is, send only the low-pass quadrant,and take the inverse transform at the receiving end. After one two dimensional operation, the dimensionis now n/2 X n/2. If we perform the same decompositionon the quadrant upper-left quadrant (HH) of Figure A.2,we get the next multiresolution analysis shown in FigureA.4 (matrix "C" of Matlab A.5, again). Notice how thenow twice averaged (Low-pass) image appears again in theupper left 1/16 of the matrix. Figure A.4 (Now Matrix"C" of Matlab A.5) now looks like

Page 54: The Fast Wavelet Transform (FWT)

50

where each H and G follow the low-pass and high-passoperations shown in figure (4.1), respectively. Theoperations follow, from right to left, row, column, row,column, etc ... . If we now take the inverse transform of the upperleft 1/16th of figure A.4 (HHHH), we will get an evenmore averaged image than Figure A.3. This inversetransformed image, using only 1/16 of the original, isshown in Figure A.5 (matrix "D1" of Matlab A.5). Noticehow even though it is highly averaged the edgeinformation is intact. Another thing to notice is thecontent of other portions of the decomposition of figureA.4 other than the upper left 1/16 (HHHH). Thesesegments of the decomposition contain essential detail inthe vertical, horizontal and diagonal dimensions.The previous example was intended to show thespacial separation provided by the high and low passmultidimensional multiresolution decomposition. We threwaway entire segments of the analysis. In a realcompression algorithm, since every segment contains someessential detail we would keep some portion of eachsegment. The question becomes, what criteria should beused to determine what data should be retained and whatshould be discarded. As far as I can tell from thecurrently available literature, the criteria is probablythe simplest one could imagine: keep the largestmagnitude coefficients and discard the smallest. MatlabA.6 performs a two level transform of the originalmandrill image (matrix "I" of Matlab A.6). It then

Page 55: The Fast Wavelet Transform (FWT)

51

discards every coefficient less then 200 in magnitude. This leaves less then 1/20 of the coefficients. FigureA.6 shows the reconstruction of the original with onlythese few (1/20) coefficients. Again, notice how theedge information remains intact. Obviously, the HARCC algorithm is more involved than thisexample, but it will be some time before we will know thedetails of this algorithm. All we do know is that it isbased some wavelet basis.

Page 56: The Fast Wavelet Transform (FWT)

52

Appendix A. Matlab Code and Compression Images Matlab A.1r=roots([1 -4 1])Note: The discretization of the 2*pi interval includes only the endpoint at 2*pi, not the end point at zero. This is important so thatthe IFFT doesn't alias.v=(2*pi/10)x=2*pi:-v:v;% Normalize H so that the sum of the hns is sqrt(2).normalize_factor=(sqrt(2)/(1-r(1)));Q=(exp(i*x)-r(1));H=(((1+exp(i*x))/2).^2).*Q*normalize_factor;h=ifft(H)s=cumsum(H);sqrt(2)-s(1)output >> daub_qn2r = 3.73205080756888 0.26794919243112h = 0.48296291314453 - 0.00000000000000i 0.83651630373781 - 0.00000000000000i 0.22414386804201 - 0.00000000000000i -0.12940952255126 + 0.00000000000000isqrt(2) - sum{hn} = 0 + 2.195904039796593e-16iThis is the error between the calculated square root of 2 by Matlaband the sum of the hns. We can also look at the aforementionedunitary conditions in the spectral domain:Note: Here c implies complement, and m implies x+pi.v=(2*pi/30)x=2*pi:-v:v;a=1/(1-r(1));H=a*(((1+exp(i*x))/2).^2).*(exp(i*x)-r(1));Hc=a*(((1+exp(-i*x))/2).^2).*(exp(-i*x)-r(1));Hm=a*(((1+exp(i*(x+pi)))/2).^2).*(exp(i*(x+pi))-r(1));Hmc=a*(((1+exp(-i*(x+pi)))/2).^2).*(exp(-i*(x+pi))-r(1));G=-a*exp(i*3*x).*(((1+exp(-i*(x+pi)))/2).^2).*(exp(-i*(x+pi))-r(1));

Page 57: The Fast Wavelet Transform (FWT)

53

Gc=-a*exp(-i*3*x).*(((1+exp(i*(x+pi)))/2).^2).*(exp(i*(x+pi))-r(1));Gm=-a*exp(i*3*(x+pi)).*(((1+exp(-i*(x)))/2).^2).*(exp(-i*(x))-r(1));Gmc=-a*exp(-i*3*(x+pi)).*(((1+exp(i*(x)))/2).^2).*(exp(i*(x))-r(1));Z0=Hc.*H+Hmc.*Hm; % should be 1Z1=Gc.*H+Gmc.*Hm; % should be 0Z2=H.*Hc+G.*Gc; % should be 1Z3=Hm.*Hc+Gm.*Gc; % should be 0Matlab A.2c=roots([1 -3 8/3])r=roots([1 -2*(c(1)+c(2)) (2+4*c(1)*c(2)) -2*(c(1)+c(2)) 1])Note: The discretization of the 2*pi interval includes only the endpoint at 2*pi, not the end point at zero. This is important so thatthe IFFT doesn't alias.v=(2*pi/14);x=2*pi:-v:v;% Normalize H so that the sum of the hns is sqrt(2).normalize_factor= sqrt(2)/(1-(r(1)+r(2))+r(1)*r(2));Q=exp(2*i*x)-(r(1)+r(2))*exp(i*x)+r(1)*r(2);H=(((1+exp(i*x))/2).^3).*Q*normalize_factor;h=ifft(H)s=cumsum(H);sqrt(2)-s(1)output >> daub_qn3c = 1.50000000000000 + 0.64549722436790i 1.50000000000000 - 0.64549722436790ir = 2.71274862195598 + 1.44388678261800i 2.71274862195598 - 1.44388678261800i 0.28725137804402 + 0.15289233388220i 0.28725137804402 - 0.15289233388220ih = 0.33267055295008 + 0.00000000000000i 0.80689150931109 - 0.00000000000000i 0.45987750211849 - 0.00000000000000i -0.13501102001025 + 0.00000000000000i -0.08544127388203 + 0.00000000000000i 0.03522629188571 + 0.00000000000000isqrt(2) - sum{hn} = 0 + 2.831240458600424e-16i

Page 58: The Fast Wavelet Transform (FWT)

54

Matlab A.3% This function was derived with input from articles% from William H. Press and Gilbert Strang.% Prologue: 'a' defines the vector to be transformed% 'n' defines the length of 'a'% 'cl' are the low-pass filter coefficients {hn}% 'ch' are the high-pass filter coefficients {gn}% 'ncof' indicates the number of coefficients in cl or ch% 'xform' true for transform false for inverse-transformfunction a = waveletn(a,n,cl,ch,ncof,xform)% Fast Wavelet Xform/invXform function if (xform > 0), nn=n; while (nn >= 4), a=daubn(a,nn,cl,ch,ncof,xform); nn=nn/2; end else nn=4; while (nn <= n), a=daubn(a,nn,cl,ch,ncof,xform); nn=nn*2; end endreturn

Page 59: The Fast Wavelet Transform (FWT)

55

Matlab A.4% This function was derived with input from articles% from William H. Press and Gilbert Strang.% Prologue: 'a' defines the vector to be transformed% 'n' defines the length of 'a'% 'cl' are the low-pass filter coefficients {hn}% 'ch' are the high-pass filter coefficients {gn}% 'ncof' indicates the number of coefficients in cl or ch% 'xform' true for transform false for inverse-transformfunction a = daubn(a,n,cl,ch,ncof,xform)nh=n/2;% clear the work spacefor i=1:n,w(i)=0;end if (xform > 0), i=1; for j=1:2:n, jk=j; for k=1:ncof, if (jk>n) jk=jk-n; end w(i)=w(i)+cl(k)*a(jk); w(i+nh)=w(i+nh)+ch(k)*a(jk); jk=jk+1; end i=i+1; end else i=1; for j=1:2:n, jk=j; for k=1:ncof, if (jk>n) jk=jk-n; end w(jk)=w(jk)+cl(k)*a(i)+ch(k)*a(i+nh); jk=jk+1; end i=i+1; end end% save the work space result back into 'a' for i=1:n, a(i)=w(i); endreturn

Page 60: The Fast Wavelet Transform (FWT)

56

Matlab A.5% Image Compression example using the FWT multiresolutiondecomposition.% Prologue: 'I' the original image contained in a 512x512 matrix of % gray scale values.% 'C' the transformed gray scale matrix: I is decomposedto% two levels in this example.% 'ncof' the number of Daubechies' coefficients (filterlength).% 'n' matrix dimentionn=512;ncof=6;% Transform the image I xform=1;% First along Rowsfor i=1:n,A(i,:)=daubn(I(i,:),n,cl,ch,ncof,xform);end% Then along Columnsfor i=1:n,C(:,i)=daubn(A(:,i),n,cl,ch,ncof,xform);end% Take the inverse transform of the HH portion of C.% The other 3/4 of the matrix are zeroed.xform=-1;I=zeros(n,n);I(1:n/2,1:n/2)=C(1:n/2,1:n/2);for i=1:n,A(1:n,i)=daubn(I(1:n,i),n,cl,ch,ncof,xform);endfor i=1:n,D(i,1:n)=daubn(A(i,1:n),n,cl,ch,ncof,xform);end% D contains the uncompressed image of the first resolution% Take the transform to the next level of resolution; % i.e., take the transform of the HH 1/4 portion of C.xform=1;for i=1:n/2,A(1:n/2,i)=daubn(C(1:n/2,i),n/2,cl,ch,ncof,xform);endfor i=1:n/2,C(i,1:n/2)=daubn(A(i,1:n/2),n/2,cl,ch,ncof,xform);end

Page 61: The Fast Wavelet Transform (FWT)

57

% C now contains the second level of resolution% Take the inverse transform of the HHHH portion of C.% The other 15/16 of the matrix are zeroed.xform=-1;I=zeros(n/2,n/2);I(1:n/4,1:n/4)=C(1:n/4,1:n/4);for i=1:n/2,A(1:n/2,i)=daubn(I(1:n/2,i),n/2,cl,ch,ncof,xform);endfor i=1:n/2,I1(i,1:n/2)=daubn(A(i,1:n/2),n/2,cl,ch,ncof,xform);endI=zeros(n,n);I(1:n/2,1:n/2)=I1(1:n/2,1:n/2);for i=1:n,A(1:n,i)=daubn(I(1:n,i),n,cl,ch,ncof,xform);endfor i=1:n,D1(i,1:n)=daubn(A(i,1:n),n,cl,ch,ncof,xform);end% D1 contains the uncompressed image of the second resolution% view the uncompressed image of the second resolution.image(D1)colormap(gray(200))

Page 62: The Fast Wavelet Transform (FWT)

50 100 150 200 250 300 350 400 450 500

50

100

150

200

250

300

350

400

450

58

Figure A.1: This is the original image of a mandrill,contained in matrix "I" of Matlab A.5.

Page 63: The Fast Wavelet Transform (FWT)

50 100 150 200 250 300 350 400 450 500

50

100

150

200

250

300

350

400

450

500

59

Figure A.2: This is the first level transform of theoriginal image (nxn). This image is contained in matrix"C" of Matlab A.5.

Page 64: The Fast Wavelet Transform (FWT)

50 100 150 200 250 300 350 400 450 500

50

100

150

200

250

300

350

400

450

60

Figure A.3: This is the inverse transform of the (n/2 xn/2) upper left quadrant of figure A.2 (matrix "C" ofMatlab A.5), with all other quadrants zero. This imageis contained in matrix "D" of Matlab A.5.

Page 65: The Fast Wavelet Transform (FWT)

50 100 150 200 250 300 350 400 450 500

50

100

150

200

250

300

350

400

450

500

61

Figure A.4: This is the second level transform of theoriginal image (nxn). The first operation was at thedimension (nxn), and the second operation was at thedimension (n/2 n/2). This image is contained in thesecond occurence of matrix "C" in Matlab A.5.

Page 66: The Fast Wavelet Transform (FWT)

50 100 150 200 250 300 350 400 450 500

50

100

150

200

250

300

350

400

450

62

Figure A.5: This is the inverse transform of the (n/4 xn/4) upper left 1/16th of figure A.4 (matrix "C" ofMatlab A.5), with the rest of the matrix zero. Thisimage is contained in matrix "D1" of Matlab A.5.

Page 67: The Fast Wavelet Transform (FWT)

63

Matlab A.6% Image Compression example using the FWT multiresolutiondecomposition.% Prologue: 'I' the original image contained in a 512x512 matrix of % gray scale values.% 'C' the transformed gray scale matrix: I is decomposed to% two levels in this example.% 'ncof' the number of Daubechies' coefficients (filter length).% 'n' matrix dimentionn=512;ncof=6;% Transform the image I xform=1;% First along Rowsfor i=1:n,A(i,:)=daubn(I(i,:),n,cl,ch,ncof,xform);end% Then along Columnsfor i=1:n,C(:,i)=daubn(A(:,i),n,cl,ch,ncof,xform);end% Take the transform to the next level of resolution; % i.e., take the transform of the HH 1/4 portion of C.xform=1;for i=1:n/2,A(1:n/2,i)=daubn(C(1:n/2,i),n/2,cl,ch,ncof,xform);endfor i=1:n/2,C(i,1:n/2)=daubn(A(i,1:n/2),n/2,cl,ch,ncof,xform);end% C now contains the second level of resolution% As an example, zero all coefficients less than 200.for i=1:n,for j=1:n,if (abs(C(i,j)) < 200),C(i,j)=0; endendend

Page 68: The Fast Wavelet Transform (FWT)

64

% Take the inverse transform of the second resolution% transformed image with only the more significant % coefficients retained.xform=-1;for i=1:n/2,A(1:n/2,i)=daubn(C(1:n/2,i),n/2,cl,ch,ncof,xform);endfor i=1:n/2,C(i,1:n/2)=daubn(A(i,1:n/2),n/2,cl,ch,ncof,xform);endfor i=1:n,A(1:n,i)=daubn(C(1:n,i),n,cl,ch,ncof,xform);endfor i=1:n,C(i,1:n)=daubn(A(i,1:n),n,cl,ch,ncof,xform);end% C contains the uncompressed image of the second resolution% view the uncompressed image of the second resolution.image(C)colormap(gray(200))

Page 69: The Fast Wavelet Transform (FWT)

50 100 150 200 250 300 350 400 450 500

50

100

150

200

250

300

350

400

450

65

Figure A.6: Inverse transform of figure A.4 with only1/20th of the coefficients retained.

Page 70: The Fast Wavelet Transform (FWT)

66

References[1] I. Daubechies, "Orthonormal Bases of Compactly Supported Wavelets," Communications on Pure and Applied Mathematics, vol. XLI, pp. 909-996, 1988.[2] I. Daubechies, "Ten Lectures on Wavelets," SIAM, Philadelphia, PA, 1992.[3] T.H. Koornwinder, "Wavelets: An Elementary Treatment of Theory and Applications," World Scientific Publishing Co., River Edge, NJ, 1993.[4] G.G. Walter, "Wavelets and Other Orthogonal Systems With Applications," CRC Press, Boca Taton, FL, 1994.[5] Y. Meyer, "Wavelets, Algorithms & Applications," SIAM, Philadelphia, PA, 1993.[6] J.M. Combes and A. Grossmann, "Wavelets, Time-Frequency Methods and Phase Space," Springer-Verlag, Berlin Heidelberg, 1989.[7] C.K. Chui, "Wavelets: A tutorial in Theory and Applications," Academic Press, San Diego, CA, 1992.[8] L.L. Schumaker and G. Webb, "Recent Advances in Wavlet Analysis," Academic Press, San Diego, CA, 1994.[9] M.B. Ruskai, "Wavelets and Their Applications," Jones and Bartlett, Boston, MA, 1992.[10] P. Duhamel et al., "Special Issue on Wavelets and Signal Processing," IEEE Trans. on Signal Processing, vol. 41, 1993.[11] O. Rioul, "A Remez Exchange Algorithm for Orthonormal Wavelets," IEEE Trans. on Circuits and Systems, vol. 41, pp.550-560, Aug. 1994.[12] S.G. Mallat, "Multiresolution Approximations and Wavelet Orthonormal Bases of L (R)," Trans. of the American 2Mathematical Society, vol. 315, pp. 69-86, Sept. 1989.[13] S.G. Mallat, "A Theory for Multiresolution Signal Decomposition: The Wavelet Representation," IEEE Trans. on Pattern Analysis and Machine Intelligence, vol. 11, pp. 674-693, Jul. 1989.

Page 71: The Fast Wavelet Transform (FWT)

67

[14] G. Strang, "Wavelet Transforms Versus Fourier Transforms," American Mathematical Society, vol. 28, pp. 288-304, Apr. 1993.[15] R.A. Gopinath, "Optimal Wavelet Representation of Signals andthe Wavelet Sampling Theorem," IEEE Trans. on Circuits andSystems, vol. 41, pp. 262-277, Apr. 1994.[16] I. Daubechies, "The Wavelet Transform, Time-Frequency Localization and Signal Analysis," IEEE Trans. on Information Theory, vol. 36, pp. 961-1004, Sept. 1990.[17] P.J. Burt and E.H. Adelson, "The Laplacian Pyramid as a Compact Image Code," IEEE Trans. on Communications, vol. 31,pp. 532-540, 1983.[18] J.J. Benedetto and M.W. Frazier, "Wavelets, Mathematics andApplications," CRC Press, Boca Raton, FL, 1994.[19] M.V. Wickerhauser, "Adapted Wavelet Analysis, from Theory toSoftware," A.K Peters, Wellesley, MA, 1994.[20] T.C. Bell et al., "Text Compression," Prentice Hall, EnglewoodCliffs, NJ, 1990.

Page 72: The Fast Wavelet Transform (FWT)

68