13.10 Wavelet Transforms 591 The splitting point b must be chosen large enough that the remaining integral over(b,)is small.Successive terms in its asymptotic expansion are found by integrating by parts.The integral over(a,b)can be done using dftint.You keep as many terms in the asymptotic expansion as you can easily compute.See[6]for some examples of this idea.More powerful methods,which work well for long-tailed functions but which do not use the FFT, are described in [7-9]. CITED REFERENCES AND FURTHER READING: Stoer,J.,and Bulirsch,R.1980,Introduction to Numerical Analysis(New York:Springer-Verlag), p.88.[1] Narasimhan,M.S.and Karthikeyan,M.1984,IEEE Transactions on Antennas Propagation, vol.32,pp.404-408.[2] Filon,L.N.G.1928.Proceedings of the Royal Society of Edinburgh,vol.49,pp.38-47.[3] Giunta,G.and Murli,A.1987,ACM Transactions on Mathematical Software,vol.13,pp.97-107. 4] ICAL Lyness,J.N.1987,in Numerical Integration,P.Keast and G.Fairweather,eds.(Dordrecht: Reidel).[5] Pantis,G.1975,Journal of Computational Physics,vol.17,pp.229-233.[6] RECIPES Blakemore,M.,Evans,G.A.,and Hyslop,J.1976,Journal of Computational Physics,vol.22. pp.352-376.7] 9 Lyness,J.N.,and Kaper,T.J.1987,SIAM Journal on Scientific and Statistical Computing,vol.8. pp.1005-1011.[8] Thakkar,A.J.,and Smith,V.H.1975,Computer Physics Communications,vol.10,pp.73-79.[9] 邑白 9 13.10 Wavelet Transforms Like the fast Fourier transform(FFT),the discrete wavelet transform(DWT)is a fast,linear operation that operates on a data vector whose length is an integer power of two,transforming it into a numerically different vector of the same length.Also like the FFT,the wavelet transform is invertible and in fact orthogonal-the inverse transform,when viewed as a big matrix,is simply the transpose of the transform. Both FFT and DWT,therefore,can be viewed as a rotation in function space,from Numerical Recipes 10621 43106 the input space(or time)domain,where the basis functions are the unit vectors ei, or Dirac delta functions in the continuum limit,to a different domain.For the FFT. this new domain has basis functions that are the familiar sines and cosines.In the (outside wavelet domain,the basis functions are somewhat more complicated and have the North fanciful names“mother functions'”and“wavelets. Of course there are an infinity of possible bases for function space,almost all of them uninteresting!What makes the wavelet basis interesting is that,unlike sines and cosines,individual wavelet functions are quite localized in space;simultaneously, like sines and cosines,individual wavelet functions are quite localized in frequency or (more precisely)characteristic scale.As we will see below,the particular kind of dual localization achieved by wavelets renders large classes of functions and operators sparse,or sparse to some high accuracy,when transformed into the wavelet domain.Analogously with the Fourier domain,where a class of computations,like convolutions,become computationally fast,there is a large class of computations
13.10 Wavelet Transforms 591 Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machinereadable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). The splitting point b must be chosen large enough that the remaining integral over (b,∞) is small. Successive terms in its asymptotic expansion are found by integrating by parts. The integral over (a, b) can be done using dftint. You keep as many terms in the asymptotic expansion as you can easily compute. See [6] for some examples of this idea. More powerful methods, which work well for long-tailed functions but which do not use the FFT, are described in [7-9]. CITED REFERENCES AND FURTHER READING: Stoer, J., and Bulirsch, R. 1980, Introduction to Numerical Analysis (New York: Springer-Verlag), p. 88. [1] Narasimhan, M.S. and Karthikeyan, M. 1984, IEEE Transactions on Antennas & Propagation, vol. 32, pp. 404–408. [2] Filon, L.N.G. 1928, Proceedings of the Royal Society of Edinburgh, vol. 49, pp. 38–47. [3] Giunta, G. and Murli, A. 1987, ACM Transactions on Mathematical Software, vol. 13, pp. 97–107. [4] Lyness, J.N. 1987, in Numerical Integration, P. Keast and G. Fairweather, eds. (Dordrecht: Reidel). [5] Pantis, G. 1975, Journal of Computational Physics, vol. 17, pp. 229–233. [6] Blakemore, M., Evans, G.A., and Hyslop, J. 1976, Journal of Computational Physics, vol. 22, pp. 352–376. [7] Lyness, J.N., and Kaper, T.J. 1987, SIAM Journal on Scientific and Statistical Computing, vol. 8, pp. 1005–1011. [8] Thakkar, A.J., and Smith, V.H. 1975, Computer Physics Communications, vol. 10, pp. 73–79. [9] 13.10 Wavelet Transforms Like the fast Fourier transform (FFT), the discrete wavelet transform (DWT) is a fast, linear operation that operates on a data vector whose length is an integer power of two, transforming it into a numerically different vector of the same length. Also like the FFT, the wavelet transform is invertible and in fact orthogonal — the inverse transform, when viewed as a big matrix, is simply the transpose of the transform. Both FFT and DWT, therefore, can be viewed as a rotation in function space, from the input space (or time) domain, where the basis functions are the unit vectors e i, or Dirac delta functions in the continuum limit, to a different domain. For the FFT, this new domain has basis functions that are the familiar sines and cosines. In the wavelet domain, the basis functions are somewhat more complicated and have the fanciful names “mother functions” and “wavelets.” Of course there are an infinity of possible bases for function space, almost all of them uninteresting! What makes the wavelet basis interesting is that, unlike sines and cosines, individual wavelet functions are quite localized in space; simultaneously, like sines and cosines, individual wavelet functions are quite localized in frequency or (more precisely) characteristic scale. As we will see below, the particular kind of dual localization achieved by wavelets renders large classes of functions and operators sparse, or sparse to some high accuracy, when transformed into the wavelet domain. Analogously with the Fourier domain, where a class of computations, like convolutions, become computationally fast, there is a large class of computations
592 Chapter 13.Fourier and Spectral Applications -those that can take advantage of sparsity-that become computationally fast in the wavelet domain [1]. Unlike sines and cosines,which define a unique Fourier transform,there is not one single unique set of wavelets;in fact,there are infinitely many possible sets.Roughly,the different sets of wavelets make different trade-offs between how compactly they are localized in space and how smooth they are.(There are further fine distinctions.) Daubechies Wavelet Filter Coefficients A particular set of wavelets is specified by a particular set of numbers,called wavelet filter coefficients.Here,we will largely restrict ourselves to wavelet filters in a class discovered by Daubechies [21.This class includes members ranging from highly localized to highly smooth.The simplest (and most localized)member,often 茶 called DAUB4,has only four coefficients,co,...,c3.For the moment we specialize to this case for ease of notation. Consider the following transformation matrix acting on a column vector of RECIPES I data to its right: 。●0 令 「co C1 C2 C3 Press. C3 -C2C1-C0 Co C1 C2 C3 C3 -C2C1 -C0 (13.10.1) SCIENTIFIC Co C1 C2 C3 C3 -C2 C1 -C0 C3 Co C1 LC1 -C0 C3 -c2」 Here blank entries signify zeroes.Note the structure of this matrix.The first row generates one component of the data convolved with the filter coefficients co...,c3. 10.621 Likewise the third,fifth,and other odd rows.If the even rows followed this pattern, Numerica offset by one,then the matrix would be a circulant,that is,an ordinary convolution 43106 that could be done by FFT methods.(Note how the last two rows wrap around Recipes like convolutions with periodic boundary conditions.Instead of convolving with (outside co,...,c3,however,the even rows perform a different convolution,with coefficients c3,-c2,c1,-co.The action of the matrix,overall,is thus to perform two related North convolutions,then to decimate each of them by half(throw away half the values), and interleave the remaining halves. It is useful to think of the filter co,...,ca as being a smoothing filter,call it H, something like a moving average of four points.Then,because of the minus signs, the filter c3,-c2,c1,-co,call it G,is not a smoothing filter.(In signal processing contexts,H and G are called quadrature mirror filters [3].)In fact,the c's are chosen so as to make G yield,insofar as possible,a zero response to a sufficiently smooth data vector.This is done by requiring the sequence c3,-c2,c1,-co to have a certain number of vanishing moments.When this is the case for p moments(starting with the zeroth),a set of wavelets is said to satisfy an"approximation condition of order
592 Chapter 13. Fourier and Spectral Applications Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machinereadable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). — those that can take advantage of sparsity — that become computationally fast in the wavelet domain [1]. Unlike sines and cosines, which define a unique Fourier transform, there is not one single unique set of wavelets; in fact, there are infinitely many possible sets. Roughly, the different sets of wavelets make different trade-offs between how compactly they are localized in space and how smooth they are. (There are further fine distinctions.) Daubechies Wavelet Filter Coefficients A particular set of wavelets is specified by a particular set of numbers, called wavelet filter coefficients. Here, we will largely restrict ourselves to wavelet filters in a class discovered by Daubechies [2]. This class includes members ranging from highly localized to highly smooth. The simplest (and most localized) member, often called DAUB4, has only four coefficients, c0,...,c3. For the moment we specialize to this case for ease of notation. Consider the following transformation matrix acting on a column vector of data to its right: c0 c1 c2 c3 c3 −c2 c1 −c0 c0 c1 c2 c3 c3 −c2 c1 −c0 . . . . . . ... c0 c1 c2 c3 c3 −c2 c1 −c0 c2 c3 c0 c1 c1 −c0 c3 −c2 (13.10.1) Here blank entries signify zeroes. Note the structure of this matrix. The first row generates one component of the data convolved with the filter coefficients c 0 ...,c3. Likewise the third, fifth, and other odd rows. If the even rows followed this pattern, offset by one, then the matrix would be a circulant, that is, an ordinary convolution that could be done by FFT methods. (Note how the last two rows wrap around like convolutions with periodic boundary conditions.) Instead of convolving with c0,...,c3, however, the even rows perform a different convolution, with coefficients c3, −c2, c1, −c0. The action of the matrix, overall, is thus to perform two related convolutions, then to decimate each of them by half (throw away half the values), and interleave the remaining halves. It is useful to think of the filter c0,...,c3 as being a smoothing filter, call it H, something like a moving average of four points. Then, because of the minus signs, the filter c3, −c2, c1, −c0, call it G, is not a smoothing filter. (In signal processing contexts, H and G are called quadrature mirror filters [3].) In fact, the c’s are chosen so as to make G yield, insofar as possible, a zero response to a sufficiently smooth data vector. This is done by requiring the sequence c 3, −c2, c1, −c0 to have a certain number of vanishing moments. When this is the case for p moments (starting with the zeroth), a set of wavelets is said to satisfy an “approximation condition of order
13.10 Wavelet Transforms 593 p."This results in the output of H,decimated by half,accurately representing the data's "smooth"information.The output of G,also decimated,is referred to as the data's“detail”information[4l. For such a characterization to be useful,it must be possible to reconstruct the original data vector of length N from its N/2 smooth or s-components and its N/2 detail or d-components.That is effected by requiring the matrix(13.10.1)to be orthogonal,so that its inverse is just the transposed matrix Co C3 C2 C1 C1 -C2 C3 -C0 C2 C1 Co C3 C3 -C0C1 -C2 (13.10.2) C2 C1 Co C3 C3 -C0C1-C2 C2 C1 C0 C3 RECIPES C3 -c0 C1 -C2 9 One sees immediately that matrix (13.10.2)is inverse to matrix (13.10.1)if and only if these two equations hold, 哈+c+c吃+c=1 (13.10.3) C2c0+c3C1=0 If additionally we require the approximation condition of order p =2,then two IENTIFIC additional relations are required, C3-C2+C1-c0=0 (13.10.4) 0c3-1c2+2c1-3c0=0 Equations (13.10.3)and (13.10.4)are 4 equations for the 4 unknowns co,...,c3, first recognized and solved by Daubechies.The unique solution(up to a left-right Sg② Numerica 10.621 reversal)is 0=(1+V3)/4v2 c1=(3+V3)/4v② 4310 (13.10.5) Recipes c2=(3-V/42 c3=(1-V3)/4V2 (outside In fact,DAUB4 is only the most compact of a sequence of wavelet sets:If we had six coefficients instead of four,there would be three orthogonality requirements in equation(13.10.3)(with offsets of zero,two,and four),and we could require the vanishing ofp =3 moments in equation(13.10.4).In this case,DAUB6,the solution coefficients can also be expressed in closed form, c0=(1+√o+V5+2Vo/16v2c1=(5+V0+3V5+2W1ō)/16v2 c2=(10-2W0+2V5+2yo)/16√2c3=(10-2面-2V5+2Wō/16√2 c4=(6+V10-3V5+2W1o)/16v2c=(1+√10-V5+2W1o)/16v2 (13.10.6)
13.10 Wavelet Transforms 593 Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machinereadable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). p.” This results in the output of H, decimated by half, accurately representing the data’s “smooth” information. The output of G, also decimated, is referred to as the data’s “detail” information [4]. For such a characterization to be useful, it must be possible to reconstruct the original data vector of length N from its N/2 smooth or s-components and its N/2 detail or d-components. That is effected by requiring the matrix (13.10.1) to be orthogonal, so that its inverse is just the transposed matrix c0 c3 ··· c2 c1 c1 −c2 ··· c3 −c0 c2 c1 c0 c3 c3 −c0 c1 −c2 ... c2 c1 c0 c3 c3 −c0 c1 −c2 c2 c1 c0 c3 c3 −c0 c1 −c2 (13.10.2) One sees immediately that matrix (13.10.2) is inverse to matrix (13.10.1) if and only if these two equations hold, c2 0 + c2 1 + c2 2 + c2 3 = 1 c2c0 + c3c1 = 0 (13.10.3) If additionally we require the approximation condition of order p = 2, then two additional relations are required, c3 − c2 + c1 − c0 = 0 0c3 − 1c2 + 2c1 − 3c0 = 0 (13.10.4) Equations (13.10.3) and (13.10.4) are 4 equations for the 4 unknowns c 0,...,c3, first recognized and solved by Daubechies. The unique solution (up to a left-right reversal) is c0 = (1 + √ 3)/4 √ 2 c1 = (3 + √ 3)/4 √ 2 c2 = (3 − √ 3)/4 √ 2 c3 = (1 − √ 3)/4 √ 2 (13.10.5) In fact, DAUB4 is only the most compact of a sequence of wavelet sets: If we had six coefficients instead of four, there would be three orthogonality requirements in equation (13.10.3) (with offsets of zero, two, and four), and we could require the vanishing of p = 3 moments in equation (13.10.4). In this case, DAUB6, the solution coefficients can also be expressed in closed form, c0 = (1 + √10 + 5+2√10)/16√2 c1 = (5 + √10 + 35+2√10)/16√2 c2 = (10 − 2 √10 + 2 5+2√10)/16√2 c3 = (10 − 2 √10 − 2 5+2√10)/16√2 c4 = (5 + √10 − 3 5+2√10)/16√2 c5 = (1 + √10 − 5+2√10)/16√2 (13.10.6)
594 Chapter 13.Fourier and Spectral Applications For higher p,up to 10,Daubechies [2]has tabulated the coefficients numerically.The number of coefficients increases by two each time p is increased by one. Discrete Wavelet Transform We have not yet defined the discrete wavelet transform (DWT),but we are almost there:The DWT consists of applying a wavelet coefficient matrix like (13.10.1)hierarchically,first to the full data vector of length N,then to the "smooth" vector of length N/2,then to the "smooth-smooth"vector of length N/4.and so on until only a trivial number of "smooth-...-smooth"components(usually 2) remain.The procedure is sometimes called a pyramidal algorithm [4],for obvious reasons.The output of the DWT consists of these remaining components and all 鱼 the "detail"components that were accumulated along the way.A diagram should make the procedure clear: 100 17 S1 S17 S17 d 旺山 S2 S etc. 4 4 13.10.1 permute D2 (North America users to make one paper UnN电.t THE ye ds D 2 7 8 ART 8 13.10.1 da permute D 9 S5 器 only),or y10 ds 出 Programs 11 s 12 de d 91 ST s y14 dr 2 Copyright (C) y15 S8 dz d to dir y16 ds ds ds ds (13.10.7 ectcustser If the length of the data vector were a higher power of two.there would be OF SCIENTIFIC COMPUTING(ISBN 0-521- more stages ofapplying(13.10.1)(or any other wavelet coefficients)and permuting. The endpoint will always be a vector with two S's and a hierarchy of D's,D's, v@cam d's,etc.Notice that once d's are generated,they simply propagate through to all subsequent stages. 1988-1992 by Numerical Recipes A value di of any level is termed a "wavelet coefficient"of the original data 1-43108-.5 vector;the final values S1,S2 should strictly be called"mother-function coefficients," although the term"wavelet coefficients"is often used loosely for both d's and final (outside 膜 S's.Since the full procedure is a composition of orthogonal linear operations,the North Software. whole DWT is itself an orthogonal linear operator. To invert the DWT,one simply reverses the procedure,starting with the smallest level of the hierarchy and working(in equation 13.10.7)from right to left.The visit website inverse matrix(13.10.2)is of course used instead of the matrix(13.10.1). machine As already noted,the matrices(13.10.1)and(13.10.2)embody periodic("wrap- around")boundary conditions on the data vector.One normally accepts this as a minor inconvenience:the last few wavelet coefficients at each level of the hierarchy are affected by data from both ends of the data vector.By circularly shifting the matrix (13.10.1)N/2 columns to the left,one can symmetrize the wrap-around; but this does not eliminate it.It is in fact possible to eliminate the wrap-around
594 Chapter 13. Fourier and Spectral Applications Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machinereadable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). For higher p, up to 10, Daubechies [2] has tabulated the coefficients numerically. The number of coefficients increases by two each time p is increased by one. Discrete Wavelet Transform We have not yet defined the discrete wavelet transform (DWT), but we are almost there: The DWT consists of applying a wavelet coefficient matrix like (13.10.1) hierarchically, first to the full data vector of length N, then to the “smooth” vector of length N/2, then to the “smooth-smooth” vector of length N/4, and so on until only a trivial number of “smooth-...-smooth” components (usually 2) remain. The procedure is sometimes called a pyramidal algorithm [4], for obvious reasons. The output of the DWT consists of these remaining components and all the “detail” components that were accumulated along the way. A diagram should make the procedure clear: y1 y2 y3 y4 y5 y6 y7 y8 y9 y10 y11 y12 y13 y14 y15 y16 13.10.1 −→ s1 d1 s2 d2 s3 d3 s4 d4 s5 d5 s6 d6 s7 d7 s8 d8 permute −→ s1 s2 s3 s4 s5 s6 s7 s8 d1 d2 d3 d4 d5 d6 d7 d8 13.10.1 −→ S1 D1 S2 D2 S3 D3 S4 D4 d1 d2 d3 d4 d5 d6 d7 d8 permute −→ S1 S2 S3 S4 D1 D2 D3 D4 d1 d2 d3 d4 d5 d6 d7 d8 etc. −→ S1 S2 D1 D2 D1 D2 D3 D4 d1 d2 d3 d4 d5 d6 d7 d8 (13.10.7) If the length of the data vector were a higher power of two, there would be more stages of applying (13.10.1) (or any other wavelet coefficients) and permuting. The endpoint will always be a vector with two S’s and a hierarchy of D’s, D’s, d’s, etc. Notice that once d’s are generated, they simply propagate through to all subsequent stages. A value di of any level is termed a “wavelet coefficient” of the original data vector; the final values S1, S2 should strictly be called “mother-function coefficients,” although the term “wavelet coefficients” is often used loosely for both d’s and final S’s. Since the full procedure is a composition of orthogonal linear operations, the whole DWT is itself an orthogonal linear operator. To invert the DWT, one simply reverses the procedure, starting with the smallest level of the hierarchy and working (in equation 13.10.7) from right to left. The inverse matrix (13.10.2) is of course used instead of the matrix (13.10.1). As already noted, the matrices (13.10.1) and (13.10.2) embody periodic (“wraparound”) boundary conditions on the data vector. One normally accepts this as a minor inconvenience: the last few wavelet coefficients at each level of the hierarchy are affected by data from both ends of the data vector. By circularly shifting the matrix (13.10.1) N/2 columns to the left, one can symmetrize the wrap-around; but this does not eliminate it. It is in fact possible to eliminate the wrap-around
13.10 Wavelet Transforms 595 completely by altering the coefficients in the first and last N rows of(13.10.1). giving an orthogonal matrix that is purely band-diagonal [5].This variant,beyond our scope here,is useful when,e.g.,the data varies by many orders of magnitude from one end of the data vector to the other. Here is a routine,wt1,that performs the pyramidal algorithm(or its inverse if isign is negative)on some data vector a[1..n].Successive applications of the wavelet filter,and accompanying permutations,are done by an assumed routine wtstep,which must be provided.(We give examples of several different wtstep routines just below. void wt1(float a[],unsigned long n,int isign, void(*wtstep)(f1oat☐,unsigned long,int)) One-dimensional discrete wavelet transform.This routine implements the pyramid algorithm, replacing a[1..n]by its wavelet transform (for isign=1),or performing the inverse operation (for isign=-1).Note that n MUST be an integer power of 2.The routine wtstep,whose actual name must be supplied in calling this routine,is the underlying wavelet filter.Examples of wtstep are daub4 and (preceded by pwtset)pwt. 3 unsigned long nn; RECIPES if (n 4)return; (Nort if(1s1gn>=0)[ Wavelet transform. for (nn=n;nn>=4;nn>>=1)(*wtstep)(a,nn,isign); server computer, Start at largest hierarchy,and work towards smallest. America one paper University Press. THE else Inverse wavelet transform. 9 ART for (nn=4;nn1)+1; 1f(1s1gm>=0){ Apply filter for(1=1,j=1;j<=n-3;j+=2,1++){ ksp[i]=C0*a[j]+C1*a[j+1]+C2*a[j+2]+C3*a[j+3]; wksp[i+nh]=C3*a[j]-C2*a[j+1]+C1*a[j+2]-C0*a[j+3] wksp[i]=C0*a[n-1]+C1*a[n]+C2*a[1]+C3*a[2]; wksp[i+nh]=C3*a[n-1]-C2*a[n]+c1*a[1]-c0*a[2]; else Apply transpose filter wksp[1]=C2*a[nh]+C1*a[n]+C0*a[1]+C3*a[nh1]; wksp[2]=C3*a[nh]-C0*a[n]+C1*a[1]-C2*a[nh1]; for (i=1,j=3;i<nh;i++){
13.10 Wavelet Transforms 595 Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machinereadable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). completely by altering the coefficients in the first and last N rows of (13.10.1), giving an orthogonal matrix that is purely band-diagonal [5]. This variant, beyond our scope here, is useful when, e.g., the data varies by many orders of magnitude from one end of the data vector to the other. Here is a routine, wt1, that performs the pyramidal algorithm (or its inverse if isign is negative) on some data vector a[1..n]. Successive applications of the wavelet filter, and accompanying permutations, are done by an assumed routine wtstep, which must be provided. (We give examples of several different wtstep routines just below.) void wt1(float a[], unsigned long n, int isign, void (*wtstep)(float [], unsigned long, int)) One-dimensional discrete wavelet transform. This routine implements the pyramid algorithm, replacing a[1..n] by its wavelet transform (for isign=1), or performing the inverse operation (for isign=-1). Note that n MUST be an integer power of 2. The routine wtstep, whose actual name must be supplied in calling this routine, is the underlying wavelet filter. Examples of wtstep are daub4 and (preceded by pwtset) pwt. { unsigned long nn; if (n = 0) { Wavelet transform. for (nn=n;nn>=4;nn>>=1) (*wtstep)(a,nn,isign); Start at largest hierarchy, and work towards smallest. } else { Inverse wavelet transform. for (nn=4;nn> 1)+1; if (isign >= 0) { Apply filter. for (i=1,j=1;j<=n-3;j+=2,i++) { wksp[i]=C0*a[j]+C1*a[j+1]+C2*a[j+2]+C3*a[j+3]; wksp[i+nh] = C3*a[j]-C2*a[j+1]+C1*a[j+2]-C0*a[j+3]; } wksp[i]=C0*a[n-1]+C1*a[n]+C2*a[1]+C3*a[2]; wksp[i+nh] = C3*a[n-1]-C2*a[n]+C1*a[1]-C0*a[2]; } else { Apply transpose filter. wksp[1]=C2*a[nh]+C1*a[n]+C0*a[1]+C3*a[nh1]; wksp[2] = C3*a[nh]-C0*a[n]+C1*a[1]-C2*a[nh1]; for (i=1,j=3;i<nh;i++) {
596 Chapter 13. Fourier and Spectral Applications ksp[j++]=C2*a[i]+C1*a[i+nh]+C0*a[i+1]+C3*a[i+nh1]; ksp[j++]=C3*a[i]-C0*a[i+nh]+C1*a[i+1]-C2*a[i+nh1]; for (i=1;i<=n;i++)a[i]-wksp[i]; free_vector(wksp,1,n); 2 For larger sets of wavelet coefficients.the wrap-around of the last rows or columns is a programming inconvenience.An efficient implementation would handle the wrap-arounds as special cases,outside of the main loop.Here,we will content ourselves with a more general scheme involving some extra arithmetic at run time.The following routine sets up any particular wavelet coefficients whose nted for values you happen to know. 1800 typedef struct int ncof,ioff,joff; float *cc,*cri to any /Cambridge from NUMERICAL RECIPES IN 18881992 wavefilt; wavefilt wfilt; Defining declaration of a structure. (Nort void pwtset(int n) server computer, e University Press. THE Initializing routine for pwt,here implementing the Daubechies wavelet filters with 4,12,and America make one paper 20 coefficients,as selected by the input value n.Further wavelet filters can be included in the ART obvious manner.This routine must be called (once)before the first use of pwt.(For the case n=4,the specific routine daub4 is considerably faster than pwt.) 9 Programs void nrerror(char error_text[]); for their int k: float sig =-1.0; static f1oatc4[5]=[0.0,0.4829629131445341,0.8365163037378079, 0.2241438680420134,-0.1294095225512604): to dir stat1cf1oatc12[13]=[0.0,0.111540743350,0.494623890398,0.751133908021, 0.315250351709,-0.226264693965,-0.129766867567, 0.097501605587,0.027522865530,-0.031582039318 OF SCIENTIFIC COMPUTING(ISBN 0.000553842201,0.004777257511,-0.001077301085] stat1cf1oatc20[21]=10.0,0.026670057901,0.188176800078,0.527201188932, 0.688459039454,0.281172343661,-0.249846424327 -0.195946274377,0.127369340336,0.093057364604 -0.071394147166,-0.029457536822,0.033212674059, 0.003606553567,-0.010733175483,0.001395351747, Further reproduction,or 1988-1992 by Numerical Recipes 10-621 43108 0.001992405295,-0.000685856695,-0.000116466855, 0.000093588670,-0.000013264203}: static float c4r[5],c12r[13],c20r[21]; wfilt.ncof=n Software. if(n==4)[ wfilt.cc=c4; wfilt.cr=c4r; (outside North America) e1se1f(n=12)[ wfilt.cc=c12; wfilt.cr=c12r; e1se1f(n==20){ wfilt.cc=c20; wfilt.cr=c20r else nrerror("unimplemented value n in pwtset"); for(k=1;k<=n;k++){
596 Chapter 13. Fourier and Spectral Applications Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machinereadable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). wksp[j++]=C2*a[i]+C1*a[i+nh]+C0*a[i+1]+C3*a[i+nh1]; wksp[j++] = C3*a[i]-C0*a[i+nh]+C1*a[i+1]-C2*a[i+nh1]; } } for (i=1;i<=n;i++) a[i]=wksp[i]; free_vector(wksp,1,n); } For larger sets of wavelet coefficients, the wrap-around of the last rows or columns is a programming inconvenience. An efficient implementation would handle the wrap-arounds as special cases, outside of the main loop. Here, we will content ourselves with a more general scheme involving some extra arithmetic at run time. The following routine sets up any particular wavelet coefficients whose values you happen to know. typedef struct { int ncof,ioff,joff; float *cc,*cr; } wavefilt; wavefilt wfilt; Defining declaration of a structure. void pwtset(int n) Initializing routine for pwt, here implementing the Daubechies wavelet filters with 4, 12, and 20 coefficients, as selected by the input value n. Further wavelet filters can be included in the obvious manner. This routine must be called (once) before the first use of pwt. (For the case n=4, the specific routine daub4 is considerably faster than pwt.) { void nrerror(char error_text[]); int k; float sig = -1.0; static float c4[5]={0.0,0.4829629131445341,0.8365163037378079, 0.2241438680420134,-0.1294095225512604}; static float c12[13]={0.0,0.111540743350, 0.494623890398, 0.751133908021, 0.315250351709,-0.226264693965,-0.129766867567, 0.097501605587, 0.027522865530,-0.031582039318, 0.000553842201, 0.004777257511,-0.001077301085}; static float c20[21]={0.0,0.026670057901, 0.188176800078, 0.527201188932, 0.688459039454, 0.281172343661,-0.249846424327, -0.195946274377, 0.127369340336, 0.093057364604, -0.071394147166,-0.029457536822, 0.033212674059, 0.003606553567,-0.010733175483, 0.001395351747, 0.001992405295,-0.000685856695,-0.000116466855, 0.000093588670,-0.000013264203}; static float c4r[5],c12r[13],c20r[21]; wfilt.ncof=n; if (n == 4) { wfilt.cc=c4; wfilt.cr=c4r; } else if (n == 12) { wfilt.cc=c12; wfilt.cr=c12r; } else if (n == 20) { wfilt.cc=c20; wfilt.cr=c20r; } else nrerror("unimplemented value n in pwtset"); for (k=1;k<=n;k++) {
13.10 Wavelet Transforms 597 wfilt.cr[wfilt.ncof+1-k]=sig*wfilt.cc[k]; s1g■-s1g: wfilt.ioff wfilt.joff =-(n >1); These values center the "support"of the wavelets at each level.Alternatively,the "peaks" of the wavelets can be approximately centered by the choices ioff=-2 and joff=-n+2. Note that daub4 and putset with n-4 use different default centerings. Once pwtset has been called,the following routine can be used as a specific instance of wtstep. #include "nrutil.h" typedef struct int ncof,ioff,joff; granted for 18881992 float *cc,*cr; wavefilt; 100 extern wavefilt wfilt; Defined in pwtset. to any Cambridge from NUMERICAL RECIPES IN void pwt(float a],unsigned long n,int isign) Partial wavelet transform:applies an arbitrary wavelet filter to data vector a [1..n](for isign 1)or applies its transpose (for isign =-1).Used hierarchically by routines wt1 and wtn. (Nort server The actual filter is determined by a preceding (and required)call to pwtset,which initializes the structure wfilt. America computer, THE float ai,ai1,*wksp; ART unsigned long i,ii,j,jf,jr,k,n1,ni,nj,nh,nmod; if (n 4)return; Programs wksp=vector(1,n); nmod=wfilt.ncof*n; A positive constant equal to zero mod n. n1=n-1; Mask of all bits,since n a power of 2. nh=n >1; for (j=1;j=0)[ Apply filter. for(1i=1,1=1;i<n;i+=2,ii++)[ ni=i+nmod+wfilt.ioff; Pointer to be incremented and wrapped-around. OF SCIENTIFIC COMPUTING(ISBN nj=i+nmod+wfilt.joff; 1788-1982 for (k=1;k<=wfilt.ncof;k++){ jf=n1&(ni+k); We use bitwise and to wrap-around the point- jr=n1&(nj+k); ers. 10-621 wksp[ii]+wfilt.cc[k]*a[if+1]; wksp[ii+nh]+wfilt.cr[k]*a[jr+1]; .Further reproduction, Numerical Recipes 43108 else Apply transpose filter. for(1i=1,1=1;1<n;1+=2,11++)[ (outside 膜 aisa[ii]; ailsa[iitnh]; ni=i+nmod+wfilt.ioff; See comments above. nj=i+nmod+wfilt.joff; North Amer Software. for (k=1;k<=wfilt.ncof;k++){ jf=(n12(ni+k))+1; jr=(n1&(nj+k))+1: wksp[jf]+wfilt.cc[k]*ai; wksp[jr]+wfilt.cr[k]wail; for (j=1;j<=n;j++)a[j]=wksp[j]; Copy the results back from workspace. free_vector(wksp,1,n);
13.10 Wavelet Transforms 597 Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machinereadable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). wfilt.cr[wfilt.ncof+1-k]=sig*wfilt.cc[k]; sig = -sig; } wfilt.ioff = wfilt.joff = -(n >> 1); These values center the “support” of the wavelets at each level. Alternatively, the “peaks” of the wavelets can be approximately centered by the choices ioff=-2 and joff=-n+2. Note that daub4 and pwtset with n=4 use different default centerings. } Once pwtset has been called, the following routine can be used as a specific instance of wtstep. #include "nrutil.h" typedef struct { int ncof,ioff,joff; float *cc,*cr; } wavefilt; extern wavefilt wfilt; Defined in pwtset. void pwt(float a[], unsigned long n, int isign) Partial wavelet transform: applies an arbitrary wavelet filter to data vector a[1..n] (for isign = 1) or applies its transpose (for isign = −1). Used hierarchically by routines wt1 and wtn. The actual filter is determined by a preceding (and required) call to pwtset, which initializes the structure wfilt. { float ai,ai1,*wksp; unsigned long i,ii,j,jf,jr,k,n1,ni,nj,nh,nmod; if (n > 1; for (j=1;j= 0) { Apply filter. for (ii=1,i=1;i<=n;i+=2,ii++) { ni=i+nmod+wfilt.ioff; Pointer to be incremented and wrapped-around. nj=i+nmod+wfilt.joff; for (k=1;k<=wfilt.ncof;k++) { jf=n1 & (ni+k); We use bitwise and to wrap-around the pointjr=n1 & (nj+k); ers. wksp[ii] += wfilt.cc[k]*a[jf+1]; wksp[ii+nh] += wfilt.cr[k]*a[jr+1]; } } } else { Apply transpose filter. for (ii=1,i=1;i<=n;i+=2,ii++) { ai=a[ii]; ai1=a[ii+nh]; ni=i+nmod+wfilt.ioff; See comments above. nj=i+nmod+wfilt.joff; for (k=1;k<=wfilt.ncof;k++) { jf=(n1 & (ni+k))+1; jr=(n1 & (nj+k))+1; wksp[jf] += wfilt.cc[k]*ai; wksp[jr] += wfilt.cr[k]*ai1; } } } for (j=1;j<=n;j++) a[j]=wksp[j]; Copy the results back from workspace. free_vector(wksp,1,n); }
598 Chapter 13.Fourier and Spectral Applications .1 .05 0 -.05 DAUB4 es -.1 0 100 200300400500600700 800 900 1000 83g granted for 19881992 .05 0 1-.200 -05 -.1 DAUB20 e22 server from NUMERICAL RECIPES IN C: LLLLLL (North 0 100200 300400500600700 8009001000 America computer, UnN电.t THE Figure 13.10.1.Wavelet functions,that is,single basis functions from the wavelet families DAUB4 and DAUB20.A complete,orthonormal wavelet basis consists of scalings and translations of either one ART of these functions.DAUB4 has an infinite number of cusps,DAUB20 would show similar behavior in a higher derivative. Programs 是家 What Do Wavelets Look Like? We are now in a position actually to see some wavelets.To do so,we simply N OF SCIENTIFIC COMPUTING (ISBN run unit vectors through any of the above discrete wavelet transforms,with isign 1988-1992 negative so that the inverse transform is performed.Figure 13.10.1 shows the DAUB4 wavelet that is the inverse DWT of a unit vector in the 5th component of a vector of length 1024,and also the DAUB20 wavelet that is the inverse of the 22nd component.(One needs to go to a later hierarchical level for DAUB20,to avoid a Fuurggoglrion Numerical Recipes 10-621 wavelet with a wrapped-around tail.)Other unit vectors would give wavelets with 43198.5 the same shapes,but different positions and scales. One sees that both DAUB4 and DAUB20 have wavelets that are continuous. (outside DAUB20 wavelets also have higher continuous derivatives.DAUB4 has the peculiar North Software. property that its derivative exists only almost everywhere.Examples of where it fails to exist are the points p/2",where p and n are integers;at such points,DAUB4 is left differentiable,but not right differentiable!This kind of discontinuity-at least in some derivative-is a necessary feature of wavelets with compact support,like the Daubechies series.For every increase in the number of wavelet coefficients by two,the Daubechies wavelets gain about half a derivative of continuity.(But not exactly half,the actual orders of regularity are irrational numbers!) Note that the fact that wavelets are not smooth does not prevent their having exact representations for some smooth functions,as demanded by their approximation order p.The continuity of a wavelet is not the same as the continuity of functions
598 Chapter 13. Fourier and Spectral Applications Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machinereadable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). 0 100 200 300 400 500 600 700 800 900 1000 0 100 200 300 400 500 600 700 800 900 1000 −.1 −.05 0 .05 .1 −.1 −.05 0 .05 .1 DAUB20 e22 DAUB4 e5 Figure 13.10.1. Wavelet functions, that is, single basis functions from the wavelet families DAUB4 and DAUB20. A complete, orthonormal wavelet basis consists of scalings and translations of either one of these functions. DAUB4 has an infinite number of cusps; DAUB20 would show similar behavior in a higher derivative. What Do Wavelets Look Like? We are now in a position actually to see some wavelets. To do so, we simply run unit vectors through any of the above discrete wavelet transforms, with isign negative so that the inverse transform is performed. Figure 13.10.1 shows the DAUB4 wavelet that is the inverse DWT of a unit vector in the 5th component of a vector of length 1024, and also the DAUB20 wavelet that is the inverse of the 22nd component. (One needs to go to a later hierarchical level for DAUB20, to avoid a wavelet with a wrapped-around tail.) Other unit vectors would give wavelets with the same shapes, but different positions and scales. One sees that both DAUB4 and DAUB20 have wavelets that are continuous. DAUB20 wavelets also have higher continuous derivatives. DAUB4 has the peculiar property that its derivative exists only almost everywhere. Examples of where it fails to exist are the points p/2n, where p and n are integers; at such points, DAUB4 is left differentiable, but not right differentiable! This kind of discontinuity — at least in some derivative — is a necessary feature of wavelets with compact support, like the Daubechies series. For every increase in the number of wavelet coefficients by two, the Daubechies wavelets gain about half a derivative of continuity. (But not exactly half; the actual orders of regularity are irrational numbers!) Note that the fact that wavelets are not smooth does not prevent their having exact representations for some smooth functions,as demanded by their approximation order p. The continuity of a wavelet is not the same as the continuity of functions
13.10 Wavelet Transforms 599 2 0 -.2 DAUB4 e10+ess 0 100 200 300400500600700800 9001000 83g 1-.200 0 -.2 Lemarie e1o+ess (North server 0 100200 3004005006007008009001000 America University Press. 需 Figure 13.10.2.More wavelets,here generated from the sum of two unit vectors,eo +ess,which are in different hierarchical levels of scale,and also at different spatial positions.DAUB4 wavelets(a) are defined by a filter in coordinate space (equation 13.10.5),while Lemarie wavelets (b)are defined by a filter most easily written in Fourier space (equation 13.10.14). Progra 9 that a set of wavelets can represent.For example,DAUB4 can represent(piecewise) linear functions of arbitrary slope:in the correct linear combinations,the cusps all CIENTIFIC( cancel out.Every increase of two in the number of coefficients allows one higher 61 order of polynomial to be exactly represented. Figure 13.10.2 shows the result of performing the inverse DWT on the input vector e1o+ess,again for the two different particular wavelets.Since 10 lies early in the hierarchical range of 9-16,that wavelet lies on the left side of the picture. Since 58 lies in a later(smaller-scale)hierarchy,it is a narrower wavelet;in the range of 33-64 it is towards the end,so it lies on the right side of the picture.Note that 10.621 smaller-scale wavelets are taller,so as to have the same squared integral. Recipes E喜 43106 Wavelet Filters in the Fourier Domain (outside The Fourier transform of a set of filter coefficients cj is given by North Hu)-∑cew (13.10.8) Here H is a function periodic in 2m,and it has the same meaning as before:It is the wavelet filter,now written in the Fourier domain.A very useful fact is that the orthogonality conditions for the c's(e.g.,equation 13.10.3 above)collapse to two simple relations in the Fourier domain, H(P-1 (13.10.9)
13.10 Wavelet Transforms 599 Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machinereadable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). 0 100 200 300 400 500 600 700 800 900 1000 0 100 200 300 400 500 600 700 800 900 1000 −.2 0 .2 DAUB4 e10 + e58 −.2 0 .2 Lemarie e10 + e58 Figure 13.10.2. More wavelets, here generated from the sum of two unit vectors, e10 + e58, which are in different hierarchical levels of scale, and also at different spatial positions. DAUB4 wavelets (a) are defined by a filter in coordinate space (equation 13.10.5), while Lemarie wavelets (b) are defined by a filter most easily written in Fourier space (equation 13.10.14). that a set of wavelets can represent. For example, DAUB4 can represent (piecewise) linear functions of arbitrary slope: in the correct linear combinations, the cusps all cancel out. Every increase of two in the number of coefficients allows one higher order of polynomial to be exactly represented. Figure 13.10.2 shows the result of performing the inverse DWT on the input vector e10 + e58, again for the two different particular wavelets. Since 10 lies early in the hierarchical range of 9 − 16, that wavelet lies on the left side of the picture. Since 58 lies in a later (smaller-scale) hierarchy, it is a narrower wavelet; in the range of 33–64 it is towards the end, so it lies on the right side of the picture. Note that smaller-scale wavelets are taller, so as to have the same squared integral. Wavelet Filters in the Fourier Domain The Fourier transform of a set of filter coefficients c j is given by H(ω) = j cjeijω (13.10.8) Here H is a function periodic in 2π, and it has the same meaning as before: It is the wavelet filter, now written in the Fourier domain. A very useful fact is that the orthogonality conditions for the c’s (e.g., equation 13.10.3 above) collapse to two simple relations in the Fourier domain, 1 2 |H(0)| 2 =1 (13.10.9)
600 Chapter 13.Fourier and Spectral Applications and 号HoP+Ho+-l (13.10.10) Likewise the approximation condition of order p (e.g.,equation 13.10.4 above) has a simple formulation,requiring that H(w)have a pth order zero at w=, or (equivalently) Hm)(r)=0m=0,1,,p-1 (13.10.11) It is thus relatively straightforward to invent wavelet sets in the Fourier domain. You simply invent a function H(w)satisfying equations(13.10.9)(13.10.11).To 81 find the actual ci's applicable to a data (or s-component)vector of length N,and with periodic wrap-around as in matrices(13.10.1)and(13.10.2),you invert equation (13.10.8)by the discrete Fourier transform 1 N-1 ,2k ∑H(N )e-2mijk/N (13.10.12) k= The quadrature mirror filter G(reversed c;'s with alternating signs),incidentally, RECIPES has the Fourier representation G(w)=e-iwH(w+π) (13.10.13) where asterisk denotes complex conjugation ∽5 In general the above procedure will not produce wavelet filters with compact support.In other words,all N of the cj's,j=0,...,N-1 will in general be nonzero(though they may be rapidly decreasing in magnitude).The Daubechies s巴g1 wavelets,or other wavelets with compact support,are specially chosen so that H(w) is a trigonometric polynomial with only a small number of Fourier components, guaranteeing that there will be only a small number of nonzero ci's. On the other hand,there is sometimes no particular reason to demand compact support.Giving it up in fact allows the ready construction of relatively smoother wavelets (higher values of p).Even without compact support,the convolutions implicit in the matrix(13.10.1)can be done efficiently by FFT methods Lemarie's wavelet (see [41)has p =4,does not have compact support,and is defined by the choice of H(w), 、ò6 Numerica 10.621 H(w)= 2(1-04315-420u+1262-4r311/e (13.10.14) 43106 315-420元+126u2-43 where u三sim2 2 v三sin2w (13.10.15) It is beyond our scope to explain where equation (13.10.14)comes from.An informal description is that the quadrature mirror filter G(w)deriving from equation (13.10.14)has the property that it gives identically zero when applied to any function whose odd-numbered samples are equal to the cubic spline interpolation of its even-numbered samples.Since this class of functions includes many very smooth members,it follows that H(w)does a good job of truly selecting a function's smooth information content.Sample Lemarie wavelets are shown in Figure 13.10.2
600 Chapter 13. Fourier and Spectral Applications Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copyin Copyright (C) 1988-1992 by Cambridge University Press. Programs Copyright (C) 1988-1992 by Numerical Recipes Software. Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5) g of machinereadable files (including this one) to any server computer, is strictly prohibited. To order Numerical Recipes books or CDROMs, visit website http://www.nr.com or call 1-800-872-7423 (North America only), or send email to directcustserv@cambridge.org (outside North America). and 1 2 |H(ω)| 2 + |H(ω + π)| 2 =1 (13.10.10) Likewise the approximation condition of order p (e.g., equation 13.10.4 above) has a simple formulation, requiring that H(ω) have a pth order zero at ω = π, or (equivalently) H(m) (π)=0 m = 0, 1,...,p − 1 (13.10.11) It is thus relatively straightforward to invent wavelet sets in the Fourier domain. You simply invent a function H(ω) satisfying equations (13.10.9)–(13.10.11). To find the actual cj ’s applicable to a data (or s-component) vector of length N, and with periodic wrap-around as in matrices (13.10.1) and (13.10.2), you invert equation (13.10.8) by the discrete Fourier transform cj = 1 N N −1 k=0 H( 2πk N )e−2πijk/N (13.10.12) The quadrature mirror filter G (reversed c j ’s with alternating signs), incidentally, has the Fourier representation G(ω) = e−iωH*(ω + π) (13.10.13) where asterisk denotes complex conjugation. In general the above procedure will not produce wavelet filters with compact support. In other words, all N of the c j ’s, j = 0,...,N − 1 will in general be nonzero (though they may be rapidly decreasing in magnitude). The Daubechies wavelets, or other wavelets with compact support, are specially chosen so that H(ω) is a trigonometric polynomial with only a small number of Fourier components, guaranteeing that there will be only a small number of nonzero c j ’s. On the other hand, there is sometimes no particular reason to demand compact support. Giving it up in fact allows the ready construction of relatively smoother wavelets (higher values of p). Even without compact support, the convolutions implicit in the matrix (13.10.1) can be done efficiently by FFT methods. Lemarie’s wavelet (see [4]) has p = 4, does not have compact support, and is defined by the choice of H(ω), H(ω) = 2(1 − u) 4 315 − 420u + 126u2 − 4u3 315 − 420v + 126v2 − 4v3 1/2 (13.10.14) where u ≡ sin2 ω 2 v ≡ sin2 ω (13.10.15) It is beyond our scope to explain where equation (13.10.14) comes from. An informal description is that the quadrature mirror filter G(ω) deriving from equation (13.10.14) has the property that it gives identically zero when applied to any function whose odd-numbered samples are equal to the cubic spline interpolation of its even-numbered samples. Since this class of functions includes many very smooth members, it follows that H(ω) does a good job of truly selecting a function’s smooth information content. Sample Lemarie wavelets are shown in Figure 13.10.2