Вы находитесь на странице: 1из 626

Wavel et Tool box

Computation
Visualization
Programming
User s Gui de
Version 1
Michel Misiti
Yves Misiti
Georges Oppenheim
Jean-Michel Poggi
For Use with MATLAB

How to Conta ct The Ma thW orks:


508-647-7000 Phone
508-647-7001 Fax
The MathWorks, I nc. Mai l
24 Pri me Park Way
Nati ck, MA 01760-1500
ht t p: //www. mat hwor ks . com Web
f t p. mat hwor ks . com Anonymous FTP ser ver
c omp. s of t - s y s . mat l ab Newsgroup
s uppor t @mat hwor ks . com Techni cal support
s ugges t @mat hwor ks . com Product enhancement suggesti ons
bugs @mat hwor ks . com Bug r epor ts
doc@mat hwor ks . com Documentati on err or r epor ts
s ubs cr i be@mat hwor ks . com Subscr i bi ng user r egi strati on
s er v i ce@mat hwor ks . com Or der status, l i cense renewal s, passcodes
i nf o@mat hwor ks . com Sal es, pr i ci ng, and gener al i nformati on
Wavlet Toolbox Users Guide
COPYRI GHT 1996 - 1997 by The MathWor ks, I nc. Al l Ri ghts Reser ved.
The softwar e descr i bed i n thi s document i s fur ni shed under a l i cense agr eement. The softwar e may be used
or copied onl y under the ter ms of the l i cense agr eement. No par t of thi s manual may be photocopi ed or r epr o-
duced i n any for m wi thout pr i or wr i tten consent fr om The MathWorks, I nc.
U.S. GOVERNMENT: I f Li censee i s acquir i ng the softwar e on behal f of any uni t or agency of the U. S.
Gover nment, the fol l owi ng shal l appl y:
(a) for uni ts of the Depar tment of Defense:
RESTRI CTED RI GHTS LEGEND: Use, dupli cation, or discl osur e by the Gover nment is subject to r estr i c-
ti ons as set for th i n subparagraph (c)(1)(i i ) of the Ri ghts i n Techni cal Data and Computer Software Cl ause
at DFARS 252.227-7013.
(b) for any other unit or agency:
NOTI CE - Notwi thstandi ng any other l ease or li cense agr eement that may pertai n to, or accompany the
del iver y of, the computer softwar e and accompanyi ng documentati on, the r ights of the Gover nment
r egar ding i ts use, repr oducti on and discl osur e ar e as set for th i n Clause 52.227-19(c)(2) of the FAR.
Contractor /manufactur er i s The MathWor ks I nc., 24 Pr i me Par k Way, Nati ck, MA 01760-1500.
MATLAB, Si muli nk, Handle Gr aphi cs, and Real -Ti me Wor kshop ar e r egi ster ed trademar ks and Statefl ow
and Tar get Language Compi ler ar e tr ademar ks of The MathWor ks, I nc.
Other pr oduct or br and names are tr ademar ks or r egister ed tr ademar ks of thei r r espective hol ders.
Pr i nti ng Hi stor y: Mar ch 1996 Fi rst pri nti ng

FAX
u
@
iv
Contents
Preface
About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvi
What is the Wavelet Toolbox? . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
How to Use Thi s Gui de . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii
For More Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xx
System Recommendati ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xx
Pl atform-Speci fi c Detai l s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xx
Wi ndows Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xx
Other Pl atforms Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Mouse Compati bi l i ty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Typographical Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii
1
Wavelets: A New Tool for Signal Analysis
Fourier Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
Short-Time Fourier Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Wavelet Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5
What Can Wavel et Anal ysi s Do? . . . . . . . . . . . . . . . . . . . . . . . . 1-5
v Contents
What is Wavelet Analysis? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
Number of Di mensi ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
The Continuous Wavelet Transform . . . . . . . . . . . . . . . . . . . . . . . 1-8
Scal i ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
Shi fti ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-10
Fi ve Easy Steps to a Conti nuous Wavel et Tr ansform . . . . . . . 1-10
Scal e and Frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
The Scal e of Nature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13
Whats Conti nuous About the Conti nuous
Wavel et Tr ansfor m? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-15
The Discrete Wavelet Transform . . . . . . . . . . . . . . . . . . . . . . . . . 1-16
One-Stage Fi l teri ng: Approxi mati ons and Detai l s . . . . . . . . . . 1-16
Mul ti pl e-Level Decomposi ti on . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19
Number of Level s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19
Wavelet Reconstruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-20
Reconstructi on Fi l ter s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-21
Reconstructi ng Approxi mati ons and Detai l s . . . . . . . . . . . . . . 1-21
Rel ati onshi p of Fi l ter s to Wavel et Shapes . . . . . . . . . . . . . . . . 1-23
The Scal i ng Functi on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-25
Mul ti step Decomposi ti on and Reconstructi on . . . . . . . . . . . . . 1-25
Wavelet Packet Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-27
History of Wavelets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-29
An Introduction to the Wavelet Families . . . . . . . . . . . . . . . . . 1-30
Haar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-31
Daubechi es . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-31
Bi orthogonal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-32
Coi fl ets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-33
Syml ets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-33
Morl et . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-34
Mexi can Hat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-34
Meyer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-35
vi
2
Using Wavelets
Continuous Wavelet Analysis (One-Dimensional) . . . . . . . . . . 2-3
Conti nuous Anal ysi s Usi ng the Command Li ne . . . . . . . . . . . . 2-3
Conti nuous Anal ysi s Usi ng the Graphi cal I nterface . . . . . . . . . 2-7
I mpor ti ng and Exporti ng I nfor mati on
fr om the Graphi cal I nterface . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-11
Loadi ng Si gnal s i nto the Conti nuous Wavel et 1-D Tool . . . 2-11
Savi ng Wavel et Coeffi ci ents . . . . . . . . . . . . . . . . . . . . . . . . . 2-12
One-Dimensional Discrete Wavelet Analysis . . . . . . . . . . . . 2-13
Anal ysi s Decomposi ti on Functi ons: . . . . . . . . . . . . . . . . . . . 2-13
Synthesi s Reconstructi on Functi ons: . . . . . . . . . . . . . . . . . . 2-13
Decomposi ti on Structure Uti l i ti es:
Anal ysi s Decomposi ti on Functi ons: . . . . . . . . . . . . . . . . . . . 2-14
One-Di mensi onal Anal ysi s Usi ng the Command Li ne . . . . . . 2-15
One-Di mensi onal Anal ysi s Usi ng the Gr aphi cal I nterface . . . 2-22
I mpor ti ng and Exporti ng I nfor mati on
fr om the Graphi cal I nterface . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-38
Savi ng I nformati on to the Di sk . . . . . . . . . . . . . . . . . . . . . . . 2-38
Loadi ng I nformati on i nto the Wavel et 1-D Tool . . . . . . . . . 2-40
Two-Dimensional Discrete Wavelet Analysis . . . . . . . . . . . . . 2-43
Anal ysi s-Decomposi ti on Functi ons: . . . . . . . . . . . . . . . . . . . 2-43
Synthesi s-Reconstructi on Functi ons: . . . . . . . . . . . . . . . . . . 2-43
Decomposi ti on Structure Uti l i ti es: . . . . . . . . . . . . . . . . . . . . 2-43
De-noi si ng and Compressi on: . . . . . . . . . . . . . . . . . . . . . . . . 2-44
Two-Di mensi onal Anal ysi s Usi ng the Command Li ne . . . . . . 2-44
Two-Di mensi onal Anal ysi s Usi ng the Gr aphi cal I nter face . . . 2-52
I mpor ti ng and Exporti ng I nfor mati on
fr om the Graphi cal I nterface . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-59
Savi ng I nformati on to the Di sk . . . . . . . . . . . . . . . . . . . . . . . 2-59
Loadi ng I nformati on i nto the Wavel et 2-D Tool . . . . . . . . . 2-62
Working with Indexed Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-66
Understandi ng I mages i n MATLAB . . . . . . . . . . . . . . . . . . . . . 2-66
I ndexed I mages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-66
Wavel et Decomposi ti on of I ndexed I mages . . . . . . . . . . . . . . . 2-68
How Decomposi ti ons Ar e Di spl ayed . . . . . . . . . . . . . . . . . . . 2-71
vii Contents
3
Wavelet Applications
Detecting Discontinuities and Breakdown Points I . . . . . . . . 3-3
Di scussi on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
Gui del i nes for Detecti ng Di sconti nui ti es . . . . . . . . . . . . . . . . 3-4
Detecting Discontinuities and Breakdown Points II . . . . . . . 3-6
Di scussi on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-7
Detecting Long-Term Evolution . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8
Di scussi on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9
Detecting Self-Similarity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-10
Wavel et Coeffi ci ents and Sel f-Si mi l ari ty . . . . . . . . . . . . . . . . . 3-10
Di scussi on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-11
Identifying Pure Frequencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
Di scussi on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-12
Suppressing Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15
Di scussi on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16
Vani shi ng Moments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17
De-Noising Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18
Di scussi on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18
Compressing Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21
Di scussi on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22
4
Wavelets in Action: Examples and Case Studies
Illustrated Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3
Advi ce to the Reader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-6
About Fur ther Expl or ati on . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-7
Exampl e #1: A Sum of Si nes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
viii
Exampl e #2: A Frequency Br eakdown . . . . . . . . . . . . . . . . . . . 4-10
Exampl e #3: Uni for m Whi te Noi se . . . . . . . . . . . . . . . . . . . . . . 4-12
Exampl e #4: Col ored AR(3) Noi se . . . . . . . . . . . . . . . . . . . . . . . 4-14
Exampl e #5: Pol ynomi al + Whi te Noi se . . . . . . . . . . . . . . . . . . 4-16
Exampl e #6: A Step Si gnal . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-18
Exampl e #7: Two Pr oxi mal Di sconti nui ti es . . . . . . . . . . . . . . . 4-20
Exampl e #8: A Second-Deri vati ve Di sconti nui ty . . . . . . . . . . . 4-22
Exampl e #9: A Ramp + Whi te Noi se . . . . . . . . . . . . . . . . . . . . . 4-24
Exampl e #10: A Ramp + Col or ed Noi se . . . . . . . . . . . . . . . . . . 4-26
Exampl e #11: A Si ne + Whi te Noi se . . . . . . . . . . . . . . . . . . . . . 4-28
Exampl e #12: A Tri angl e + A Si ne . . . . . . . . . . . . . . . . . . . . . . 4-30
Exampl e #13: A Tri angl e + A Si ne + Noi se . . . . . . . . . . . . . . . 4-32
Exampl e #14: A Real El ectr i ci ty Consumpti on Si gnal . . . . . . . 4-34
A Case Study: An Electrical Signal . . . . . . . . . . . . . . . . . . . . . . . 4-36
Data and the External I nformati on . . . . . . . . . . . . . . . . . . . . . 4-36
Anal ysi s of the Mi dday Per i od . . . . . . . . . . . . . . . . . . . . . . . . . . 4-38
Anal ysi s of the End of the Ni ght Peri od . . . . . . . . . . . . . . . . . . 4-39
Suggesti ons for Further Anal ysi s . . . . . . . . . . . . . . . . . . . . . . . 4-42
I denti fy the Sensor Fai l ur e . . . . . . . . . . . . . . . . . . . . . . . . . . 4-42
Suppr ess the Noi se . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-43
I denti fy Patter ns i n the Detai l s . . . . . . . . . . . . . . . . . . . . . . 4-44
Locate and Suppr ess Outl yi ng Val ues . . . . . . . . . . . . . . . . . 4-46
Study Mi ssi ng Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-47
Fast Multiplication of Large Matrices . . . . . . . . . . . . . . . . . . . . 4-48
Exampl e 1: Effecti ve Fast Matri x Mul ti pl i cati on . . . . . . . . 4-49
Exampl e 2: I neffecti ve Fast Matri x Mul ti pl i cati on . . . . . . . 4-51
5
Using Wavelet Packets
About Wavelet Packet Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3
One-Dimensional Wavelet Packet Analysis . . . . . . . . . . . . . . . . 5-6
De-Noi si ng a Si gnal Usi ng Wavel et Packet . . . . . . . . . . . . . . . 5-14
ix Contents
Two-Dimensional Wavelet Packet Analysis . . . . . . . . . . . . . . . 5-19
Importing and Exporting from Graphical Tools . . . . . . . . . . 5-26
Savi ng I nformati on to the Di sk . . . . . . . . . . . . . . . . . . . . . . . . . 5-26
Savi ng Synthesi zed Si gnal s . . . . . . . . . . . . . . . . . . . . . . . . . 5-26
Savi ng Synthesi zed I mages . . . . . . . . . . . . . . . . . . . . . . . . . . 5-27
Savi ng One-Di mensi onal Decomposi ti on Str uctur es . . . . . . 5-27
Savi ng Two-Di mensi onal Decomposi ti on Str uctur es . . . . . 5-28
Loadi ng I nformati on i nto the Gr aphi cal Tool s . . . . . . . . . . . . . 5-28
Loadi ng Si gnal s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-29
Loadi ng I mages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-29
Loadi ng Wavel et Packet Decomposi ti on Structures . . . . . . 5-30
6
Advanced Concepts
Mathemati cal Conventi ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
General Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5
Wavel ets: A New Tool for Si gnal Anal ysi s . . . . . . . . . . . . . . . . . 6-5
Wavel et Decomposi ti on:
A Hi erarchi cal Organi zati on . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-5
Fi ner and Coarser Resol uti ons . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6
Wavel et Shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6
Wavel ets and Associ ated Fami l i es . . . . . . . . . . . . . . . . . . . . . . . 6-8
Wavel ets on a Regul ar Di screte Gr i d . . . . . . . . . . . . . . . . . . . . 6-13
Wavel et Tr ansfor ms: Conti nuous and Di scr ete . . . . . . . . . . . . 6-14
Local and Gl obal Anal ysi s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-16
Synthesi s: An I nverse Transform . . . . . . . . . . . . . . . . . . . . . . . 6-17
Detai l s and Appr oxi mati ons . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-18
The Fast Wavelet Transform (FWT) Algorithm . . . . . . . . . . . 6-21
Fi l ters Used to Cal cul ate the DWT and I DWT . . . . . . . . . . . . 6-21
Al gori thms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-24
Why Does Such an Al gori thm Exi st? . . . . . . . . . . . . . . . . . . . . 6-29
x
One-Dimensional Wavelet Capabilities . . . . . . . . . . . . . . . . . . . 6-34
Two-Dimensional Wavelet Capabilities . . . . . . . . . . . . . . . . . . . 6-40
Dealing with Border Distortion . . . . . . . . . . . . . . . . . . . . . . . . . . 6-46
Si gnal Extensi ons: Zero-Paddi ng, Symmetri zati on,
and Smooth Paddi ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-46
Per i odi zed Wavel et Transform . . . . . . . . . . . . . . . . . . . . . . . . . 6-55
Frequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-56
Conti nuous or Di scr ete Anal ysi s? . . . . . . . . . . . . . . . . . . . . . 6-56
Why Are Wavel ets Useful for Space-Savi ng Codi ng? . . . . . 6-56
Why Do Al l Wavel ets Have Zero Average and Someti mes
Several Vani shi ng Moments? . . . . . . . . . . . . . . . . . . . . . . . . 6-57
What About the Regul ar i ty of a Wavel et ? . . . . . . . . . . . . 6-57
Are Wavel ets Useful i n Fi el ds Other Than Si gnal or
I mage Pr ocessi ng? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-58
What Functi ons Are Candi dates to Be a Wavel et? . . . . . . . 6-59
I s I t Easy to Bui l d a New Wavel et? . . . . . . . . . . . . . . . . . . . 6-59
What I s the Li nk Between Wavel et and Fouri er Anal ysi s? 6-60
Wavelet Families: Additional Discussion . . . . . . . . . . . . . . . . . 6-62
Daubechi es Wavel ets: dbN . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-63
Haar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-64
dbN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-64
Syml et Wavel ets: symN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-65
Coi fl et Wavel ets: coi fN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-66
Bi orthogonal Wavel et Pai r s: bi or Nr .Nd . . . . . . . . . . . . . . . . . . 6-67
Meyer Wavel et: meyr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-69
Battl e-Lemari e Wavel ets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-70
Mexi can Hat Wavel et: mexh . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-71
Morl et Wavel et: mor l . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-72
Summary of Wavelet Families and Associated Properties 6-73
Wavelet Applications: More Detail . . . . . . . . . . . . . . . . . . . . . . . . 6-74
Suppr essi ng Si gnal s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-74
Spl i tti ng Si gnal Components . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-77
Noi se Processi ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-77
xi Contents
De-Noi si ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-79
The Basi c One-Di mensi onal Model . . . . . . . . . . . . . . . . . . . . 6-80
De-Noi si ng Pr ocedur e Pri nci pl es . . . . . . . . . . . . . . . . . . . . . 6-80
Soft or Har d Thr eshol di ng? . . . . . . . . . . . . . . . . . . . . . . . . . . 6-81
Threshol d Sel ecti on Rul es . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-82
Deal i ng wi th Unscal ed Noi se and Non-Whi te Noi se . . . . . . 6-84
De-Noi si ng i n Acti on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-85
Extensi on to I mage De-Noi si ng . . . . . . . . . . . . . . . . . . . . . . 6-88
More About De-Noi si ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-89
Data Compressi on . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-90
Defaul t Val ues for De-Noi si ng and Compr essi on . . . . . . . . . . . 6-93
De-noi si ng. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-93
Compr essi on. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-93
About the Bi r ge-Massart Strategy . . . . . . . . . . . . . . . . . . . . 6-94
Wavelet Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-95
Fr om Wavel ets to Wavel et Packets: Decomposi ng the Detai l s 6-95
Wavel et Packets i n Acti on: An I ntroducti on . . . . . . . . . . . . . . 6-96
Exampl e 1: Anal yzi ng a Si ne Functi on . . . . . . . . . . . . . . . . 6-96
Exampl e 2: Anal yzi ng a Chi r p Si gnal . . . . . . . . . . . . . . . . . 6-97
Bui l di ng Wavel et Packets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-98
Wavel et Packet Atoms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-101
Or gani zi ng the Wavel et Packets . . . . . . . . . . . . . . . . . . . . . . . 6-104
Choosi ng the Opti mal Decomposi ti on . . . . . . . . . . . . . . . . . . . 6-105
Wavel et Packets 1-D Decomposi ti on Structure . . . . . . . . . . . 6-111
Wavel et Packets 2-D Decomposi ti on Structure . . . . . . . . . . . 6-113
Wavel et Packets for Compr essi on and De-Noi si ng . . . . . . . . 6-113
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-114
7
Adding Your Own Wavelets
Preparing to Add a New Wavelet Family . . . . . . . . . . . . . . . . . . 7-3
Choose the Wavel et Fami l y Ful l Name . . . . . . . . . . . . . . . . . . . 7-3
Choose the Wavel et Fami l y Shor t Name . . . . . . . . . . . . . . . . . . 7-3
Determi ne the Wavel et Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4
xii
Defi ne the Or der s of Wavel ets
Wi thi n the Gi ven Fami l y . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4
Bui l d a MAT-Fi l e or M-Fi l e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-5
Type 1 (Or thogonal wi th FI R Fi l ter) . . . . . . . . . . . . . . . . . . . 7-5
Type 2 (Bi orthogonal wi th FI R Fi l ter ) . . . . . . . . . . . . . . . . . . 7-5
Type 3 (Or thogonal wi th Scal e Functi on) . . . . . . . . . . . . . . . . 7-6
Type 4 (No FI R Fi l ter ; No Scal e Functi on) . . . . . . . . . . . . . . . 7-6
Defi ne the Effecti ve Suppor t . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7
How to Add a New Wavelet Family . . . . . . . . . . . . . . . . . . . . . . . . 7-8
Exampl e 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8
Exampl e 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-12
After Adding a New Wavelet Family . . . . . . . . . . . . . . . . . . . . . . 7-16
8
Reference
Commands Grouped by Function . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
A
GUI Reference
General Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-3
Col or Codi ng . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-3
Connectedness of Pl ots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-3
Usi ng the Mouse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-4
Maki ng Sel ecti ons and Acti vati ng Control s . . . . . . . . . . . . . . A-5
Tr ansl ati ng Pl ots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-5
Di spl ayi ng Posi ti on-Dependent I nfor mati on . . . . . . . . . . . . . A-5
Contr ol l i ng the Col or map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-6
Contr ol l i ng the Number of Col ors . . . . . . . . . . . . . . . . . . . . . . . . A-7
Contr ol l i ng the Col or ati on Mode . . . . . . . . . . . . . . . . . . . . . . . . . A-8
Customi zi ng Graphi cal Objects . . . . . . . . . . . . . . . . . . . . . . . . . . A-8
xiii Contents
Customi zi ng Pri nt Setti ngs . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-10
Usi ng Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-11
Continuous Wavelet Tool Features . . . . . . . . . . . . . . . . . . . . . . A-14
Wavelet 1-D Tool Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-15
Tr ee Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-15
More Di spl ay Opti ons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-15
Wavelet 2-D Tool Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-17
Wavelet Packet Tool Features (1-D and 2-D) . . . . . . . . . . . . . A-18
Node Acti on Functi onal i ty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-19
Wavelet Display Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-22
Wavelet Packet Display Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-23

Preface
Preface
xv
About the Authors
Mi chel Mi si ti , Geor ges Oppenhei m, and Jean-Mi chel Poggi are mathemati cs
pr ofessor s at Ecol e Centr al e de Lyon, Uni versi ty of Marne-La- Val l e and Pari s
10 Uni versi ty. Yves Mi si ti i s a r esearch engi neer speci al i zi ng i n Computer
Sci ences at Par i s 11 Uni ver si ty.
They ar e members of the Laboratoi re de Mathmati que Orsay-Pari s 11
Uni versi ty France.
Thei r fi el ds of i nterest ar e stati sti cal si gnal pr ocessi ng, stochasti c pr ocesses,
adapti ve contr ol , and wavel ets.
The authors group, whi ch was consti tuted more than ten years ago, has
publ i shed numerous theoreti cal paper s and car ri ed out appl i cati ons i n cl ose
col l aborati on wi th i ndustri al teams. For i nstance:
Robustness of the pi l oti ng l aw for a ci vi l i an space l auncher for whi ch an
expert system was devel oped
For ecasti ng of the el ectr i ci ty consumpti on by nonl i near methods
For ecasti ng of ai r pol l uti on
Acknowledgments
xvi
Acknowledgments
The authors wi sh to expr ess thei r grati tude to al l the col l eagues who di rectl y
or i ndi r ectl y contr i buted to the maki ng of the Wavel et Tool box.
Speci fi cal l y
For the wavel et questi ons to Pi er re-Gi l l es Lemar i -Ri eusset (Evr y) and
Yves Meyer (Par i s 9)
For the stati sti cal questi ons to Luci en Bi rg (Pari s 6) and Pascal Massart
(Par i s 11) whose l ast r esul t i s i ncl uded as a star ti ng poi nt of the de-noi si ng
al gori thm
To Davi d Donoho (Stanfor d) and to Anesti s Antoni adi s (Grenobl e) who ar e
used to gi vi ng generousl y so many val uabl e i deas
Col l eagues and fr i ends have hel ped us steadi l y: Sami r Akkouche (Ecol e
Centr al e de Lyon), Mark Asch (Par i s 11), Patr i ce Assouad (Pari s 11), Roger
Asti er (Pari s 11), Jean Cour sol (Par i s 11), Di di er Dacunha-Castel l e (Pari s 11),
Cl aude Deni au (Mar sei l l e), Patr i ck Fl andri n (Ecol e Nor mal e de Lyon), Er i c
Gal i n (Ecol e Centr al e de Lyon), Chr i sti ne Graffi gne (Pari s 5), Anatol i Judi tsky
(Rennes), Grard Kerkyachari an (Ami ens), Gr ard Mal gouyr es (Par i s 11),
Ol i vi er Nowak (Ecol e Central e de Lyon), Domi ni que Pi car d (Pari s 7), and
Franck Tar pi n-Ber nar d (Ecol e Central e de Lyon).
Sever al student groups have tested pr el i mi nary ver si ons.
One of our fi rst opportuni ti es to appl y the i deas of wavel ets connected wi th
si gnal anal ysi s and i ts model i ng occur red duri ng a cl ose and pl easant
cooperati on wi th the team Anal ysi s and For ecast of the El ectr i cal
Consumpti on of El ectr i ci t de Fr ance (Cl amar t-Pari s) di r ected fi rst by
Jean-Pi er re Desbr osses, then by Her v Laffaye and whi ch i ncl uded Xavi er
Brossat, Yves Devi l l e, and Mar i e-Madel ei ne Mar ti n.
Many thanks to those who tested and hel ped to refi ne the software and the
pri nted matter and at l ast to The MathWorks gr oup and speci al l y to Roy Lur i e,
Ji m Tung, and Br uce Sesnovi ch.
And fi nal l y, apol ogi es to those we may have omi tted.
Preface
xvii
What is the Wavelet Toolbox?
The Wavel et Tool box i s a col l ecti on of functi ons bui l t on the MATLAB


Techni cal Computi ng Envi ronment. I t provi des tool s for the anal ysi s and
synthesi s of si gnal s and i mages usi ng wavel ets and wavel et packets wi thi n the
framework of MATLAB.
The tool box provi des two categori es of tool s:
Command l i ne functi ons
Gr aphi cal i nter acti ve tool s
The fi rst categor y of tool s i s made up of functi ons that you can cal l di r ectl y fr om
the command l i ne or fr om your own appl i cati ons. Most of these functi ons are
M-fi l es, seri es of statements that i mpl ement speci al i zed wavel et anal ysi s or
synthesi s al gor i thms. You can vi ew the code for these functi ons usi ng the
fol l owi ng statement:
t ype f unct i on_name
You can vi ew the header of the functi on, the hel p part, usi ng the statement:
hel p f unct i on_name
A summary l i st of the Wavel et Tool box functi ons i s avai l abl e to you by typi ng
hel p wav el et
You can change the way any tool box functi on wor ks by copyi ng and renami ng
the M-fi l e, then modi fyi ng your copy. You can al so extend the tool box by addi ng
your own M-fi l es.
The second category of tool s i s a col l ecti on of graphi cal i nterface tool s that
afford access to extensi ve functi onal i ty. Access these tool s by typi ng
wav emenu
from the command l i ne.
W hat i sthe W avelet Toolbox?
xviii
How to Use This Guide
If you are new to wavelet analysis and synthesi s and need an overvi ew of the
concepts, r ead Chapter 1, Wavel ets: A New Tool for Si gnal Anal ysi s. I t
presents the mai n i deas wi thout mathemati cal compl exi ty.
After thi s you can r efer to Chapter 2 and Chapter 5, for i nstr ucti ons on usi ng
the wavel et and wavel et packet anal ysi s tool s, respecti vel y; Chapter 3, whi ch
di scusses pr acti cal appl i cati ons of wavel et anal ysi s; and Chapter 4, whi ch
provi des exampl es and a case study.
If you have experience with signal analysis and wavel ets, you may want to tur n
di rectl y to:
Chapter 2 and Chapter 5, for i nstructi ons on usi ng the wavel et and wavel et
packet anal ysi s tool s, r especti vel y.
Chapter 6, for a di scussi on of the techni cal underpi nni ngs of wavel et
anal ysi s.
Chapter 7, for i nstr ucti ons on extendi ng the Wavel et Tool box by addi ng your
own wavel ets.
All toolbox users shoul d l ook to Chapter 8 for compl ete r efer ence i nfor mati on
about the Wavel et Tool box command l i ne functi ons, and to Appendi x A for
more detai l ed i nfor mati on on usi ng the many functi ons provi ded by the
gr aphi cal tool s.
Preface
xix
For More Background
The Wavel et Tool box pr ovi des a compl ete i ntroducti on to wavel ets and
assumes no previ ous knowl edge of the ar ea. The tool box al l ows you to use
wavel et techni ques on your own data i mmedi atel y and devel op new i nsi ghts. I t
i s our hope that, through the use of these pr acti cal tool s, you may want to
expl or e the beauti ful underl yi ng mathemati cs and theory.
An excel l ent suppl ementar y text that presents a compl ementar y treatment of
wavel et theory and pr acti ce i s the book, Wavelets and Filter Banks by Gi l ber t
Strang and Tr uong Nguyen. Si gnal pr ocessi ng engi neers wi l l fi nd thi s book
especi al l y useful . I t offer s a cl ear and easy-to-understand i ntroducti on to two
centr al i deas - fi l ter banks for di screte si gnal s and wavel ets - and ful l y expl ai ns
the connecti on between them. Many exerci ses i n the book are drawn fr om the
Wavel et Tool box.
Wavelets and Filter Banks
Gi l bert Str ang and Tr uong Nguyen
Wel l esl ey-Cambri dge Press, 1996
I SBN 0-9614088-7-1
Avai l abl e from
Wel l esl ey-Cambri dge Press
Box 812060, Wel l esl ey
MA 02181, USA.
Phone: (617) 431-8488
Fax: (617) 253-4358
Emai l : gs @mat h. mi t . e du
The homepage for the book i s:
http://sai gon.ece.wi sc.edu/~waveweb/Tutori al s/book.html
Installati on
xx
Installation
To i nstal l thi s tool box on your computer, see the appropri ate pl atform-speci fi c
MATLAB I nstallation Guide. To deter mi ne i f the Wavel et Tool box i s al r eady
i nstal l ed on your system, check for a subdi r ector y named wav e l e t wi thi n the
mai n tool box di r ectory or fol der.
The Wavel et Tool box can per for m si gnal or i mage anal ysi s. Si nce MATLAB
stor es most number s i n doubl e pr eci si on, even a si ngl e i mage takes up a l ot of
memory. For i nstance, one copy of a 512-by-512 i mage uses 2 MB of memor y.
To avoi d Out of Me mor y er ror s, i t i s i mportant to al l ocate enough memory to
process var i ous i mage si zes.
The memor y can be real RAM or can be a combi nati on of RAM and vi r tual
memory. See your oper ati ng system documentati on for how to set up vi rtual
memory.
System Recommendations
Whi l e not a requi rement, we recommend you obtai n the Si gnal Processi ng and
I mage Processi ng Tool boxes to use i n conjuncti on wi th the Wavel et Tool box.
These tool boxes pr ovi de compl ementar y functi onal i ty that wi l l gi ve you
maxi mum fl exi bi l i ty i n anal yzi ng and pr ocessi ng si gnal s and i mages.
Thi s manual makes no assumpti on that your computer i s runni ng any other
MATLAB tool boxes.
Platform-Specific Details
Some detai l s of the use of the Wavel et Tool box may depend on your har dwar e
or oper ati ng system.
Windows Fonts
We recommend you set the system to use Smal l Fonts. Some of the l abel s i n
the GUI wi ndows may be i l l egi bl e i f l arge fonts ar e used.
Set thi s opti on by cl i cki ng the Di spl ay i con i n your desktops Control Panel
(accessi bl e through the SettingsControl Panel submenu i n Wi ndows 95). Use
the Font Size menu to change to Small Fonts. Youl l have to restart Wi ndows for
thi s change to take effect.
Preface
xxi
Other Platforms Fonts
We r ecommend you set the system to use standar d defaul t fonts. Some of the
l abel s i n the GUI wi ndows may be i l l egi bl e i f other fonts are used.
Mouse Compatibility
The Wavel et Tool box was desi gned for thr ee di sti nct types of mouse control :
For more i nformati on, see the secti on Usi ng the Mouse on page A-4.
Left Mouse Button Middle Mouse Button Right Mouse Button
Make sel ecti ons,
acti vate control s
Di spl ay a cross-hai r to
show posi ti on-dependent
i nfor mati on
Transl ate pl ots up and
down, and l eft and
ri ght
Shift + Option +
Typographi cal C onventi ons
xxii
Typographical Conventions
Thi s manual uses certai n typogr aphi cal conventi ons.
Font Use for
Monos pac e Commands, functi on names, and scr een
di spl ays; for exampl e, c onv.
Monospace I t al i cs Names of ar guments that are meant to be
r epl aced and not typed l i ter al l y; for i nstance:
c d di r ect or y.
I talics Book ti tl es, mathemati cal notati on, and the
i ntr oducti on of new terms.
Boldface Initial Cap Names of keys, such as the Return key and
menu i tems, such as the File menu.
Preface
xxiii

1
Wavel ets: A New Tool for
Si gnal Anal ysi s
1-3 Fourier Analysis
1-4 Short-Time Fourier Analysis
1-5 Wavelet Analysis
1-7 What is Wavelet Analysis?
1-8 The Continuous Wavelet Transform
1-16 The Discrete Wavelet Transform
1-20 Wavelet Reconstruction
1-27 Wavelet Packet Analysis
1-29 History of Wavelets
1-30 An Introduction to the Wavelet Families
1 Wavelets: A N ew Tool for Si gnal Analysi s
1-2
Ever ywhere around us ar e si gnal s that need to be anal yzed. Sei smi c tremors,
human speech, engi ne vi br ati ons, medi cal i mages, fi nanci al data, musi c, and
many other types of si gnal s have to be effi ci entl y encoded, compr essed, cl eaned
up, reconstr ucted, descr i bed, si mpl i fi ed, model ed, di sti ngui shed, or l ocated.
Wavel et anal ysi s i s a new and pr omi si ng set of tool s and techni ques for doi ng
thi s.
Fouri er Analysi s
1-3
Fourier Analysis
Si gnal anal ysts al ready have at thei r di sposal an i mpr essi ve ar senal of tool s.
Per haps the most wel l -known of these i s Fourier analysis, whi ch breaks down
a si gnal i nto consti tuent si nusoi ds of di ffer ent fr equenci es. Another way to
thi nk of Fouri er anal ysi s i s as a mathemati cal techni que for transforming our
vi ew of the si gnal fr om a ti me-based one to a frequency-based one.
For many si gnal s, Four i er anal ysi s i s extr emel y useful because the si gnal s
frequency content i s of great i mpor tance. So why do we need other techni ques,
l i ke wavel et anal ysi s?
Fouri er anal ysi s has a ser i ous drawback. I n transformi ng to the fr equency
domai n, ti me i nfor mati on i s l ost. When l ooki ng at a Fouri er tr ansfor m of a
si gnal , i t i s i mpossi bl e to tel l when a par ti cul ar event took pl ace.
I f a si gnal doesnt change much over ti me that i s, i f i t i s what i s cal l ed a
stationary si gnal thi s dr awback i snt very i mpor tant. However, most
i nter esti ng si gnal s contai n numer ous non-stati onary or tr ansi tory
character i sti cs: dr i ft, tr ends, abrupt changes, and begi nni ngs and ends of
events. These characteri sti cs are often the most i mpor tant par t of the si gnal ,
and Fouri er anal ysi s i s not sui ted to detecti ng them.
F
Fourier
Transform
A
m
p
l
i
t
u
d
e
Time
A
m
p
l
i
t
u
d
e
Frequency
1 Wavelets: A N ew Tool for Si gnal Analysi s
1-4
Short-Time Fourier Analysis
I n an effor t to cor rect thi s defi ci ency, Denni s Gabor (1946) adapted the Fouri er
tr ansfor m to anal yze onl y a smal l secti on of the si gnal at a ti me a techni que
cal l ed windowing the si gnal . Gabor s adaptati on, cal l ed the Short-Time Fourier
Transform (STFT), maps a si gnal i nto a two-di mensi onal functi on of ti me and
frequency.
The STFT repr esents a sort of compromi se between the ti me- and
frequency-based vi ews of a si gnal . I t provi des some i nformati on about both
when and at what fr equenci es a si gnal event occur s. However , you can onl y
obtai n thi s i nfor mati on wi th l i mi ted preci si on, and that preci si on i s deter mi ned
by the si ze of the wi ndow.
Whi l e the STFTs compromi se between ti me and fr equency i nformati on can be
useful , the dr awback i s that once you choose a par ti cul ar si ze for the ti me
wi ndow, that wi ndow i s the same for al l fr equenci es. Many si gnal s r equi r e a
more fl exi bl e approach one wher e we can var y the wi ndow si ze to determi ne
more accur atel y ei ther ti me or fr equency.
Short
Transform
A
m
p
l
i
t
u
d
e
Time
Time
Time
Fourier
F
r
e
q
u
e
n
c
y
window
Wavelet Analysi s
1-5
Wavelet Analysis
Wavel et anal ysi s repr esents the next l ogi cal step: a wi ndowi ng techni que wi th
var i abl e-si zed regi ons. Wavel et anal ysi s al l ows the use of l ong ti me i nter val s
where we want more preci se l ow fr equency i nformati on, and shorter regi ons
where we want hi gh frequency i nformati on.
Her es what thi s l ooks l i ke i n contr ast wi th the ti me-based, fr equency-based,
and STFT vi ews of a si gnal :
You may have noti ced that wavel et anal ysi s does not use a ti me-frequency
regi on, but rather a ti me-scale regi on. Wel l have more to say about the concept
of scal e l ater.
What Can Wavelet Analysis Do?
One major advantage affor ded by wavel ets i s the abi l i ty to per for m local
analysis that i s, to anal yze a l ocal i zed area of a l ar ger si gnal .
Consi der a si nusoi dal si gnal wi th a smal l di sconti nui ty one so ti ny as to be
bar el y vi si bl e. Such a si gnal easi l y coul d be gener ated i n the real wor l d,
perhaps by a power fl uctuati on or a noi sy swi tch.
Time
F
r
e
q
u
e
n
c
y
Time
S
c
a
l
e
STFT (Gabor) Wavelet Analysis
Time
Time Domain (Shannon)
F
r
e
q
u
e
n
c
y
Frequency Domain (Fourier)
Amplitude
A
m
p
l
i
t
u
d
e
Sinusoid with a small discontinuity
1 Wavelets: A N ew Tool for Si gnal Analysi s
1-6
A pl ot of the Fouri er coeffi ci ents (as provi ded by the f f t command) of thi s
si gnal shows nothi ng par ti cul ar l y i nteresti ng: a fl at spectrum wi th two peaks
r epr esenti ng a si ngl e frequency. However , a pl ot of wavel et coeffi ci ents cl ear l y
shows the exact l ocati on i n ti me of the di sconti nui ty.
Wavel et anal ysi s i s capabl e of r eveal i ng aspects of data that other si gnal
anal ysi s techni ques mi ss, aspects l i ke trends, breakdown poi nts,
di sconti nui ti es i n hi gher deri vati ves, and sel f-si mi l ari ty. Fur ther , because i t
affords a di ffer ent vi ew of data than those presented by tr adi ti onal techni ques,
wavel et anal ysi s can often compress or de-noi se a si gnal wi thout appreci abl e
degr adati on.
I ndeed, i n thei r br i ef hi story wi thi n the si gnal pr ocessi ng fi el d, wavel ets have
al r eady proven themsel ves to be an i ndi spensabl e addi ti on to the anal ysts
col l ecti on of tool s and conti nue to enjoy a burgeoni ng popul ari ty today.
Fourier Coefficients Wavelet Coefficients
W hat i sWavelet Analysi s?
1-7
What is Wavelet Analysis?
Now that we know some si tuati ons when wavel et anal ysi s i s useful , i t i s
wor thwhi l e aski ng the questi ons What i s wavel et anal ysi s? and even more
fundamental l y, What i s a wavel et?
A wavel et i s a wavefor m of effecti vel y l i mi ted dur ati on that has an average
val ue of zer o.
Compare wavel ets wi th si ne waves, whi ch ar e the basi s of Four i er anal ysi s.
Si nusoi ds do not have l i mi ted dur ati on they extend from mi nus to pl us
i nfi ni ty. And wher e si nusoi ds ar e smooth and predi ctabl e, wavel ets tend to be
i rr egul ar and asymmetri c.
Fouri er anal ysi s consi sts of breaki ng up a si gnal i nto si ne waves of var i ous
frequenci es. Si mi l arl y, wavel et anal ysi s i s the breaki ng up of a si gnal i nto
shi fted and scal ed versi ons of the ori gi nal (or mother) wavel et.
Just l ooki ng at pi ctur es of wavel ets and si ne waves, you can see i ntui ti vel y that
si gnal s wi th sharp changes mi ght be better anal yzed wi th an i rr egul ar wavel et
than wi th a smooth si nusoi d, just as some foods are better handl ed wi th a fork
than a spoon.
I t al so makes sense that l ocal features can be descri bed better wi th wavel ets,
whi ch have l ocal extent.
Number of Dimensions
Thus far , weve di scussed onl y one-di mensi onal data, whi ch encompasses most
ordi nary si gnal s. However, wavel et anal ysi s can be appl i ed to two-di mensi onal
data images; and, i n pr i nci pl e, to hi gher-di mensi onal data.
Thi s tool box uses onl y one- and two-di mensi onal anal ysi s techni ques.
Sine Wave Wavelet (db10)
... ...
1 Wavelets: A N ew Tool for Si gnal Analysi s
1-8
The Continuous Wavelet Transform
Mathemati cal l y, the process of Fouri er anal ysi s i s repr esented by the Fourier
transform:
whi ch i s the sum over al l ti me of the si gnal f(t) mul ti pl i ed by a compl ex
exponenti al . (Recal l that a compl ex exponenti al can be br oken down i nto r eal
and i magi nary si nusoi dal components.)
The resul ts of the tr ansform are the Fourier coefficients , whi ch when
mul ti pl i ed by a si nusoi d of appropri ate frequency , yi el d the consti tuent
si nusoi dal components of the or i gi nal si gnal . Graphi cal l y, the pr ocess l ooks
l i ke:
Si mi l arl y, the continuous wavelet transform (CWT) i s defi ned as the sum over
al l ti me of the si gnal mul ti pl i ed by scal ed, shi fted versi ons of the wavel et
functi on :
The resul t of the CWT ar e many wavelet coefficients C, whi ch are a functi on of
scal e and posi ti on.
F ( ) f t ( )e
j t

dt = ,
F ( )

Signal
...
Constituent sinusoids of different frequencies
Fourier
Transform

C scale position , ( ) f t ( ) scale position t , , ( ) t d


=
The C onti nuousW avelet Transform
1-9
Mul ti pl yi ng each coeffi ci ent by the appr opr i atel y scal ed and shi fted wavel et
yi el ds the consti tuent wavel ets of the or i gi nal si gnal :
Scaling
Weve al r eady al l uded to the fact that wavel et anal ysi s produces a ti me-scal e
vi ew of a si gnal , and now were tal ki ng about scal i ng and shi fti ng wavel ets.
What exactl y do we mean by scale i n thi s context?
Scal i ng a wavel et si mpl y means stretchi ng (or compressi ng) i t.
To go beyond col l oqui al descr i pti ons such as str etchi ng, we i ntroduce the
scale factor, often denoted by the l etter I f were tal ki ng about si nusoi ds, for
exampl e, the effect of the scal e factor i s ver y easy to see:
Signal Constituent wavelets of different scales and positions
...
Wavelet
Transform
a.
f t ( ) t ( ) sin =
f t ( ) 2t ( ) sin =
f t ( ) 4t ( ) sin =
a ; 1 =
; a
1
2
--- =
; a
1
4
--- =
1 Wavelets: A N ew Tool for Si gnal Analysi s
1-10
The scal e factor wor ks exactl y the same wi th wavel ets. The smal l er the scal e
factor, the mor e compressed the wavel et.
I t i s cl ear fr om the di agrams that, for a si nusoi d the scal e factor i s
r el ated (i nversel y) to the radi an fr equency Si mi l ar l y, wi th wavel et anal ysi s,
the scal e i s r el ated to the frequency of the si gnal . Wel l r etur n to thi s topi c l ater .
Shifting
Shi fti ng a wavel et si mpl y means del ayi ng (or hasteni ng) i ts onset.
Mathemati cal l y, del ayi ng a functi on by k i s r epr esented by :
Five Easy Steps to a Continuous Wavelet Transform
The conti nuous wavel et transform i s the sum over al l ti me of the si gnal
mul ti pl i ed by scal ed, shi fted versi ons of the wavel et. Thi s pr ocess pr oduces
wavel et coeffi ci ents that ar e a functi on of scal e and posi ti on.
f t ( ) t ( ) =
f t ( ) 2t ( ) =
f t ( ) 4t ( ) =
; a 1 =
; a
1
2
--- =
; a
1
4
--- =
t ( ), sin a
.
f t ( ) f t k ( )
Wavelet function
t ( ) t k ( )
Shifted wavelet function
The C onti nuousW avelet Transform
1-11
I ts real l y a very si mpl e process. I n fact, here ar e the fi ve steps of an easy r eci pe
for cr eati ng a CWT:
1 Take a wavel et and compare i t to a secti on at the star t of the ori gi nal si gnal .
2 Cal cul ate a number , C, that represents how cl osel y cor rel ated the wavel et i s
wi th thi s secti on of the si gnal . The hi gher C i s, the mor e the si mi l ari ty. Note
that the resul ts wi l l depend on the shape of the wavel et you choose.
3 Shi ft the wavel et to the ri ght and r epeat steps 1 and 2 unti l youve covered
the whol e si gnal .
4 Scal e (stretch) the wavel et and r epeat steps 1 through 3.
5 Repeat steps 1 thr ough 4 for al l scal es.
Signal
Wavelet
C = 0.0102
Signal
Wavelet
Signal
Wavelet
C = 0.2247
1 Wavelets: A N ew Tool for Si gnal Analysi s
1-12
When your e done, youl l have the coeffi ci ents produced at di fferent scal es by
di fferent secti ons of the si gnal . The coeffi ci ents consti tute the r esul ts of a
r egressi on of the ori gi nal si gnal perfor med on the wavel ets.
How to make sense of al l these coeffi ci ents? You coul d make a pl ot on whi ch the
x-axi s r epresents posi ti on al ong the si gnal (ti me), the y-axi s represents scal e,
and the col or at each x-y poi nt r epr esents the magni tude of the wavel et
coeffi ci ent C. These ar e the coeffi ci ent pl ots gener ated by the graphi cal tool s.
These coeffi ci ent pl ots r esembl e a bumpy sur face vi ewed from above. I f you
coul d l ook at the same sur face fr om the si de, you mi ght see somethi ng l i ke thi s:
The conti nuous wavel et tr ansfor m coeffi ci ent pl ots ar e pr eci sel y the ti me-scal e
vi ew of the si gnal we referr ed to ear l i er. I t i s a di ffer ent vi ew of si gnal data than
the ti me-fr equency Fouri er vi ew, but i t i s not unr el ated.
Large
Coefficients
Small
Coefficients
S
c
a
l
e
Time
Time
S
c
a
l
e
C
o
e
f
s
The C onti nuousW avelet Transform
1-13
Scale and Frequency
Noti ce that the scal es i n the coeffi ci ents pl ot (shown as y-axi s l abel s) run from
1 to 31. Recal l that the hi gher scal es corr espond to the most stretched
wavel ets. The mor e str etched the wavel et, the l onger the porti on of the si gnal
wi th whi ch i t i s bei ng compared, and thus the coar ser the si gnal features bei ng
measured by the wavel et coeffi ci ents.
Thus, ther e i s a cor respondence between wavel et scal es and fr equency as
reveal ed by wavel et anal ysi s:
Low scal e a Compr essed wavel et Rapi dl y changi ng detai l s Hi gh
fr equency .
Hi gh scal e a Stretched wavel et Sl owl y changi ng, coarse featur es Low
fr equency .
The Scale of Nature
I ts i mpor tant to understand that the fact that wavel et anal ysi s does not
produce a ti me-frequency vi ew of a si gnal i s not a weakness but a strength of
the techni que.
Not onl y i s ti me-scal e a di fferent way to vi ew data, i t i s a very natur al way to
vi ew data deri vi ng fr om a gr eat number of natural phenomena.
Signal
Wavelet
Low scale High scale

1 Wavelets: A N ew Tool for Si gnal Analysi s


1-14
Consi der a l unar l andscape, whose ragged sur face (si mul ated bel ow) i s a resul t
of centuri es of bombardment by meteori tes whose si zes range from gi ganti c
boul der s to dust specks.
I f we thi nk of thi s sur face i n cross-secti on as a one-di mensi onal si gnal , then i t
i s reasonabl e to thi nk of the si gnal as havi ng components of di fferent scal es
l ar ge featur es carved by the i mpacts of l arge meteori tes, and fi ner featur es
abr aded by smal l meteor i tes.
Here i s a case wher e thi nki ng i n terms of scal e makes much mor e sense than
thi nki ng i n terms of frequency. I nspecti on of the CWT coeffi ci ents pl ot for thi s
si gnal r eveal s patter ns among scal es and shows the si gnal s possi bl y fr actal
natur e.
Even though thi s si gnal i s arti fi ci al , many natur al phenomena fr om the
i ntri cate branchi ng of bl ood vessel s and trees, to the jagged sur faces of
mountai ns and fractur ed metal s l end themsel ves to an anal ysi s of scal e.
The C onti nuousW avelet Transform
1-15
Whats Continuous About the Continuous
Wavelet Transform?
Any si gnal processi ng performed on a computer usi ng real -wor l d data must be
performed on a di screte si gnal that i s, on a si gnal that has been measured
at di screte ti me i nterval s. I t i s i mportant to remember that the conti nuous
wavel et transform i s al so oper ati ng i n di scr ete ti me. So what exactl y i s
conti nuous about i t?
Whats conti nuous about the CWT, and what di sti ngui shes i t from the
di screte wavel et tr ansfor m (to be di scussed i n the fol l owi ng secti on), are the
scal es at whi ch i t oper ates.
Unl i ke the di scr ete wavel et tr ansfor m, the CWT can oper ate at ever y scal e,
from that of the or i gi nal si gnal up to some maxi mum scal e whi ch you
determi ne by tr adi ng off your need for detai l ed anal ysi s wi th avai l abl e
computati onal horsepower .
The CWT i s al so conti nuous i n terms of shi fti ng: duri ng computati on, the
anal yzi ng wavel et i s shi fted smoothl y over the ful l domai n of the anal yzed
functi on.
1 Wavelets: A N ew Tool for Si gnal Analysi s
1-16
The Discrete Wavelet Transform
Cal cul ati ng wavel et coeffi ci ents at every possi bl e scal e i s a fai r amount of wor k,
and i t generates an awful l ot of data. What i f we choose onl y a subset of scal es
and posi ti ons at whi ch to make our cal cul ati ons?
I t tur ns out, r ather r emarkabl y, that i f we choose scal es and posi ti ons based on
power s of two so-cal l ed dyadic scal es and posi ti ons then our anal ysi s wi l l
be much more effi ci ent and just as accur ate. We obtai n just such an anal ysi s
from the discrete wavelet transform (DWT).
An effi ci ent way to i mpl ement thi s scheme usi ng fi l ters was devel oped i n 1988
by Mal l at (see [Mal 89]). The Mal l at al gori thm i s i n fact a cl assi cal scheme
known i n the si gnal processi ng communi ty as a two-channel subband coder
(see p. 1 of the book Wavelets and Filter Banks, by Str ang and Nguyen).
Thi s very practi cal fi l ter i ng al gor i thm yi el ds a fast wavelet transform a box
i nto whi ch a si gnal passes, and out of whi ch wavel et coeffi ci ents qui ckl y
emerge. Lets exami ne thi s i n more depth.
One-Stage Filtering: Approximations and Details
For many si gnal s, the l ow-fr equency content i s the most i mportant part. I t i s
what gi ves the si gnal i ts i denti ty. The hi gh-frequency content, on the other
hand, i mpar ts fl avor or nuance. Consi der the human voi ce. I f you r emove the
hi gh-fr equency components, the voi ce sounds di fferent, but you can sti l l tel l
whats bei ng sai d. However, i f you r emove enough of the l ow-fr equency
components, you hear gi bberi sh.
I t i s for thi s reason that, i n wavel et anal ysi s, we often speak of approximations
and details.
The Di screte W avelet Transform
1-17
The appr oxi mati ons ar e the hi gh-scal e, l ow-fr equency components of the
si gnal . The detai l s are the l ow-scal e, hi gh-frequency components. The fi l teri ng
process, at i ts most basi c l evel , l ooks l i ke thi s:
The ori gi nal si gnal , S, passes through two compl ementar y fi l ter s and emer ges
as two si gnal s.
Unfortunatel y, i f we actual l y perform thi s operati on on a r eal di gi tal si gnal , we
wi nd up wi th twi ce as much data as we star ted wi th. Suppose, for i nstance,
that the or i gi nal si gnal S consi sts of 1000 sampl es of data. Then the
approxi mati on and the detai l wi l l each have 1000 sampl es, for a total of 2000.
To cor rect thi s pr obl em, we i ntr oduce the noti on of downsampling. Thi s si mpl y
means throwi ng away every second data poi nt. Whi l e doi ng thi s i ntroduces
aliasing (a type of err or, see p. 91 of the book Wavelets and Filter Banks, by
Str ang and Nguyen) i n the si gnal components, i t turns out we can account for
thi s l ater on i n the process.
The pr ocess on the r i ght, whi ch i ncl udes downsampl i ng, produces DWT
coeffi ci ents.
To gai n a better appreci ati on of thi s pr ocess, l ets perform a one-stage di screte
wavel et transform of a si gnal . Our si gnal wi l l be a pur e si nusoi d wi th
hi gh-frequency noi se added to i t.
S
highpass
A D
Filters
lowpass
S
cD
cA
1000 samples
~500 coefs
~500 coefs
S
D
A
1000 samples
~1000 samples
~1000 samples
1 Wavelets: A N ew Tool for Si gnal Analysi s
1-18
Here i s our schemati c di agram wi th real si gnal s i nser ted i nto i t:
The MATLAB code needed to generate s , cD, and c A i s:
s = s i n( 20. *l i ns pac e( 0, pi , 1000) ) + 0. 5. *r and( 1, 1000) ;
[ cA, c D] = dwt ( s , ' db2' ) ;
where db2 i s the name of the wavel et we want to use for the anal ysi s.
Noti ce that the detai l coeffi ci ents c D consi st mai nl y of the hi gh-frequency noi se,
whi l e the approxi mati on coeffi ci ents cA contai n much l ess noi se than does the
ori gi nal si gnal .
[ l e ngt h( cA) l e ngt h( cD) ]
ans =
501 501
You may obser ve that the actual l engths of the detai l and appr oxi mati on
coeffi ci ent vectors ar e sl i ghtl y more than hal f the l ength of the ori gi nal si gnal .
Thi s has to do wi th the fi l teri ng process, whi ch i s i mpl emented by convol vi ng
the si gnal wi th a fi l ter. The convol uti on smear s the si gnal , i ntr oduci ng
sever al extr a sampl es i nto the resul t.
1000 data points
~500 DWT coefficients
~500 DWT coefficients
S
cD High Frequency
cA Low Frequency
The Di screte W avelet Transform
1-19
Multiple-Level Decomposition
The decomposi ti on process can be i terated, wi th successi ve appr oxi mati ons
bei ng decomposed i n turn, so that one si gnal i s broken down i nto many
l ower -r esol uti on components. Thi s i s cal l ed the wavelet decomposition tree.
Looki ng at a si gnal s wavel et decomposi ti on tr ee can yi el d val uabl e
i nfor mati on.
Number of Levels
Si nce the anal ysi s pr ocess i s i terati ve, i n theory i t can be conti nued
i ndefi ni tel y. I n real i ty, the decomposi ti on can pr oceed onl y unti l the i ndi vi dual
detai l s consi st of a si ngl e sampl e or pi xel . I n pr acti ce, youl l sel ect a sui tabl e
number of l evel s based on the natur e of the si gnal , or on a sui tabl e cri teri on
such as entropy (see Chapter 6 for detai l s).
S
cA
1
cD
1
cA
2
cD
2
cA
3
cD
3
S
cA
1
cD
1
cA
2
cD
2
cA
3
cD
3
1 Wavelets: A N ew Tool for Si gnal Analysi s
1-20
Wavelet Reconstruction
Weve l ear ned how the di scr ete wavel et tr ansfor m can be used to anal yze, or
decompose, si gnal s and i mages. The other hal f of the stor y i s how those
components can be assembl ed back i nto the or i gi nal si gnal wi th no l oss of
i nfor mati on. Thi s process i s cal l ed reconstruction, or synthesis. The
mathemati cal mani pul ati on that effects synthesi s i s cal l ed the inverse discrete
wavelet transform (I DWT).
To synthesi ze a si gnal i n our tool box, we r econstruct i t from the wavel et
coeffi ci ents:
Wher e wavel et anal ysi s i nvol ves fi l ter i ng and downsampl i ng, the wavel et
r econstructi on pr ocess consi sts of upsampl i ng and fi l ter i ng. Upsampl i ng i s the
pr ocess of l engtheni ng a si gnal component by i nserti ng zer os between sampl es:
The wavel et tool box i ncl udes commands, l i ke i dwt and wav er ec , that per for m
one-l evel or mul ti -l evel r econstructi on, r especti vel y, on the components of
one-di mensi onal si gnal s. These commands have thei r two-di mensi onal
anal ogues, i dwt 2 and wav er e c2.
S
H'
L'
H'
L'
Signal component Upsampled signal component
W avelet Reconstructi on
1-21
Reconstruction Filters
The fi l teri ng part of the r econstructi on pr ocess al so bear s some di scussi on,
because i t i s the choi ce of fi l ters that i s cr uci al i n achi evi ng per fect
reconstr ucti on of the or i gi nal si gnal .
That perfect r econstructi on i s even possi bl e i s noteworthy. Recal l that the
downsampl i ng of the si gnal components per formed duri ng the decomposi ti on
phase i ntroduces a di storti on cal l ed al i asi ng. I t turns out that by careful l y
choosi ng fi l ter s for the decomposi ti on and reconstructi on phases that ar e
cl osel y r el ated (but not i denti cal ), we can cancel out the effects of al i asi ng.
Thi s was the breakthrough made possi bl e by the work of I ngr i d Daubechi es.
A techni cal di scussi on of how to desi gn these fi l ter s can be found i n p. 347 of
the book Wavelets and Filter Banks, by Strang and Nguyen. The l ow- and
hi ghpass decomposi ti on fi l ters (L and H), together wi th thei r associ ated
reconstr ucti on fi l ters (L' and H' ), for m a system of what are cal l ed quadrature
mirror filters:
Reconstructing Approximations and Details
We have seen that i t i s possi bl e to reconstr uct our or i gi nal si gnal from the
coeffi ci ents of the appr oxi mati ons and detai l s.
S S
Decomposition Reconstruction
H
L
H'
L'
cD
cA
S
H'
L'
cD
cA
1000 samples
~500 coefs
~500 coefs
1 Wavelets: A N ew Tool for Si gnal Analysi s
1-22
I t i s al so possi bl e to r econstr uct the appr oxi mati ons and detai l s themsel ves
from thei r coeffi ci ent vectors. As an exampl e, l ets consi der how we woul d
r econstruct the fi rst-l evel approxi mati on A1 fr om the coeffi ci ent vector cA1.
We pass the coeffi ci ent vector c A1 through the same process we used to
r econstruct the ori gi nal si gnal . However, i nstead of combi ni ng i t wi th the
l evel -one detai l cD1, we feed i n a vector of zer os i n pl ace of the detai l s:
The process yi el ds a r econstructed approximation A1, whi ch has the same
l ength as the ori gi nal si gnal S and whi ch i s a real approxi mati on of i t.
Si mi l arl y, we can r econstr uct the fi r st-l evel detai l D1, usi ng the anal ogous
pr ocess:
The reconstr ucted detai l s and appr oxi mati ons ar e tr ue consti tuents of the
ori gi nal si gnal . I n fact, we fi nd when we combi ne them that:
Note that the coeffi ci ent vector s cA1 and c D1 because they were produced by
downsampl i ng, contai n al i asi ng di stor ti on, and are onl y hal f the l ength of the
ori gi nal si gnal cannot di rectl y be combi ned to r eproduce the si gnal . I t is
necessary to reconstruct the approximations and details before combining them.
A1
H'
L'
0
c A1
1000 samples
~500 zeros
~500 coefs
D1
H'
L'
c D1
0
1000 samples
~500 coefs
~500 zeros
A
1
D
1
+ S =
W avelet Reconstructi on
1-23
Extendi ng thi s techni que to the components of a mul ti -l evel anal ysi s, we fi nd
that si mi l ar r el ati onshi ps hol d for al l the reconstr ucted si gnal consti tuents.
That i s, ther e ar e sever al ways to reassembl e the or i gi nal si gnal :
Relationship of Filters to Wavelet Shapes
I n the secti on Reconstructi on Fi l ters on page 1-21, we spoke of the
i mportance of choosi ng the ri ght fi l ters. I n fact, the choi ce of fi l ters not onl y
determi nes whether per fect reconstr ucti on i s possi bl e, i t al so deter mi nes the
shape of the wavel et we use to per for m the anal ysi s.
I n fact, to construct a wavel et of some practi cal uti l i ty, you sel dom start by
drawi ng a wavefor m. I nstead, i t usual l y makes more sense to desi gn the
appropr i ate quadr atur e mi r ror fi l ter s and then use them to create the
wavefor m. Lets see how thi s i s done by focusi ng on an exampl e.
Consi der the l owpass reconstructi on fi l ter (L' ) for the db2 wavel et.
The fi l ter coeffi ci ents can be obtai ned from the dbaux command:
Lpr i me = dbaux ( 2)
Lpr i me =
0. 3415 0. 5915 0. 1585 0. 0915
S
A
1
D
1
A
2
D
2
A
3
D
3
= A
2
D
2
D
1
+ +
S A
1
D
1
+ =
= A
3
D
3
D
2
D
1
+ + +
Reconstructed
Signal
Components
db2 wavelet
1 Wavelets: A N ew Tool for Si gnal Analysi s
1-24
I f we r everse the order of thi s vector (see wr e v), and then mul ti pl y every second
sampl e by 1, we obtai n the hi ghpass fi l ter H' :
Hpr i me =
0. 0915 0. 1585 0. 5915 0. 3415
Next, upsampl e Hpr i me by two (see dyadup), i nser ti ng zer os i n al ternate
posi ti ons:
HU =
0. 0915 0 0. 1585 0 0. 5915 0 0. 3415 0
Fi nal l y, convol ve the upsampl ed vector wi th the ori gi nal l owpass fi l ter:
H2 = conv( HU, Lpr i me ) ;
pl ot ( H2)
I f we i ter ate thi s pr ocess sever al mor e ti mes, repeatedl y upsampl i ng and
convol vi ng the r esul tant vector wi th the four-el ement fi l ter vector Lpr i me , a
patter n begi ns to emerge:
W avelet Reconstructi on
1-25
The cur ve begi ns to l ook progressi vel y more l i ke the db2 wavel et. Thi s means
that the wavel ets shape i s determi ned enti rel y by the coeffi ci ents of the
reconstr ucti on fi l ter s.
Thi s r el ati onshi p has profound i mpl i cati ons. I t means that you cannot choose
just any shape, cal l i t a wavel et, and perfor m an anal ysi s. At l east, you cant
choose an ar bi tr ary wavel et waveform i f you want to be abl e to r econstruct the
ori gi nal si gnal accuratel y. You are compel l ed to choose a shape deter mi ned by
quadrature mi rr or decomposi ti on fi l ter s.
The Scaling Function
Weve seen the i nter rel ati on of wavel ets and quadr ature mi rr or fi l ters. The
wavel et functi on i s deter mi ned by the hi ghpass fi l ter , whi ch al so pr oduces
the detai l s of the wavel et decomposi ti on.
There i s an addi ti onal functi on associ ated wi th some but not al l wavel ets. Thi s
i s the so-cal l ed scaling function, . The scal i ng functi on i s ver y si mi l ar to the
wavel et functi on. I t i s determi ned by the l owpass quadrature mi rr or fi l ters,
and thus i s associ ated wi th the appr oxi mati ons of the wavel et decomposi ti on.
I n the same way that i terati vel y upsampl i ng and convol vi ng the hi ghpass fi l ter
produces a shape approxi mati ng the wavel et functi on, i terati vel y upsampl i ng
and convol vi ng the l owpass fi l ter produces a shape appr oxi mati ng the scal i ng
functi on.
Multistep Decomposition and Reconstruction
A mul ti step anal ysi s-synthesi s process can be represented as:

S 1000
~250
~250
S 1000
~500
Analysis
Decomposition
DWT
Synthesis
Reconstruction
IDWT
Wavelet
Coefficients
. . . . . .
H
L
H
L
H'
L'
H'
L'
1 Wavelets: A N ew Tool for Si gnal Analysi s
1-26
Thi s process i nvol ves thr ee aspects: br eaki ng up a si gnal to obtai n the wavel et
coeffi ci ents, modi fyi ng the wavel et coeffi ci ents, and r eassembl i ng the si gnal
from the coeffi ci ents.
Weve al r eady di scussed decomposi ti on and r econstructi on at some l ength. Of
course, ther e i s no poi nt br eaki ng up a si gnal merel y to have the sati sfacti on of
i mmedi atel y r econstructi ng i t. We perform wavel et anal ysi s because the
coeffi ci ents thus obtai ned have many known uses, de-noi si ng and compressi on
bei ng for emost among them.
But wavel et anal ysi s i s sti l l a new and emergi ng fi el d. Many unchar ted uses of
the wavel et coeffi ci ents no doubt l i e i n wai t. The Wavel et Tool box can be a
means of expl ori ng possi bl e uses and hi therto unknown appl i cati ons of wavel et
anal ysi s. Expl or e the tool box functi ons and see what you di scover .
Wavelet Packet Analysi s
1-27
Wavelet Packet Analysis
The wavelet packet method i s a general i zati on of wavel et decomposi ti on that
offer s a r i cher range of possi bi l i ti es for si gnal anal ysi s.
I n wavel et anal ysi s, a si gnal i s spl i t i nto an approxi mati on and a detai l . The
approxi mati on i s then i tsel f spl i t i nto a second-l evel appr oxi mati on and detai l ,
and the process i s repeated. For an n-l evel decomposi ti on, ther e ar e n+1
possi bl e ways to decompose or encode the si gnal .
I n wavel et packet anal ysi s, the detai l s as wel l as the approxi mati ons can be
spl i t. Thi s yi el ds 2
n
di fferent ways to encode the si gnal . Thi s i s the wavelet
packet decomposition tree:
For i nstance, wavel et packet anal ysi s al l ows the si gnal S to be represented as
A1 + AAD3 + DAD3 + DD2. Thi s i s an exampl e of a r epr esentati on that i s not
possi bl e wi th ordi nary wavel et anal ysi s.
S
A
1
D
1
A
2
D
2
A
3
D
3
= A
2
D
2
D
1
+ +
S A
1
D
1
+ =
= A
3
D
3
D
2
D
1
+ + +
S
A
1
D
1
AA
2
DA
2
AAA
3
DAA
3
AD
2
DD
2
ADA
3
DDA
3
AAD
3
DAD
3
ADD
3
DDD
3
1 Wavelets: A N ew Tool for Si gnal Analysi s
1-28
Choosi ng one out of al l these possi bl e encodi ngs pr esents an i nter esti ng
pr obl em. I n thi s tool box, we use an entropy-based criterion to sel ect the most
sui tabl e decomposi ti on of a gi ven si gnal . Thi s means we l ook at each node of
the decomposi ti on tree and quanti fy the i nfor mati on to be gai ned by
perfor mi ng each spl i t.
Si mpl e and effi ci ent al gori thms exi st for both wavel et packet decomposi ti on
and opti mal decomposi ti on sel ecti on. Thi s tool box uses an adapti ve fi l teri ng
al gori thm, based on work by Coi fman and Wi ckerhauser, wi th di r ect
appl i cati ons i n opti mal si gnal codi ng and data compressi on.
Such al gori thms al l ow the Wavelet Packet 1-D and Wavelet Packet 2-D
tool s to i ncl ude Best Level and Best Tr ee features that opti mi ze the
decomposi ti on both gl obal l y and wi th r espect to each node.
Hi story of W avelets
1-29
History of Wavelets
From an hi stori cal poi nt of vi ew, wavel et anal ysi s i s a new method, though i ts
mathemati cal underpi nni ngs date back to the work of Joseph Fouri er i n the
ni neteenth centur y. Fouri er l ai d the foundati ons wi th hi s theor i es of frequency
anal ysi s, whi ch pr oved to be enormousl y i mportant and i nfl uenti al .
The attenti on of resear chers gr adual l y tur ned fr om fr equency-based anal ysi s
to scal e-based anal ysi s when i t started to become cl ear that an approach
measuri ng average fl uctuati ons at di ffer ent scal es mi ght prove l ess sensi ti ve to
noi se.
The fi r st r ecorded menti on of the ter m wavel et was i n 1909, i n a thesi s by
Al fred Haar.
The concept of wavel ets i n i ts pr esent theor eti cal for m was fi rst pr oposed by
Jean Morl et and the team at the Mar sei l l e Theoreti cal Physi cs Center worki ng
under Al ex Grossmann i n Fr ance.
The methods of wavel et anal ysi s have been devel oped mai nl y by Y. Meyer and
hi s col l eagues, who have ensured the methods di ssemi nati on. The mai n
al gor i thm dates back to the wor k of Stephane Mal l at i n 1988. Si nce then,
resear ch on wavel ets has become i nternati onal . Such r esearch i s parti cul arl y
acti ve i n the Uni ted States, where i t i s spear headed by the work of sci enti sts
such as I ngri d Daubechi es, Ronal d Coi fman, and Vi ctor Wi ckerhauser .
1 Wavelets: A N ew Tool for Si gnal Analysi s
1-30
An Introduction to the Wavelet Families
Sever al fami l i es of wavel ets that have proven to be especi al l y useful are
i ncl uded i n thi s tool box. What fol l ows i s an i ntr oducti on to these wavel et
fami l i es. To expl ore wavel et fami l i es on your own, check out the Wavelet
Display tool :
1 Type wav eme nu from the MATLAB command l i ne. The Wavel et Tool box Mai n
Menu appears.
2 Cl i ck on the Wavelet Display menu i tem. The Wavelet Display tool
appear s.
3 Sel ect a fami l y from the Wavelet menu at the top ri ght of the tool .
4 Cl i ck the Display button. Pi ctures of the wavel ets and thei r associ ated
fi l ters appear.
5 Obtai n mor e i nfor mati on by cl i cki ng on the i nformati on buttons l ocated at
the r i ght.
An Introducti on to the W avelet Fami li es
1-31
Haar
Any di scussi on of wavel ets begi ns wi th Haar, the fi r st and si mpl est. Haar i s
di sconti nuous, and resembl es a step functi on. I t represents the same wavel et
as Daubechi es db1. See "Haar " on page 64 for more detai l .
Daubechies
I ngri d Daubechi es, one of the br i ghtest stars i n the wor l d of wavel et resear ch,
i nvented what are cal l ed compactl y-suppor ted or thonor mal wavel ets thus
maki ng di scr ete wavel et anal ysi s practi cabl e.
The names of the Daubechi es fami l y wavel ets are wri tten dbN, where N i s the
order, and db the sur name of the wavel et. The db1 wavel et, as menti oned
above, i s the same as Haar . Her e ar e the next ni ne members of the fami l y:
You can obtai n a survey of the mai n properti es of thi s fami l y by typi ng
wav ei nf o( ' db' ) fr om the MATLAB command l i ne. See Daubechi es Wavel ets:
dbN on page 6-63 for more detai l .
db2 db3 db4 db5 db6
db7 db8 db9 db10
1 Wavelets: A N ew Tool for Si gnal Analysi s
1-32
Biorthogonal
Thi s fami l y of wavel ets exhi bi ts the property of l i near phase, whi ch i s needed
for si gnal and i mage r econstructi on. By usi ng two wavel ets, one for
decomposi ti on and the other for reconstr ucti on i nstead of the same si ngl e one,
i nteresti ng properti es are der i ved.
bior1.3 bior1.5
bior2.2 bior2.4
bior2.6 bior2.8
bior3.1 bior3.3
bior3.5 bior3.7
bior5.5 bior6.8
bior3.9 bior4.4
An Introducti on to the W avelet Fami li es
1-33
You can obtai n a survey of the mai n properti es of thi s fami l y by typi ng
wav ei nf o( ' bi or ' ) fr om the MATLAB command l i ne. See Bi orthogonal
Wavel et Pai rs: bi orNr .Nd on page 6-67 for mor e detai l .
Coiflets
Bui l t by I . Daubechi es at the request of R. Coi fman. The wavel et functi on has
2N moments equal to 0 and the scal i ng functi on has 2N-1 moments equal to 0.
The two functi ons have a support of l ength 6N-1. You can obtai n a survey of the
mai n properti es of thi s fami l y by typi ng wav ei nf o( ' c oi f ' ) from the MATLAB
command l i ne. See Coi fl et Wavel ets: coi fN on page 6-66 for mor e detai l .
Symlets
The syml ets ar e nearl y symmetri cal wavel ets pr oposed by Daubechi es as
modi fi cati ons to the db fami l y. The pr operti es of the two wavel et fami l i es are
si mi l ar.
You can obtai n a survey of the mai n properti es of thi s fami l y by typi ng
wav ei nf o( ' s ym' ) fr om the MATLAB command l i ne. See Syml et Wavel ets:
symN on page 6-65 for mor e detai l .
coif1 coif2 coif3 coif4 coif5
sym2 sym3 sym4 sym5
sym6 sym7 sym8
1 Wavelets: A N ew Tool for Si gnal Analysi s
1-34
Morlet
Thi s wavel et has no scal i ng functi on, but i s expl i ci t.
You can obtai n a survey of the mai n pr oper ti es of thi s fami l y by typi ng
wav ei nf o( ' mor l ' ) fr om the MATLAB command l i ne. See Mor l et Wavel et:
morl on page 6-72 for more detai l .
Mexican Hat
Thi s wavel et has no scal i ng functi on and i s deri ved from a functi on that i s
pr opor ti onal to the second deri vati ve functi on of the Gaussi an pr obabi l i ty
densi ty functi on.
You can obtai n a sur vey of the mai n properti es of thi s fami l y by typi ng
wav ei nf o( ' me xh' ) fr om the MATLAB command l i ne. See Mexi can Hat
Wavel et: mexh on page 6-71 for mor e i nfor mati on.
An Introducti on to the W avelet Fami li es
1-35
Meyer
The Meyer wavel et and scal i ng functi on are defi ned i n the frequency domai n.
You can obtai n a survey of the mai n properti es of thi s fami l y by typi ng
wav ei nf o( ' mey er ' ) from the MATLAB command l i ne. See Meyer Wavel et:
meyr on page 6-69 for more detai l .
1 Wavelets: A N ew Tool for Si gnal Analysi s
1-36

2
Usi ng Wavel ets
2-3 Continuous Wavelet Analysis (One-Dimensional)
2-3 Conti nuous Anal ysi s Usi ng the Command Li ne
2-7 Conti nuous Anal ysi s Usi ng the Graphi cal I nterface
2-11 I mpor ti ng and Exporti ng I nfor mati on from the Gr aphi cal I nterface
2-13 One-Dimensional Discrete Wavelet Analysis
2-15 One-Di mensi onal Anal ysi s Usi ng the Command Li ne
2-22 One-Di mensi onal Anal ysi s Usi ng the Gr aphi cal I nterface
2-38 I mpor ti ng and Exporti ng I nfor mati on from the Gr aphi cal I nterface
2-43 Two-Dimensional Discrete Wavelet Analysis
2-44 Two-Di mensi onal Anal ysi s Usi ng the Command Li ne
2-52 Two-Di mensi onal Anal ysi s Usi ng the Gr aphi cal I nter face
2-59 I mpor ti ng and Exporti ng I nfor mati on from the Gr aphi cal I nterface
2-66 Working with Indexed Images
2-66 Understandi ng I mages i n MATLAB
2-66 I ndexed I mages
2-68 Wavel et Decomposi ti on of I ndexed I mages
2 Usi ng Wavelets
2-2
The Wavel et Tool box contai ns graphi cal tool s and command l i ne functi ons that
l et you:
Exami ne and expl or e char acteri sti cs of i ndi vi dual wavel ets and wavel et
packet.
Exami ne stati sti cs of si gnal s and si gnal components.
Per form a conti nuous wavel et tr ansfor m of a one-di mensi onal si gnal .
Per form di screte anal ysi s and synthesi s of one- and two-di mensi onal si gnal s.
Per form wavel et packet anal ysi s of one- and two-di mensi onal si gnal s.
Compress and r emove noi se from si gnal s and i mages.
I n addi ti on to the above, the tool box makes i t easy to customi ze the
pr esentati on and vi sual i zati on of your data. You choose:
Whi ch si gnal s to di spl ay
A r egi on of i nterest to magni fy
A col ori ng scheme for di spl ay of wavel et coeffi ci ent detai l s
Thi s chapter takes you step-by-step thr ough exampl es that teach you how to
use the graphi cal tool s and command l i ne functi ons. These exampl es i ncl ude:
Conti nuous Wavel et Anal ysi s (One-Di mensi onal )
One-Di mensi onal Di screte Wavel et Anal ysi s
Two-Di mensi onal Di scr ete Wavel et Anal ysi s
Chapter 5 descr i bes usi ng the tool box to perfor m wavel et packet anal ysi s.
C onti nuous Wavelet Analysi s (O ne-Di mensi onal)
2-3
Continuous Wavelet Analysis (One-Dimensional)
Thi s secti on takes you thr ough the featur es of conti nuous wavel et anal ysi s
usi ng the MATLAB Wavel et Tool box.
The Wavel et Tool box requi res onl y one functi on for conti nuous wavel et
anal ysi s: c wt . Youl l fi nd ful l i nfor mati on about thi s functi on i n the Command
Refer ence (Chapter 8).
I n thi s secti on, youl l l earn how to:
Load a si gnal
Per for m a conti nuous wavel et transform of a si gnal
Pr oduce a pl ot of the coeffi ci ents
Zoom i n on detai l
Di spl ay coeffi ci ents i n normal or absol ute mode
Choose the scal es at whi ch anal ysi s i s performed
Si nce you can per for m anal yses ei ther from the command l i ne or usi ng the
gr aphi cal i nter face tool s, thi s secti on has subsecti ons cover i ng each method.
The fi nal subsecti on di scusses how to exchange si gnal and coeffi ci ent
i nfor mati on between the di sk and the gr aphi cal tool s.
Continuous Analysis Using the Command Line
Thi s exampl e i nvol ves a noi sy si nusoi dal si gnal .
2 Usi ng Wavelets
2-4
Loading a Signal.
1 Fr om the MATLAB pr ompt, type:
l oad noi s s i n;
You now have the si gnal noi s s i n i n your workspace:
whos
Performing a Continuous Wavelet Transform.
2 Use the c wt command. Type:
c = c wt ( noi s s i n, 1: 48, ' db4' ) ;
The ar guments to c wt speci fy the si gnal to be anal yzed, the scal es of the
anal ysi s, and the wavel et to be used. The returned argument c contai ns the
coeffi ci ents at vari ous scal es. I n thi s case, c i s a 48-by-1000 matr i x, each row
of whi ch cor responds to a si ngl e scal e.
Name Si z e El ement s By t es Cl as s
noi s s i n 1 by 1000 1000 8000 doubl e ar r ay
C onti nuous Wavelet Analysi s (O ne-Di mensi onal)
2-5
Plotting the Coefficients. The c wt command accepts a four th argument. Thi s i s
a fl ag that, when pr esent, causes cwt to pr oduce a pl ot of the absol ute val ues of
the conti nuous wavel et transform coeffi ci ents.
3 Type
c = c wt ( noi s s i n, 1: 48, ' db4' , ' pl ot ' ) ;
A pl ot appear s:
Of course, coeffi ci ent pl ots generated from the command l i ne can be
mani pul ated usi ng or di nar y MATLAB gr aphi cs commands. The col ormap for
the pi ctur e above was changed to pi nk from the defaul t c ool by typi ng:
c ol or map( pi nk)
2 Usi ng Wavelets
2-6
Choosing Scales for the Analysis. The second argument to c wt gi ves you fi ne
contr ol over the scal e l evel s on whi ch the conti nuous anal ysi s i s per for med. I n
the previ ous exampl e, we used al l scal es fr om 1 to 48, but you can construct any
scal e vector subject to these constrai nts:
Al l scal es must be r eal posi ti ve numbers.
The i ni ti al scal e must be posi ti ve.
The scal e i ncrement must be posi ti ve.
The hi ghest scal e cannot exceed a si gnal -dependent maxi mum.
4 Lets repeat the anal ysi s usi ng ever y other scal e fr om 2 to 128.
Type:
c = c wt ( noi s s i n, 2: 2: 128, ' db4' , ' pl ot ' ) ;
A new pl ot appears:
Thi s pl ot gi ves a cl ear er pi cture of whats happeni ng wi th the si gnal ,
hi ghl i ghti ng the per i odi ci ty.
C onti nuous Wavelet Analysi s (O ne-Di mensi onal)
2-7
Continuous Analysis Using the Graphical Interface
We now use the Continuous Wavelet 1-D tool to anal yze the same noi sy
si nusoi dal si gnal we exami ned usi ng the command l i ne i nterface i n the
previ ous secti on.
Starting the Continuous Wavelet 1-D Tool.
1 From the MATLAB prompt, type wav eme nu.
The Wavelet Toolbox Main Menu appears.
2 Cl i ck the Continuous Wavelet 1-D menu i tem.
The conti nuous wavel et anal ysi s tool for one-di mensi onal si gnal data
appear s:
2 Usi ng Wavelets
2-8
Loading a Signal.
3 Choose the FileLoad Signal menu opti on.
4 When the Load Signal di al og box appear s, sel ect the demo MAT-fi l e
noi s s i n. mat , whi ch shoul d resi de i n the MATLAB di rectory t ool box /
wave l e t /wave demo. Cl i ck the OK button.
The noi sy si nusoi dal si gnal i s l oaded i nto the Continuous Wavelet 1-D
tool .
Performing a Continuous Wavelet Transform.
To start our anal ysi s, l ets per for m an anal ysi s usi ng the db4 wavel et at scal es
1 through 48, just as we di d usi ng command l i ne functi ons i n the previ ous
secti on.
5 I n the upper r i ght por ti on of the Continuous Wavelet 1-D tool , sel ect the
db4 wavel et and scal e l evel s 148.
Select db4
Select levels 1-48
in steps of 1.
C onti nuous Wavelet Analysi s (O ne-Di mensi onal)
2-9
6 Cl i ck the Analyze button.
After a pause for computati on, the tool di spl ays the coeffi ci ents pl ot.
Zooming in on Detail.
7 Drag a rubber band box (by hol di ng down the l eft mouse button) over the
porti on of the si gnal you want to magni fy.
2 Usi ng Wavelets
2-10
8 Cl i ck the X+ button (l ocated at the bottom of the screen) to zoom hor i zontal l y
onl y.
The Continuous Wavelet 1-D tool enl ar ges the di spl ayed si gnal and
coeffi ci ents pl ot.
As wi th the command l i ne anal ysi s on the precedi ng pages, you can change the
scal es or the anal yzi ng wavel et and r epeat the anal ysi s. To do thi s, just edi t the
necessar y fi el ds and press the Analyze button.
Viewing Normal or Absolute Coefficients. The Continuous Wavelet 1-D
tool al l ows you to pl ot ei ther the absol ute val ues of the wavel et coeffi ci ents, or
the coeffi ci ents themsel ves.
C onti nuous Wavelet Analysi s (O ne-Di mensi onal)
2-11
9 Choose ei ther Absolute Mode or Normal Mode from the Coloration
Mode menu, l ocated just above the Analyze button. I n normal mode, the
col or s are scal ed between the mi ni mum and maxi mum of the coeffi ci ents. I n
absol ute mode, the col ors ar e scal ed between zero and the maxi mum
absol ute val ue of the coeffi ci ents (for mor e detai l s on the Coloration Mode,
(See Conti nuous Wavel et Tool Features on page A-1).
The coeffi ci ents pl ot i s r edi spl ayed i n the mode you sel ect.
Importing and Exporting Information from the
Graphical Interface
The Conti nuous Wavel et 1-D gr aphi cal i nter face tool l ets you i mport
i nfor mati on from and export i nfor mati on to your di sk.
You can:
Load si gnal s from your di sk i nto the Continuous Wavelet 1-D tool .
Save wavel et coeffi ci ents from the Continuous Wavelet 1-D tool i nto your
di sk.
Loading Signals into the Continuous Wavelet 1-D Tool
To l oad a si gnal youve constructed i n your MATLAB workspace i nto the
Continuous Wavelet 1-D tool , save the si gnal i n a MAT-fi l e that has the
same name as the si gnal var i abl e i tsel f.
For i nstance, suppose youve desi gned a si gnal cal l ed war ma and want to
anal yze i t i n the Continuous Wavelet 1-D tool .
s av e war ma
Absolute Mode Normal Mode
2 Usi ng Wavelets
2-12
The workspace vari abl e war ma must be a vector .
s i z war ma = s i z e( war ma)
s i z war ma =
1 1000
To l oad thi s si gnal i nto the Continuous Wavelet 1-D tool , use the menu
opti on FileLoad Signal.
A di al og box appear s that l ets you sel ect the appropri ate MAT-fi l e to be l oaded.
Saving Wavelet Coefficients
The Conti nuous Wavel et 1-D tool l ets you save wavel et coeffi ci ents to your
di sk. The tool box creates a MAT-fi l e i n the curr ent di rectory wi th the extensi on
wc1 and a name you gi ve i t.
To save the conti nuous wavel et coeffi ci ents fr om the pr esent anal ysi s, use the
menu opti on FileSave Coefficients.
A di al og box appear s that l ets you speci fy a di rectory and fi l ename for stor i ng
the coeffi ci ents.
Consi der the demo anal ysi s:
FileDemo Analysiswith haar at scales [1:1:64] > Cantor curve.
After savi ng the conti nuous wavel et coeffi ci ents to the fi l e c ant or . wc1, l oad the
vari abl es i nto your wor kspace.
l oad c ant or . wc 1 - mat
whos
Var i abl es c oe f s and s c al es contai n the conti nuous wavel et coeffi ci ents and
the associ ated scal es. Mor e pr eci sel y, i n the above exampl e coef s i s a
64-by-2188 matr i x, one r ow for each scal e, and s c al es i s the 1-by-64 vector
1: 64.
Name Si z e El ement s By t es Cl as s
c oe f s 64 by 2188 140032 1120256 doubl e ar r ay
s cal e s 1 by 64 64 512 doubl e ar r ay
O ne-Di mensi onal Di screte W avelet Analysi s
2-13
One-Dimensional Discrete Wavelet Analysis
Thi s secti on takes you thr ough the featur es of one-di mensi onal di scr ete
wavel et anal ysi s usi ng the MATLAB Wavel et Tool box.
The Wavel et Tool box provi des these functi ons for one-di mensi onal si gnal
anal ysi s. For mor e i nformati on, see the Command Refer ence (Chapter 8).
Analysis Decomposition Functions:
Synthesis Reconstruction Functions:
Function Name Purpose
dwt One-step decomposi ti on
wave de c Decomposi ti on
Function Name Purpose
i dwt One-step reconstr ucti on
wave r e c Ful l reconstr ucti on
wr coef Sel ecti ve r econstructi on
upcoef Si ngl e r econstructi on
2 Usi ng Wavelets
2-14
Decomposition Structure Utilities:Analysis Decomposition
Functions:
I n thi s secti on, youl l l ear n how to:
Load a si gnal
Per form a si ngl e-l evel wavel et decomposi ti on of a si gnal
Construct approxi mati ons and detai l s fr om the coeffi ci ents
Di spl ay the approxi mati on and detai l
Regener ate a si gnal by i nverse wavel et transform
Per form a mul ti -l evel wavel et decomposi ti on of a si gnal
Extr act appr oxi mati on and detai l coeffi ci ents
Reconstruct the l evel 3 approxi mati on
Reconstruct the l evel 1, 2, and 3 detai l s
Di spl ay the resul ts of a mul ti -l evel decomposi ti on
Reconstruct the ori gi nal si gnal fr om the l evel 3 decomposi ti on
Remove noi se fr om a si gnal
Refi ne an anal ysi s
Compress a si gnal
Show a si gnal s stati sti cs and hi stograms
Function Name Purpose
de t c oef Extr acti on of detai l coeffi ci ents
appc oef Extr acti on of approxi mati on coeffi ci ents
upwl e v Recomposi ti on of decomposi ti on str ucture
Function Name Purpose
ddenc mp Provi de defaul t val ues for de-noi si ng and
compr essi on
wdenc mp Wavel et de-noi si ng and compr essi on
wden Automati c wavel et de-noi si ng
O ne-Di mensi onal Di screte W avelet Analysi s
2-15
Si nce you can per for m anal yses ei ther from the command l i ne or usi ng the
gr aphi cal i nter face tool s, thi s secti on has subsecti ons cover i ng each method.
The fi nal subsecti on di scusses how to exchange si gnal and coeffi ci ent
i nfor mati on between the di sk and the gr aphi cal tool s.
One-Dimensional Analysis Using the Command Line
Thi s exampl e i nvol ves a r eal -wor l d si gnal el ectri cal consumpti on measur ed
over the cour se of three days. Thi s si gnal i s par ti cul ar l y i nter esti ng because of
noi se i ntroduced when a defect devel oped i n the moni tori ng equi pment as the
measurements wer e bei ng made. Wavel et anal ysi s effecti vel y removes the
noi se.
Loading a Signal.
1 From the MATLAB prompt, type:
l oad l e l e c cum;
2 Set the vari abl es. Type:
s = l el ec c um( 1: 3920) ;
l s = l e ngt h( s ) ;
Performing A One-Step Wavelet Decomposition of a Signal.
3 Perform a one-step decomposi ti on of the si gnal usi ng the db1 wavel et. Type:
[ cA1, cD1] = dwt ( s , ' db1' ) ;
Thi s generates the coeffi ci ents of the l evel 1 appr oxi mati on (c A1) and detai l
(c D1).
2 Usi ng Wavelets
2-16
Constructing Approximations and Details from the Coefficients.
4 To construct the l evel 1 approxi mati on and detai l (A1 and D1) from the
coeffi ci ents c A1 and cD1, type:
A1 = upc oe f ( ' a' , c A1, ' db1' , 1, l s ) ;
D1 = upc oe f ( ' d' , c D1, ' db1' , 1, l s ) ;
Displaying the Approximation and Detail.
5 To di spl ay the r esul ts of the l evel -one decomposi ti on, type:
s ubpl ot ( 1, 2, 1) ; pl ot ( A1) ; t i t l e( ' Appr ox i mat i on A1' )
s ubpl ot ( 1, 2, 2) ; pl ot ( D1) ; t i t l e( ' Det ai l D1' )
Regenerating a Signal by Inverse Wavelet Transform.
6 To fi nd the i nver se transform, type:
A0 = i dwt ( cA1, cD1, ' db1' , l s ) ;
Performing a Multilevel Wavelet Decomposition of a Signal.
7 To per form a l evel 3 decomposi ti on of the si gnal (agai n usi ng the db1
wavel et), type:
[ C, L] = wave de c( s , 3, ' db1' ) ;
O ne-Di mensi onal Di screte W avelet Analysi s
2-17
The coeffi ci ents of al l the components of a thi rd-l evel decomposi ti on (that i s,
the thi rd-l evel appr oxi mati on and the fi r st thr ee l evel s of detai l ) ar e
r etur ned concatenated i nto one vector, C. Vector L gi ves the l engths of each
component.
Extracting Approximation and Detail Coefficients.
8 To extract the l evel 3 appr oxi mati on coeffi ci ents fr om C, type:
c A3 = appc oe f ( C, L, ' db1' , 3) ;
9 To extract the l evel s 3, 2, and 1 detai l coeffi ci ents from C, type:
c D3 = det c oe f ( C, L, 3) ;
c D2 = det c oe f ( C, L, 2) ;
c D1 = det c oe f ( C, L, 1) ;
Reconstructing the Level 3 Approximation.
10 To r econstruct the l evel 3 approxi mati on from C, type:
A3 = wr coe f ( ' a' , C, L, ' db1' , 3) ;
Reconstructing the Level 1, 2, and 3 Details.
11 To r econstruct the detai l s at l evel s 1, 2 and 3, from C, type:
D1 = wr coe f ( ' d' , C, L, ' db1' , 1) ;
D2 = wr coe f ( ' d' , C, L, ' db1' , 2) ;
D3 = wr coe f ( ' d' , C, L, ' db1' , 3) ;
S
cA
1
cD
1
cA
2
cD
2
cA
3
cD
3
cD
1
cD
2
cA
3
cD
3
C
2 Usi ng Wavelets
2-18
Displaying the Results of a Multilevel Decomposition.
12 To di spl ay the r esul ts of the l evel 3 decomposi ti on, type:
s ubpl ot ( 2, 2, 1) ; pl ot ( A3) ; t i t l e( ' Appr ox i mat i on A3' )
s ubpl ot ( 2, 2, 2) ; pl ot ( D1) ; t i t l e( ' Det ai l D1' )
s ubpl ot ( 2, 2, 3) ; pl ot ( D2) ; t i t l e( ' Det ai l D2' )
s ubpl ot ( 2, 2, 4) ; pl ot ( D3) ; t i t l e( ' Det ai l D3' )
Reconstructing the Original Signal From the Level 3 Decomposition.
13 To reconstr uct the ori gi nal si gnal fr om the wavel et decomposi ti on str ucture,
type:
A0 = wav er ec ( C, L, ' db1' ) ;
O ne-Di mensi onal Di screte W avelet Analysi s
2-19
Crude De-noising of a Signal.
Usi ng wavel ets to remove noi se from a si gnal requi res i denti fyi ng whi ch
component or components contai n the noi se and then reconstr ucti ng the si gnal
wi thout those components.
I n thi s exampl e, we note that successi ve approxi mati ons become l ess and l ess
noi sy as more and more hi gh-frequency i nformati on i s fi l tered out of the si gnal .
The l evel 3 appr oxi mati on, A3, i s qui te cl ean as a compar i son between i t and
the ori gi nal si gnal shows.
14 To compare the approxi mati on to the or i gi nal si gnal , type:
s ubpl ot ( 2, 1, 1) ; pl ot ( s ) ; t i t l e( ' Or i gi nal ' ) ; ax i s of f
s ubpl ot ( 2, 1, 2) ; pl ot ( A3) ; t i t l e ( ' Le v el 3 Appr ox i mat i on' ) ;
axi s of f
Of cour se, i n di scar di ng al l the hi gh-fr equency i nfor mati on, weve al so l ost
many of the ori gi nal si gnal s sharpest featur es.
Opti mal de-noi si ng requi r es a more subtl e approach cal l ed thresholding. Thi s
i nvol ves di scardi ng onl y the porti on of the detai l s that exceeds a certai n l i mi t.
2 Usi ng Wavelets
2-20
Removing Noise by Thresholding.
Lets l ook agai n at the detai l s of our l evel 3 anal ysi s.
15 To di spl ay the detai l s D1, D2, and D3, type:
s ubpl ot ( 3, 1, 1) ; pl ot ( D1) ; t i t l e( ' Det ai l Lev el 1' ) ; axi s of f
s ubpl ot ( 3, 1, 2) ; pl ot ( D2) ; t i t l e( ' Det ai l Lev el 2' ) ; axi s of f
s ubpl ot ( 3, 1, 3) ; pl ot ( D3) ; t i t l e( ' Det ai l Lev el 3' ) ; axi s of f
Most of the noi se occur s i n the l atter par t of the si gnal , wher e the detai l s
show thei r greatest acti vi ty. What i f we l i mi ted the strength of the detai l s
by r estr i cti ng thei r maxi mum val ues? Thi s woul d have the effect of cutti ng
back the noi se whi l e l eavi ng the detai l s unaffected through most of thei r
durati ons. But ther es a better way.
Note that cD1, c D2, and c D3 are just MATLAB vectors, and we coul d di r ectl y
mani pul ate each vector , setti ng each el ement to some fr acti on of the vectors
peak or average val ue. Then we coul d r econstruct new detai l si gnal s D1, D2,
and D3 fr om the threshol ded coeffi ci ents.
16 To de-noi se the si gnal , use the dde nc mp command to cal cul ate the defaul t
par ameters and the wdencmp command to perform the actual de-noi si ng,
type:
[ t hr , s or h, ke epapp] = ddencmp( ' de n' , ' wv ' , s ) ;
c l e an = wdencmp( ' gbl ' , C, L, ' db1' , 3, t hr , s or h, ke epapp) ;
Setting a
threshold
O ne-Di mensi onal Di screte W avelet Analysi s
2-21
Note that we pass i n to wdenc mp the r esul ts of the decomposi ti on (C and L)
we cal cul ated i n Step 7 on page 2-16. We al so speci fy that we used the db1
wavel et to perfor m the or i gi nal anal ysi s, and we speci fy the gl obal
threshol di ng opti on ' gbl ' . See the ddencmp and wde nc mp r efer ence entr i es
for more i nformati on about the use of these commands.
17 To di spl ay both the ori gi nal and de-noi sed si gnal s, type:
s ubpl ot ( 2, 1, 1) ; pl ot ( s ( 2000: 3920) ) ; t i t l e( ' Or i gi nal ' )
s ubpl ot ( 2, 1, 2) ; pl ot ( cl ean( 2000: 3920) ) ; t i t l e ( ' De - noi s e d' )
Weve pl otted here onl y the noi sy l atter par t of the si gnal . Noti ce how weve
r emoved the noi se wi thout compromi si ng the sharp detai l of the ori gi nal
si gnal . Thi s i s a str ength of wavel et anal ysi s.
Whi l e usi ng command l i ne functi ons to remove the noi se from a si gnal can be
cumbersome, the Wavel et Tool box gr aphi cal i nter face tool s i ncl ude an
easy-to-use de-noi si ng feature that i ncl udes automati c thr eshol di ng.
2 Usi ng Wavelets
2-22
One-Dimensional Analysis Using the Graphical
Interface
I n thi s secti on we expl or e the same el ectri cal consumpti on si gnal as i n the
pr evi ous secti on, but we use the graphi cal i nterface tool s to anal yze the si gnal .
Starting the 1-D Wavelet Analysis Tool.
1 Fr om the MATLAB pr ompt, type:
wave me nu.
The Wavelet Toolbox Main Menu appears.
O ne-Di mensi onal Di screte W avelet Analysi s
2-23
2 Cl i ck the Wavelet 1-D menu i tem.
The di screte wavel et anal ysi s tool for one-di mensi onal si gnal data appears.
Loading a Signal.
3 From the File menu, choose the Load Signal opti on.
2 Usi ng Wavelets
2-24
4 When the Load Signal di al og box appear s, sel ect the demo MAT-fi l e
l e l e cc um. mat , whi ch shoul d r esi de i n the MATLAB di r ector y
t ool box/wave l et /wav edemo. Cl i ck the OK button.
The el ectri cal consumpti on si gnal i s l oaded i nto the Wavelet 1-D tool .
Performing A One-Step Wavelet Decomposition of a Signal.
To start our anal ysi s, l ets perfor m a si ngl e-l evel decomposi ti on usi ng the db1
wavel et, just as we di d usi ng command l i ne functi ons i n the previ ous secti on.
5 I n the upper ri ght porti on of the Wavelet 1-D tool , sel ect the db1 wavel et
and si ngl e-l evel decomposi ti on.
O ne-Di mensi onal Di screte W avelet Analysi s
2-25
6 Cl i ck the Analyze button.
After a pause for computati on, the tool di spl ays the decomposi ti on.
2 Usi ng Wavelets
2-26
Zooming in On Relevant Detail.
One advantage of usi ng the gr aphi cal i nter face tool s i s that you can zoom i n
easi l y on any par t of the si gnal and exami ne i t i n gr eater detai l .
7 Drag a r ubber band box (by hol di ng down the l eft mouse button) over the
por ti on of the si gnal you want to magni fy. Here, weve sel ected the noi sy par t
of the ori gi nal si gnal .
8 Cl i ck the XY+ button (l ocated at the bottom of the scr een) to zoom both
hori zontal l y and ver ti cal l y.
O ne-Di mensi onal Di screte W avelet Analysi s
2-27
The Wavelet 1-D tool zooms al l the di spl ayed si gnal s.
The other zoom contr ol s do more or l ess what youd expect them to. The
X-button, for exampl e, zooms out hori zontal l y. The hi stor y functi on keeps
tr ack of al l your vi ews of the si gnal . Return to a previ ous zoom l evel by
cl i cki ng the l eft ar row button.
Performing a Multi-Level Decomposition of a Signal.
Agai n, wel l use the gr aphi cal tool s to emul ate what we di d i n the pr evi ous
secti on usi ng command l i ne functi ons. To perform a l evel 3 decomposi ti on of
the si gnal usi ng the db1 wavel et:
9 Si mpl y sel ect 3 fr om the Level menu at the upper r i ght, and then cl i ck the
Analyze button agai n.
2 Usi ng Wavelets
2-28
After the decomposi ti on i s performed, youl l see a new anal ysi s appear i n the
Wavelet 1-D tool .
Selecting Different Views of the Decomposition.
The menu at the mi ddl e ri ght l ets you choose di fferent vi ews of the wavel et
decomposi ti on.
The defaul t di spl ay mode i s cal l ed Ful l Decomposi ti on Mode. Other
al ter nati ves i ncl ude:
Separ ate Mode, whi ch shows the detai l s and the appr oxi mati ons i n
separate col umns.
Super i mpose Mode, whi ch shows the detai l s on a si ngl e pl ot superi mposed
i n di ffer ent col or s. The approxi mati ons ar e pl otted si mi l arl y.
Tree Mode, whi ch shows the decomposi ti on tree, the ori gi nal si gnal , and
one addi ti onal component of your choi ce. Cl i ck on the decomposi ti on tr ee to
sel ect the si gnal component youd l i ke to vi ew.
Select
a view
O ne-Di mensi onal Di screte W avelet Analysi s
2-29
Show and Scrol l Mode, whi ch di spl ays three wi ndows. The fi r st shows the
or i gi nal si gnal super i mposed on an appr oxi mati on you sel ect. The second
wi ndow shows a detai l you sel ect. The thi r d wi ndow shows the wavel et
coeffi ci ents.
You can change the defaul t di spl ay mode on a per -sessi on basi s. Sel ect the
desi red mode from the Options Default Display Mode submenu.
Separate Mode Superimpose Mode
Tree Mode Show & Scroll Mode
2 Usi ng Wavelets
2-30
Dependi ng on whi ch di spl ay mode you sel ect, you may have access to addi ti onal
di spl ay opti ons thr ough the More Display Options button.
These opti ons i ncl ude the abi l i ty to suppress the di spl ay of vari ous
components, and to choose whether or not to di spl ay the ori gi nal si gnal al ong
wi th the detai l s and appr oxi mati ons.
Removing Noise From a Signal.
The gr aphi cal i nter face tool s feature a de-noi si ng opti on wi th automati c
threshol di ng. Thi s makes i t very easy to remove noi se from a si gnal .
10 Br i ng up the de-noi si ng tool : cl i ck the De-noise button, l ocated i n the
mi ddl e ri ght of the wi ndow, under neath the Analyze button.
O ne-Di mensi onal Di screte W avelet Analysi s
2-31
The Wavelet 1-D De-noising wi ndow appear s.
Whi l e a number of opti ons ar e avai l abl e for fi ne-tuni ng the de-noi si ng
al gori thm, wel l accept the defaul ts of soft thr eshol di ng and unscal ed whi te
noi se.
2 Usi ng Wavelets
2-32
11 Conti nue by cl i cki ng the De-noise button.
The de-noi sed si gnal appears super i mposed on the or i gi nal . The tool al so
pl ots the wavel et coeffi ci ents of both si gnal s.
Zoom i n on the pl ot of the ori gi nal and de-noi sed si gnal s for a cl oser l ook.
O ne-Di mensi onal Di screte W avelet Analysi s
2-33
12 Drag a rubber band box ar ound the perti nent ar ea, then cl i ck the XY+
button.
The De-noise wi ndow magni fi es your vi ew. By defaul t, the ori gi nal si gnal
i s shown i n r ed, and the de-noi sed si gnal i n yel l ow.
13 Di smi ss the Wavelet 1-D De-noising wi ndow: cl i ck the Close button.
You cannot have the De-noise and Compression wi ndows open
si mul taneousl y, so cl ose the Wavelet 1-D De-noising wi ndow to conti nue.
When the Update Synthesized Signal di al og box appear s, cl i ck No (i f you
cl i ck Yes, the Synthesized Signal i s then avai l abl e i n the Wavelet 1-D
mai n wi ndow).
Refining an Analysis.
The gr aphi cal tool s make i t easy to r efi ne an anal ysi s any ti me you want to. Up
to now, weve l ooked at a l evel 3 anal ysi s usi ng db1. Lets refi ne our anal ysi s of
the el ectr i cal consumpti on si gnal usi ng the db3 wavel et at l evel 5.
14 Sel ect 5 from the Level menu at the upper r i ght, and sel ect the db3 wavel et.
Cl i ck the Analyze button.
2 Usi ng Wavelets
2-34
Compressing a Signal.
The gr aphi cal i nter face tool s feature a compressi on opti on wi th automati c or
manual threshol di ng.
15 Br i ng up the Compression wi ndow: cl i ck the Compress button, l ocated i n
the mi ddl e ri ght of the wi ndow, under neath the Analyze button.
The Compression wi ndow appears.
Whi l e you al ways have the opti on of choosi ng manual thr eshol di ng, her e
wel l take advantage of the automati c threshol di ng feature for qui ck and
easy compressi on.
Thresholding
menu
Threshold
slider
Compress
button
O ne-Di mensi onal Di screte W avelet Analysi s
2-35
Note: I f you want to experi ment wi th manual thr eshol di ng, choose that opti on
from the menu l ocated at the top ri ght of the Wavel et 1-D Compr essi on
wi ndow. The sl i der s l ocated bel ow thi s menu then control the l evel -dependent
threshol ds, i ndi cated by yel l ow dotted l i nes runni ng hor i zontal l y thr ough the
gr aphs on the l eft of the wi ndow.
16 Cl i ck the Compress button, l ocated at the center r i ght.
After a pause for computati on, the el ectr i cal consumpti on si gnal i s
r edi spl ayed i n red wi th the compressed versi on super i mposed i n yel l ow.
Bel ow, weve zoomed i n to get a cl oser l ook at the noi sy part of the si gnal .
You can see that the compr essi on pr ocess removed most of the noi se, but
pr eserved 99.74% of the energy of the si gnal . The automati c threshol di ng
was very effi ci ent, zeroi ng out al l but 3.2% of the wavel et coeffi ci ents.
17 Di smi ss the Wavelet 1-D Compression wi ndow: cl i ck the Close button.
When the Update Synthesized Signal di al og box appears, cl i ck No.
2 Usi ng Wavelets
2-36
Showing Statistics.
You can vi ew a var i ety of stati sti cs about your si gnal and i ts components.
18 Fr om the Wavelet 1-D tool , cl i ck the Statistics button.
The Wavelet 1-D Statistics wi ndow appears.
19 Sel ect the si gnal or si gnal component whose stati sti cs you want to exami ne.
Cl i ck on the appr opri ate radi o button, then press the Show Statistics
button. Her e, weve chosen to exami ne the ori gi nal si gnal :
O ne-Di mensi onal Di screte W avelet Analysi s
2-37
Di spl ayed stati sti cs i ncl ude measur es of tendency (mean, mode, medi an)
and di sper si on (range, standar d devi ati on).
I n addi ti on, the tool pr ovi des frequency-di str i buti on di agr ams (hi stograms
and cumul ati ve hi stograms). You can pl ot these hi stogr ams separ atel y usi ng
the Histograms button from the Wavelets 1-D wi ndow.
20 Sel ect the Approximation radi o button. A menu appear s fr om whi ch you
choose the l evel of the approxi mati on you want to exami ne.
21 Sel ect Level 1 and agai n cl i ck the Show Statistics button.
Stati sti cs appear for the l evel 1 appr oxi mati on.
2 Usi ng Wavelets
2-38
Importing and Exporting Information from the
Graphical Interface
The Wavelet 1-D gr aphi cal i nter face tool l ets you i mport i nformati on from and
expor t i nformati on to your di sk.
Saving Information to the Disk
You can save synthesi zed si gnal s, coeffi ci ents, and decomposi ti ons fr om the
Wavelet 1-D tool to the di sk, wher e the i nfor mati on can be mani pul ated and
l ater r ei mported i nto the gr aphi cal tool .
Saving Synthesized Signals.
You can process a si gnal i n the Wavelet 1-D tool and then save the pr ocessed
si gnal to a MAT-fi l e.
For exampl e, l oad the demo anal ysi s: FileDemo Analysiswith db3 at
level 5 > Sum of sines, and perfor m a compressi on or de-noi si ng oper ati on
on the ori gi nal si gnal . When you cl ose the De-noise or Wavelet 1-D
Compression wi ndow, update the synthesi zed si gnal by cl i cki ng Yes i n the
di al og box.
Then, fr om the Wavelet 1-D tool , sel ect the FileSave Synthesized Signal
menu opti on.
A di al og box appears al l owi ng you to sel ect a di r ectory and fi l ename for the
MAT-fi l e. For thi s exampl e, choose the name s ynt hs i g.
Load information from disk
Save information to disk
O ne-Di mensi onal Di screte W avelet Analysi s
2-39
To l oad the si gnal i nto your workspace, si mpl y type:
l oad s y nt hs i g
whos
Saving Discrete Wavelet Transform Coefficients.
The Wavelet 1-D tool l ets you save the coeffi ci ents of a di scr ete wavel et
tr ansfor m (DWT) to your di sk. The tool box cr eates a MAT-fi l e i n the curr ent
di rectory wi th a name you choose.
To save the DWT coeffi ci ents from the present anal ysi s, use the menu opti on
FileSave Coefficients.
A di al og box appears that l ets you speci fy a di rectory and fi l ename for stor i ng
the coeffi ci ents.
Consi der the demo anal ysi s:
FileDemo Analysiswith db1 at level 5 > Cantor curve.
After savi ng the wavel et coeffi ci ents to the fi l e cant or . mat , l oad the vari abl es
i nto your workspace.
l oad cant or
whos
Var i abl e c oe f s contai ns the di scr ete wavel et coeffi ci ents. Mor e pr eci sel y, i n the
above exampl e coef s i s a 1-by-2190 vector of concatenated coeffi ci ents, and
l ongs i s a vector gi vi ng the l engths of each component of coe f s .
Saving Decompositions.
The Wavelet 1-D tool l ets you save the enti r e set of data from a di scr ete
wavel et anal ysi s to your di sk. The tool box cr eates a MAT-fi l e i n the cur rent
di rectory wi th a name you choose, fol l owed by the extensi on wa1 (wavel et
anal ysi s 1-D).
Name Si z e El e me nt s By t e s Cl as s
s ynt hs i g 1 by 1000 1000 8000 doubl e ar r ay
Name Si z e El e ment s By t e s Cl as s
coef s 1 by 2190 2190 17520 doubl e ar r ay
l ongs 1 by 7 7 56 doubl e ar r ay
2 Usi ng Wavelets
2-40
Open the Wavelet 1-D tool and l oad the demo anal ysi s:
FileDemo Analysiswith db3 at level 5 > Sum of sines.
To save the data fr om thi s anal ysi s, use the menu opti on:
FileSave Decomposition.
A di al og box appear s that l ets you speci fy a di rectory and fi l ename for stor i ng
the decomposi ti on data. Type the name wdec ex .
After savi ng the decomposi ti on data to the fi l e wde ce x1d. wa1, l oad the
vari abl es i nto your wor kspace.
l oad wde ce x1d. wa1 - mat
whos
Loading Information into the Wavelet 1-D Tool
You can l oad si gnal s, coeffi ci ents, or decomposi ti ons i nto the gr aphi cal
i nterface. The i nformati on you l oad may have been pr evi ousl y exported from
the gr aphi cal i nter face and then mani pul ated i n the workspace, or i t may have
been i nfor mati on you generated i ni ti al l y fr om the command l i ne.
I n ei ther case, you must obser ve the str i ct fi l e formats and data str uctur es used
by the Wavelet 1-D tool , or el se err or s wi l l r esul t when you tr y to l oad
i nfor mati on.
Loading Signals.
To l oad a si gnal youve constructed i n your MATLAB workspace i nto the
Wavelet 1-D tool , save the si gnal i n a MAT-fi l e that has the same name as the
si gnal vari abl e i tsel f.
For i nstance, suppose youve desi gned a si gnal cal l ed war ma and want to
anal yze i t i n the Wavelet 1-D tool .
s av e war ma
Name Si z e El e me nt s By t e s Cl as s
coef s 1 by 1023 1023 8184 doubl e ar r ay
dat a_name 1 by 8 8 64 doubl e ar r ay
l ongs 1 by 64 64 512 doubl e ar r ay
wave _name 1 by 3 3 24 doubl e ar r ay
O ne-Di mensi onal Di screte W avelet Analysi s
2-41
The workspace vari abl e war ma must be a vector.
s i z war ma = s i z e( war ma)
s i z war ma =
1 1000
To l oad thi s si gnal i nto the Wavelet 1-D tool , use the menu opti on
FileLoad Signal.
A di al og box appear s that l ets you sel ect the appr opri ate MAT-fi l e to be l oaded.
Loading Discrete Wavelet Transform Coefficients.
To l oad di screte wavel et transform coeffi ci ents i nto the Wavelet 1-D tool , you
must fi r st save the appr opr i ate data i n a MAT-fi l e contai ni ng onl y the two
var i abl es c oe f s and l ongs .
Var i abl e coef s must be a vector of DWT coeffi ci ents (concatenated for the
var i ous l evel s), and var i abl e l ongs a vector speci fyi ng the l ength of each
component of coef s as wel l as the l ength of the or i gi nal si gnal .
After constr ucti ng or edi ti ng the appropri ate data i n your wor kspace, type:
s av e my f i l e
Use the FileLoad Coefficients menu opti on from the Wavelet 1-D tool to
l oad the data i nto the gr aphi cal tool .
A di al og box appear s, al l owi ng you to choose the di rector y and fi l e i n whi ch
your data resi de.
S
cA
1
cD
1
cA
2 cD
2
cA
3
cD
3
cD
1
cD
2
cA
3
cD
3
coef s
l ongs
Dec ompos i t i on
1000
501
252
127 127
501 1000 127 127 252
501
252
2 Usi ng Wavelets
2-42
Loading Decompositions.
To l oad di screte wavel et tr ansfor m decomposi ti on data i nto the Wavelet 1-D
gr aphi cal i nter face, you must fi r st save the appr opr i ate data i n a MAT-fi l e wi th
extensi on wa1 (wavel et anal ysi s 1-D). The MAT-fi l e must contai n these
vari abl es:
After constr ucti ng or edi ti ng the appropr i ate data i n your workspace, type:
s av e myf i l e. wa1
Use the FileLoad Decomposition menu opti on from the Wavelet 1-D tool
to l oad the decomposi ti on data i nto the gr aphi cal tool .
A di al og box appears, al l owi ng you to choose the di rectory and fi l e i n whi ch
your data resi de.
Variable Description
c oe f s Vector of concatenated DWT coeffi ci ents
dat a_name Stri ng speci fyi ng name of decomposi ti on
l ongs Vector speci fyi ng l engths of components of coef s
and of the or i gi nal si gnal
wav e_name Stri ng speci fyi ng name of wavel et used for
decomposi ti on (e.g., db3)
Two-Di mensi onal Di screte W avelet Analysi s
2-43
Two-Dimensional Discrete Wavelet Analysis
Thi s secti on takes you thr ough the featur es of two-di mensi onal di scr ete
wavel et anal ysi s usi ng the MATLAB Wavel et Tool box.
The Wavel et Tool box provi des these functi ons for i mage anal ysi s. For mor e
i nfor mati on, see the Command Reference (Chapter 8).
Analysis-Decomposition Functions:
Synthesis-Reconstruction Functions:
Decomposition Structure Utilities:
Function Name Purpose
dwt 2 One-step decomposi ti on
wav ede c2 Decomposi ti on
Function Name Purpose
i dwt 2 One-step r econstructi on
wave r e c 2 Ful l reconstr ucti on
wr coef 2 Sel ecti ve r econstructi on
upcoef 2 Si ngl e reconstr ucti on
Function Name Purpose
de t c oe f 2 Extr acti on of detai l coeffi ci ents
appc oe f 2 Extr acti on of approxi mati on coeffi ci ents
upwl ev 2 Recomposi ti on of decomposi ti on str uctur e
2 Usi ng Wavelets
2-44
De-noising and Compression:
I n thi s secti on, youl l l ear n:
How to l oad an i mage
How to anal yze an i mage
How to perform one-step and mul ti -l evel i mage decomposi ti ons and
reconstr ucti ons (command l i ne onl y)
How to use Square and Tree mode featur es (GUI onl y)
How to zoom i n on detai l (GUI onl y)
How to compr ess an i mage
Two-Dimensional Analysis Using the Command Line
I n thi s exampl e wel l show how you can use two-di mensi onal wavel et anal ysi s
to compress an i mage effi ci entl y wi thout sacri fi ci ng i ts cl ar i ty.
Note: I nstead of usi ng di r ectl y i mage ( I ) i n or der to vi sual i ze the i mage I , we
use i mage ( wc odemat ( I ) ) whi ch di spl ays a rescal ed versi on of I l eadi ng to a
cl ear er presentati on of the detai l s and approxi mati ons (see wc odemat i n
Chapter 8).
Function Name Purpose
ddenc mp Provi de defaul t val ues for de-noi si ng and compressi on
wdenc mp Wavel et de-noi si ng and compr essi on
Two-Di mensi onal Di screte W avelet Analysi s
2-45
Loading an Image.
1 From the MATLAB prompt, type:
l oad wbar b;
whos
2 Di spl ay the i mage. Type:
i mage ( X) ; col or map( map)
Converting an Indexed Image to a Grayscale Image.
3 I f the col orbar i s smooth, the wavel et tr ansfor m can be di rectl y appl i ed to
the i ndexed i mage, other wi se the i ndexed i mage shoul d be converted to
grayscal e format. See Wor ki ng wi th I ndexed I mages at the end of thi s
chapter for more i nfor mati on.
Si nce the col or map i s smooth i n thi s i mage, you can now perform the
decomposi ti on.
Performing A One-Step Wavelet Decomposition of an Image.
4 Perform a one-step decomposi ti on of the i mage usi ng the bi or 3. 7 wavel et.
Type:
[ cA1, cH1, c V1, c D1] = dwt 2( X, ' bi or 3. 7' ) ;
Thi s generates the coeffi ci ent matr i ces of the l evel -one approxi mati on (c A1)
and hor i zontal , verti cal and di agonal detai l s (cH1, c V1, c D1, r especti vel y).
Name Si z e El ement s Byt es Cl as s
X 256 by 256 65536 524288 doubl e ar r ay
map 192 by 3 576 4608 doubl e ar r ay
50 100 150 200 250
50
100
150
200
250
20
40
60
80
100
120
140
160
180
2 Usi ng Wavelets
2-46
Constructing Approximations and Details from the Coefficients.
5 To constr uct the l evel -one appr oxi mati on and detai l s (A
1
, H
1
, V
1
, and D
1
) from
the coeffi ci ents c A
1
, cH
1
, cV
1
, and c D
1
, type:
A1 = upc oe f 2( ' a' , cA1, ' bi or 3. 7' , 1) ;
H1 = upc oe f 2( ' h' , cH1, ' bi or 3. 7' , 1) ;
V1 = upc oe f 2( ' v' , cV1, ' bi or 3. 7' , 1) ;
D1 = upc oe f 2( ' d' , cD1, ' bi or 3. 7' , 1) ;
Displaying the Approximation and Details.
6 To di spl ay the r esul ts of the l evel 1 decomposi ti on, type:
c ol or map( map) ;
s ubpl ot ( 2, 2, 1) ; i mage ( wcode mat ( A1, 192) ) ;
t i t l e ( ' Appr oxi mat i on A1' )
s ubpl ot ( 2, 2, 2) ; i mage ( wcode mat ( H1, 192) ) ;
t i t l e ( ' Hor i z ont al Det ai l H1' )
s ubpl ot ( 2, 2, 3) ; i mage ( wcode mat ( V1, 192) ) ;
t i t l e ( ' Ver t i cal Det ai l V1' )
s ubpl ot ( 2, 2, 4) ; i mage ( wcode mat ( D1, 192) ) ;
t i t l e( ' Di agonal Det ai l D1' )
Two-Di mensi onal Di screte W avelet Analysi s
2-47
Regenerating an Image by One-Step Inverse Wavelet Transform.
7 To fi nd the i nver se tr ansform, type:
Xs y n = i dwt 2( c A1, c H1, cV1, cD1, ' bi or 3. 7' ) ;
Thi s r econstructs or synthesi zes the ori gi nal i mage fr om the coeffi ci ents of
the l evel 1 approxi mati on and detai l s.
Performing a Multi-Level Wavelet Decomposition of an Image.
8 To per for m a l evel 2 decomposi ti on of the i mage (agai n usi ng the bi or 3. 7
wavel et), type:
[ C, S] = wave de c2( X, 2, ' bi or 3. 7' ) ;
where X i s the ori gi nal i mage matri x, and 2 i s the l evel of decomposi ti on.
The coeffi ci ents of al l the components of a second-l evel decomposi ti on (that
i s, the second-l evel appr oxi mati on and the fi r st two l evel s of detai l ) ar e
r etur ned concatenated i nto one vector , C. Argument S i s a bookkeepi ng
matri x that keeps track of the si zes of each component.
Extracting Approximation and Detail Coefficients.
9 To extract the l evel 2 appr oxi mati on coeffi ci ents fr om C, type:
c A2 = appc oe f 2( C, S, ' bi or 3. 7' , 2) ;
10 To extract the fi rst- and second-l evel detai l coeffi ci ents fr om C, type:
c H2 = det c oe f 2( ' h' , C, S, 2) ; cV2 = det coef 2( ' v ' , C, S, 2) ;
c D2 = det c oe f 2( ' d' , C, S, 2) ;
c H1 = det c oe f 2( ' h' , C, S, 1) ; cV1 = det coef 2( ' v ' , C, S, 1) ;
c D1 = det c oe f 2( ' d' , C, S, 1) ;
where the fi rst ar gument (' h' , ' v ' , or ' d' ) determi nes the type of detai l
(hor i zontal , ver ti cal , di agonal ) extracted, and the l ast argument deter mi nes
the l evel .
2 Usi ng Wavelets
2-48
Reconstructing the Level 2 Approximation.
11 To reconstr uct the l evel 2 approxi mati on from C, type:
A2 = wr c oe f 2( ' a' , C, S, ' bi or 3. 7' , 2) ;
Reconstructing the Level 1 and 2 Details.
12 To reconstr uct the l evel 1 and 2 detai l s from C, type:
H1 = wr c oe f 2( ' h' , C, S, ' bi or 3. 7' , 1) ;
V1 = wr c oe f 2( ' v' , C, S, ' bi or 3. 7' , 1) ;
D1 = wr c oe f 2( ' d' , C, S, ' bi or 3. 7' , 1) ;
H2 = wr c oe f 2( ' h' , C, S, ' bi or 3. 7' , 2) ;
V2 = wr c oe f 2( ' v' , C, S, ' bi or 3. 7' , 2) ;
D2 = wr c oe f 2( ' d' , C, S, ' bi or 3. 7' , 2) ;
Two-Di mensi onal Di screte W avelet Analysi s
2-49
Displaying the Results of a Multi-Level Decomposition.
Note: Wi th al l the detai l s i nvol ved i n a mul ti -l evel i mage decomposi ti on, i t
makes sense to i mpor t the decomposi ti on i nto the Wavelet 2-D gr aphi cal tool
i n order to more easi l y di spl ay i t. For i nfor mati on on how to do thi s, see
Loadi ng Decomposi ti ons on page 67.
13 To di spl ay the resul ts of the l evel 2 decomposi ti on, type:
col or map( map) ;
s ubpl ot ( 2, 4, 1) ; i mage( ( wcodemat ( A1, 192) ) ; t i t l e( ' Appr oxi mat i on A1' )
s ubpl ot ( 2, 4, 2) ; i mage( ( wcodemat ( H1, 192) ) ; t i t l e( ' Hor i zont al
Det ai l H1' )
s ubpl ot ( 2, 4, 3) ; i mage( ( wcodemat ( V1, 192) ) ; t i t l e( ' Ver t i cal
Det ai l V1' )
s ubpl ot ( 2, 4, 4) ; i mage( ( wcodemat ( D1, 192) ) ; t i t l e( ' Di agonal
Det ai l D1' )
s ubpl ot ( 2, 4, 5) ; i mage( ( wcodemat ( A2, 192) ) ; t i t l e( ' Appr oxi mat i on A2' )
s ubpl ot ( 2, 4, 6) ; i mage( ( wcodemat ( H2, 192) ) ; t i t l e( ' Hor i zont al
Det ai l H2' )
s ubpl ot ( 2, 4, 7) ; i mage( ( wcodemat ( V2, 192) ) ; t i t l e( ' Ver t i cal
Det ai l V2' )
s ubpl ot ( 2, 4, 8) ; i mage( ( wcodemat ( D2, 192) ) ; t i t l e( ' Di agonal Det ai l D2' )
2 Usi ng Wavelets
2-50
Reconstructing the Original Image from the Multilevel Decomposition.
14 To reconstr uct the ori gi nal i mage fr om the wavel et decomposi ti on str ucture,
type:
X0 = wav er ec 2( C, S, ' bi or 3. 7' ) ;
Thi s r econstructs or synthesi zes the ori gi nal i mage fr om the coeffi ci ents C of
the mul ti -l evel decomposi ti on.
Compressing an Image.
15 To compr ess the or i gi nal i mage X, use the dde ncmp command to cal cul ate the
defaul t parameter s and the wdencmp command to perform the actual
compressi on. Type:
[ t hr , s or h, ke epapp] = ddencmp( ' cmp' , ' wv ' , X) ;
[ Xc omp, CXC, LXC, PERF0, PERFL2] =
wde nc mp( ' gbl ' , C, S, ' bi or 3. 7' , 2, t hr , s or h, ke epapp) ;
Note that we pass i n to wde nc mp the resul ts of the decomposi ti on (C and S)
we cal cul ated i n Step 7 on page 2-47. We al so speci fy the bi or 3. 7 wavel et,
because we used thi s wavel et to per form the ori gi nal anal ysi s. Fi nal l y, we
speci fy the gl obal threshol di ng opti on ' gbl ' . See the ddencmp and wde nc mp
r efer ence entri es for mor e i nformati on about the use of these commands.
Two-Di mensi onal Di screte W avelet Analysi s
2-51
Displaying the Compressed Image.
16 To vi ew the compressed i mage si de by si de wi th the or i gi nal , type:
c ol or map( map) ;
s ubpl ot ( 121) ; i mage( X) ; t i t l e ( ' Or i gi nal I mage ' ) ;
axi s s quar e
s ubpl ot ( 122) ; i mage( Xcomp) ; t i t l e ( ' Compr es s e d I mage ' ) ;
axi s s quar e
PERF0
86. 6550
PERFL2
99. 9779
These returned val ues tel l , respecti vel y, what per centage of the wavel et
coeffi ci ents was set to zero and what per centage of the i mages energy was
preser ved i n the compressi on process.
Note that, even though the compr essed i mage i s constr ucted fr om onl y about
hal f as many nonzer o wavel et coeffi ci ents as the or i gi nal , there i s al most no
detectabl e deteri or ati on i n the i mage qual i ty.
2 Usi ng Wavelets
2-52
Two-Dimensional Analysis Using the Graphical
Interface
I n thi s secti on we expl ore the same i mage as i n the previ ous secti on, but we use
the graphi cal i nterface tool s to anal yze the i mage.
Starting the 2-D Wavelet Analysis Tool.
1 Fr om the MATLAB pr ompt, type
wave me nu.
The Wavelet Tool Main Menu appear s.
2 Cl i ck the Wavelet 2-D menu i tem.
The di screte wavel et anal ysi s tool for two-di mensi onal i mage data appear s.
Two-Di mensi onal Di screte W avelet Analysi s
2-53
Loading an Image.
3 From the File menu, choose the Load Image opti on.
4 When the Load Image di al og box appears, sel ect the demo MAT-fi l e
wbar b. mat , whi ch shoul d r esi de i n the MATLAB di r ector y
t ool box /wave l e t /wav edemo. Cl i ck the OK button.
The i mage i s l oaded i nto the Wavelet 2-D tool .
2 Usi ng Wavelets
2-54
Analyzing an Image.
5 Usi ng the Wavelet and Levels menus l ocated to the upper r i ght, deter mi ne
the wavel et fami l y and type as wel l as the number of l evel s to be used for the
anal ysi s.
For thi s anal ysi s, sel ect the bi or 3. 7 wavel et at l evel 2.
6 Cl i ck the Analyze button.
After a pause for computati on, the Wavelet 2-D tool di spl ays i ts anal ysi s.
Visualization
Decomposition
Original
Synthesized
image
image
Two-Di mensi onal Di screte W avelet Analysi s
2-55
Using Square Mode Features.
By defaul t, the anal ysi s appear s i n Squar e Mode. Thi s mode i ncl udes four
di fferent di spl ays. I n the upper l eft i s the or i gi nal i mage. Bel ow that i s the
i mage r econstructed from the var i ous approxi mati ons and detai l s. To the
l ower r i ght i s a decomposi ti on showi ng the coarsest appr oxi mati on
coeffi ci ents and al l the hor i zontal , di agonal , and verti cal detai l coeffi ci ents.
Fi nal l y, the vi sual i zati on space at the top r i ght di spl ays any component of
the anal ysi s that you want to l ook at more cl osel y.
7 Cl i ck on any decomposi ti on component i n the l ower ri ght wi ndow.
A green border hi ghl i ghts the sel ected component. At the l ower ri ght of the
Wavelet 2-D wi ndow, there i s a set of three buttons l abel ed Operati ons on
sel ected i mage.
8 Cl i ck the Visualize button.
The sel ected i mage i s di spl ayed i n the vi sual i zati on ar ea. You are seei ng the
r aw, unr econstructed two-di mensi onal wavel et coeffi ci ents. Usi ng the other
buttons, you can di spl ay the r econstructed versi on of the sel ected i mage
component, or you can vi ew the sel ected component at ful l screen resol uti on.
Visualized Approximation A
2
Reconstructed Approximation A
2
2 Usi ng Wavelets
2-56
Using Tree Mode Features.
9 Choose Tree fr om the View Mode menu.
Your di spl ay changes to reveal :
Thi s i s the same i nformati on shown i n squar e mode, wi th i n addi ti on al l the
appr oxi mati on coeffi ci ents, but ar ranged to emphasi ze the tr ee structure of
the decomposi ti on. The vari ous buttons and menus wor k just the same as
they do i n squar e mode.
Two-Di mensi onal Di screte W avelet Analysi s
2-57
Zooming in on Detail.
10 Drag a rubber band box (by hol di ng down the l eft mouse button) over the
porti on of the i mage you want to magni fy.
11 Cl i ck the XY+ button (l ocated at the bottom of the screen) to zoom
hor i zontal l y and ver ti cal l y.
The Wavelet 2-D tool enl arges the di spl ayed i mages.
To zoom back to or i gi nal magni fi cati on, cl i ck the History < button.
2 Usi ng Wavelets
2-58
Compressing an Image.
12 Cl i ck the Compress button, l ocated to the upper r i ght of the Wavelet 2-D
wi ndow.
The Wavelet 2-D Compression wi ndow appears.
The tool automati cal l y sel ects threshol di ng l evel s to provi de a good i ni ti al
bal ance between r etai ni ng the i mages energy whi l e mi ni mi zi ng the number
of coeffi ci ents needed to represent the i mage.
However , you can al so adjust thr eshol ds manual l y usi ng the Thresholding
menu and sl i ders or corr espondi ng edi ts. Sel ect from the menu whether you
want to adjust thr eshol ds for hor i zontal , di agonal or ver ti cal detai l s, then
use the sl i ders to make the actual adjustments for each l evel .
For thi s exampl e, wel l accept the defaul t thr eshol ds.
Compress button
Threshold menu
Two-Di mensi onal Di screte W avelet Analysi s
2-59
13 To compr ess the or i gi nal i mage, cl i ck the Compress button.
After a pause for computati on, the compressed i mage appear s besi de the
ori gi nal . Noti ce that compressi on el i mi nated al most hal f the coeffi ci ents, yet
no more than one-hal f of one percent of i mage ener gy was l ost i n the pr ocess.
Importing and Exporting Information from the
Graphical Interface
The Wavelet 2-D graphi cal tool l ets you i mport i nfor mati on fr om and expor t
i nfor mati on to your di sk, i f you adhere to the proper fi l e for mats.
Saving Information to the Disk
You can save synthesi zed i mages, coeffi ci ents, and decomposi ti ons fr om the
Wavelet 2-D tool to the di sk, where the i nfor mati on can be mani pul ated and
l ater r ei mpor ted i nto the graphi cal tool .
Load information from disk
Save information to disk
2 Usi ng Wavelets
2-60
Saving Synthesized Images.
You can pr ocess an i mage i n the Wavelet 2-D tool and then save the processed
i mage to a MAT-fi l e.
For exampl e, l oad the demo anal ysi s
FileDemo Analysisat level 3, with sym4 > detail Durer, and
perfor m a compr essi on on the or i gi nal i mage. When you cl ose the Wavelet 2-D
Compression wi ndow, update the synthesi zed i mage by cl i cki ng Yes i n the
di al og box that appears.
Then, fr om the Wavelet 2-D tool , sel ect the FileSave Synthesized Image
menu opti on.
A di al og box appears al l owi ng you to sel ect a di r ectory and fi l ename for the
MAT-fi l e. For thi s exampl e, choose the name s ymage.
To l oad the i mage i nto your wor kspace, si mpl y type:
l oad s ymage
whos
Saving Discrete Wavelet Transform Coefficients.
The Wavelet 2-D tool l ets you save the coeffi ci ents of a di scr ete wavel et
tr ansfor m (DWT) to your di sk. The tool box cr eates a MAT-fi l e i n the cur rent
di r ectory wi th a name you choose.
To save the DWT coeffi ci ents from the present anal ysi s, use the menu opti on
FileSave Coefficients.
A di al og box appear s that l ets you speci fy a di rectory and fi l ename for stor i ng
the coeffi ci ents.
Consi der the demo anal ysi s
FileDemo Analysisat level 3, with sym4 > Detail Durer.
Name Si z e El ement s Byt e s Cl as s
map 64 by 3 192 1536 doubl e ar r ay
s y mage 359 by 371 133189 1065512 doubl e ar r ay
Two-Di mensi onal Di screte W avelet Analysi s
2-61
After savi ng the conti nuous wavel et coeffi ci ents to the fi l e dur er . mat , l oad the
var i abl es i nto your wor kspace.
l oad dur e r
whos
Var i abl es coef s and s i z es contai n the di screte wavel et coeffi ci ents and the
associ ated matr i x si zes. Mor e pr eci sel y, i n the above exampl e, c oe f s i s a
1-by-142299 vector of concatenated coeffi ci ents, and s i z es gi ves the l ength of
each component.
Saving Decompositions.
The Wavelet 2-D tool l ets you save the enti r e set of data from a di scr ete
wavel et anal ysi s to your di sk. The tool box cr eates a MAT-fi l e i n the cur rent
di rectory wi th a name you choose, fol l owed by the extensi on wa2 (wavel et
anal ysi s 2-D).
Open the Wavelet 2-D tool and l oad the demo anal ysi s FileDemo
Analysisat level 3, with sym4 > Detail Durer.
To save the data fr om thi s anal ysi s, use the menu opti on FileSave
Decomposition.
A di al og box appears that l ets you speci fy a di rectory and fi l ename for stor i ng
the decomposi ti on data. Type the name dur e r .
Name Si z e El e me nt s By t e s Cl as s
c oe f s 1 by 142299 142299 1138392 doubl e ar r ay
s i z es 5 by 2 10 80 doubl e ar r ay
2 Usi ng Wavelets
2-62
After savi ng the decomposi ti on data to the fi l e dur er . wa2, l oad the var i abl es
i nto your wor kspace.
l oad dur er . wa2 - mat
whos
Var i abl es c oe f s and s i z e s contai n the wavel et decomposi ti on structure. Other
vari abl es contai n the wavel et name, the col ormap, and the fi l ename contai ni ng
the data.
Loading Information into the Wavelet 2-D Tool
You can l oad i mages, coeffi ci ents, or decomposi ti ons i nto the gr aphi cal
i nterface. The i nformati on you l oad may have been pr evi ousl y exported from
the gr aphi cal i nter face and then mani pul ated i n the workspace, or i t may have
been i nfor mati on you generated i ni ti al l y fr om the command l i ne.
I n ei ther case, you must obser ve the str i ct fi l e formats and data str uctur es used
by the Wavelet 2-D tool , or el se err or s wi l l r esul t when you tr y to l oad
i nfor mati on.
Loading Images.
Thi s tool box supports onl y indexed images. An i ndexed i mage i s a matri x
contai ni ng onl y i nteger s from 1 to n, wher e n i s the number of col ors i n the
i mage.
Thi s i mage may opti onal l y be accompani ed by a n-by-3 matr i x cal l ed map. Thi s
i s the col or map associ ated wi th the i mage. When MATLAB di spl ays such an
i mage, i t uses the val ues of the matri x to l ook up the desi red col or i n thi s
col or map. I f the col ormap i s not gi ven, the Wavelet 2-D tool uses a monotoni c
col or map wi th max ( max( X) ) mi n( mi n( X) ) +1 col ors.
Name Si z e El e me nt s Byt es Cl as s
c oe f s 1 by 142299 142299 1138392 doubl e ar r ay
dat a_name 1 by 6 6 48 doubl e ar r ay
map 64 by 3 192 1536 doubl e ar r ay
s i z es 5 by 2 10 80 doubl e ar r ay
wav e_name 1 by 4 4 32 doubl e ar r ay
Two-Di mensi onal Di screte W avelet Analysi s
2-63
To l oad an i mage youve constructed i n your MATLAB workspace i nto the
Wavelet 2-D tool , save the i mage (and opti onal l y, the vari abl e map) i n a
MAT-fi l e that has the same name as the i mage matri x i tsel f.
For i nstance, suppose youve cr eated an i mage cal l ed br ai n and want to
anal yze i t i n the Wavelet 2-D tool . Type:
s av e br ai n
To l oad thi s i mage i nto the Wavelet 2-D tool , use the menu opti on
FileLoad Image.
A di al og box appear s that l ets you sel ect the appropr i ate MAT -fi l e to be l oaded.
Caution: The graphi cal tool s al l ow you to l oad an i mage that does not contai n
i ntegers from 1 to n. The computati ons wi l l be cor rect si nce they act di rectl y
on the matr i x, but the di spl ay of the i mage wi l l be str ange. The val ues l ess
than 1 wi l l be eval uated as 1, the val ues gr eater than n wi l l be eval uated as n,
and a real val ue wi thi n the i nter val [1,n] wi l l be eval uated as the cl osest
i nteger.
Note that the coeffi ci ents, appr oxi mati ons, and detai l s pr oduced by wavel et
decomposi ti on ar e not i ndexed i mage matri ces.
I n or der to di spl ay these i mages i n a sui tabl e way, the Wavelet 2-D tool fol l ows
these r ul es:
Reconstructed approxi mati ons ar e di spl ayed usi ng the col ormap map.
The coeffi ci ents and the r econstructed detai l s are di spl ayed usi ng the
col ormap map appl i ed to a rescal ed versi on of the matr i ces.
2 Usi ng Wavelets
2-64
Loading Discrete Wavelet Transform Coefficients.
To l oad di screte wavel et tr ansfor m (DWT) coeffi ci ents i nto the Wavelet 2-D
tool , you must fi r st save the appr opr i ate data i n a MAT-fi l e contai ni ng onl y two
vari abl es: coeffi ci ents vector coef s and bookkeepi ng matri x s i z es .
Var i abl e coef s must be a vector of concatenated DWT coeffi ci ents. The coe f s
vector for an n-l evel decomposi ti on contai ns 3n+1 secti ons, consi sti ng of the
l evel -n appr oxi mati on coeffi ci ents, fol l owed by the hori zontal , verti cal , and
di agonal detai l coeffi ci ents, i n that order for each l evel . Vari abl e s i z e s i s a
matri x, the rows of whi ch speci fy: the si ze of c A
n
, the si ze of cH
n
(or c V
n
,
or c D
n
),..., the si ze of cH
1
(or c V
1
, or c D
1
) and the si ze of the ori gi nal i mage X.
The si zes of ver ti cal and di agonal detai l s ar e the same as the hor i zontal detai l .
After constr ucti ng or edi ti ng the appropr i ate data i n your workspace, type:
s av e myf i l e
Use the FileLoad Coefficients menu opti on from the Wavelet 2-D tool to
l oad the data i nto the gr aphi cal tool .
A di al og box appears, al l owi ng you to choose the di rectory and fi l e i n whi ch
your data resi de.
Loading Decompositions.
To l oad di screte wavel et tr ansfor m decomposi ti on data i nto the Wavelet 2-D
tool , you must fi rst save the appropr i ate data i n a MAT-fi l e wi th extensi on wa2
(wavel et anal ysi s 2-D).
cA
n
c oe f s ( 3n+1 s e c t i ons )
cH
n
cV
n
cD
n
cH
n1
cV
n1
cD
n1
cH
1
cV
1
cD
1
. . .
32 32
.
.
.
32 32
256 256
s i z e s ( n+2- by - 2)
512 512 X
Two-Di mensi onal Di screte W avelet Analysi s
2-65
The MAT-fi l e must contai n these var i abl es:
After constr ucti ng or edi ti ng the appropri ate data i n your wor kspace, type:
s av e my f i l e. wa2
Use the FileLoad Decomposition menu opti on fr om the Wavelet 2-D tool
to l oad the i mage decomposi ti on data.
A di al og box appear s, al l owi ng you to choose the di rector y and fi l e i n whi ch
your data resi de.
Variable Description
coe f s Vector of concatenated DWT coeffi ci ents
dat a_name Str i ng speci fyi ng name of decomposi ti on
map Opti onal n-by-3 col or map matri x.
s i z es Matri x speci fyi ng si zes of components of c oe f s and of
the ori gi nal i mage
wav e_name Str i ng speci fyi ng name of wavel et used for decomposi -
ti on (e.g., db3)
2 Usi ng Wavelets
2-66
Working with Indexed Images
Thi s secti on provi des addi ti onal i nformati on about worki ng wi th i mages i n the
Wavel et Tool box. I t descr i bes the types of supported i mages and how MATLAB
r epr esents them, as wel l as techni ques for anal yzi ng col or i mages.
Understanding Images in MATLAB
The basi c data str uctur e i n MATLAB i s the rectangul ar matrix, an ordered set
of r eal or compl ex el ements. Thi s object i s natur al l y sui ted to the
r epr esentati on of images, whi ch are real -val ued, or der ed sets of col or or
i ntensi ty data. (Thi s tool box does not suppor t compl ex-val ued i mages.)
I n thi s suppl ement, the wor d pixel denotes a si ngl e el ement i n an i mage
matri x. You can sel ect a si ngl e pi xel fr om an i mage matri x usi ng nor mal matri x
subscri pti ng. For exampl e,
I ( 2, 15)
r etur ns the val ue of the pi xel at row 2 and col umn 15 of the i mage I . Pi xel i s
deri ved from picture element and usual l y denotes a si ngl e dot on a computer
di spl ay. By defaul t, MATLAB scal es i mages to fi l l the di spl ay axes; therefore,
an i mage pi xel may use mor e than a si ngl e pi xel on the scr een.
Indexed Images
A typi cal col or i mage requi res two matr i ces: a col or map and an i mage matr i x.
The colormap i s an order ed set of val ues that r epresent the col ors i n the i mage.
For each i mage pi xel , the image matrix contai ns a corr espondi ng i ndex i nto the
col or map. (The el ements of the i mage matr i x ar e fl oati ng-poi nt i ntegers, or
flints, whi ch MATLAB stor es as doubl e-pr eci si on val ues.)
The si ze of the col ormap matr i x i s n-by-3 for an i mage contai ni ng n col ors. Each
r ow of the col ormap matri x i s a 1-by-3 red, green, bl ue (RGB) col or vector
c ol or = [ R G B]
that speci fi es the i ntensi ty of the r ed, green, and bl ue components of that col or.
R, G, and B are real scal ar s that r ange from 0.0 (bl ack) to 1.0 (ful l i ntensi ty).
MATLAB tr ansl ates these val ues i nto di spl ay i ntensi ti es when you di spl ay an
i mage and i ts col ormap.
W orki ng wi th Indexed Images
2-67
When MATLAB di spl ays an i ndexed i mage, i t uses the val ues i n the i mage
matr i x to l ook up the desi red col or i n the col or map. For i nstance, i f the i mage
matr i x contai ns the val ue 18 i n matri x l ocati on (86,198), then the col or for pi xel
(86,198) i s the col or from row 18 of the col or map.
Outsi de MATLAB, i ndexed i mages wi th n col or s often contai n val ues from 0 to
n1. These val ues are i ndi ces i nto a col or map wi th 0 as i ts fi r st i ndex. Si nce
MATLAB matr i ces start wi th i ndex 1, you must i ncrement each val ue i n the
i mage, or shift up the i mage, to cr eate an i mage that you can mani pul ate wi th
tool box functi ons.
75 10 12 21 40 53 53
75 14 17 21 21 53 53
75 8 5 8 10 30 15
51 15 18 31 31 18 16
56 31 18 31 31 31 31
0. 5176 0. 1608 0. 0627
0. 1608 0. 3529 0. 0627
0. 6471 0. 1294 0. 0627
0. 1922 0. 2902 0. 4510
0. 5804 0. 1294 0. 2902
21
1
128
Indexed Image Matrix
Colormap Matrix
17
l oad cl own
i mage( X)
col or map( map)
2 Usi ng Wavelets
2-68
Wavelet Decomposition of Indexed Images
The Wavel et Tool box suppor ts onl y indexed images wi th l i near , monotonic
col or maps. These i mages can be thought of as scal ed i ntensi ty i mages, wi th
matri x el ements contai ni ng onl y i ntegers from 1 to n, where n i s the number of
di screte shades i n the i mage.
I f the col ormap i s not provi ded, the graphi cal user i nterface tool s di spl ay the
i mage and pr ocessi ng resul ts usi ng a monotoni c col or map wi th
max ( max ( X) ) mi n( mi n( X) ) +1 col ors.
Si nce the i mage col or map i s onl y used for di spl ay pur poses, some i ndexed
i mages may need to be preprocessed i n or der to achi eve the corr ect r esul ts fr om
the wavel et decomposi ti on.
I n gener al , col or i ndexed i mages do not have l i near, monotoni c col ormaps and
need to conver ted i nto the appr opri ate gr ay scal e i ndexed i mage befor e
perfor mi ng a wavel et decomposi ti on. The I mage Processi ng Tool box provi des a
compr ehensi ve set of functi ons that l et you easi l y conver t between i mage types.
Shoul d you not have the I mage Pr ocessi ng Tool box, the exampl e bel ow
demonstrates how thi s conversi on may be per for med, usi ng basi c MATLAB
commands.
l oad x pmndr l l
whos
i mage ( X2) , t i t l e ( ' Or i gi nal Col or I ndex e d I mage' )
c ol or map( map) , c ol or bar
Name Si z e El e me nt s Byt es Cl as s
X2 192 by 200 38400 307200 doubl e ar r ay
map 64 by 3 192 1536 doubl e ar r ay
W orki ng wi th Indexed Images
2-69
The col or bar to the ri ght of the i mage i s not smooth and does not monotoni cal l y
progr ess fr om dar k to l i ght. Thi s type of i ndexed i mage i s not sui tabl e for di r ect
wavel et decomposi ti on wi th the tool box and needs to be pr eprocessed.
Fi rst we separ ate the col or i ndexed i mage i nto i ts RGB components,
R = map( X2, 1) ; R = r e s hape( R, s i z e ( X2) ) ;
G = map( X2, 2) ; G = r e s hape( G, s i z e ( X2) ) ;
B = map( X2, 3) ; B = r e s hape( B, s i z e ( X2) ) ;

Now we conver t the RGB matri ces i nto a gray scal e i ntensi ty i mage, usi ng the
standar d perceptual wei ghti ngs for the three col or components,
Xr gb = 0. 2990*R + 0. 5870*G + 0. 1140*B;

Orignal Color Indexed Image
20 40 60 80 100 120 140 160 180 200
20
40
60
80
100
120
140
160
180
10
20
30
40
50
60
2 Usi ng Wavelets
2-70
Next, we conver t the gr ay scal e i ntensi ty i mage back to a gr ay scal e i ndexed
i mage wi th 64 di sti nct l evel s, and create a new col or map wi th 64 l evel s of gr ay.
n = 64; % Number of s hades i n new i nde xe d i mage
X = r ound( Xr gb*( n- 1) ) + 1;
map2 = gr ay( n) ;

f i gur e
i mage ( X) , t i t l e( ' Pr oc es s e d Gr ay Sc al e I ndex ed I mage' )
c ol or map( map2) , c ol or bar
The col or bar of the conver ted i mage i s now l i near and has a smooth tr ansi ti on
from dark to l i ght. The i mage i s now sui tabl e for wavel et decomposi ti on.
0
10
20
30
40
50
60
Processed Gray Scale Indexed Image
20 40 60 80 100 120 140 160 180 200
20
40
60
80
100
120
140
160
180
W orki ng wi th Indexed Images
2-71
Fi nal l y, we save the conver ted i mage i n a form compati bl e wi th the Wavel et
Tool box graphi cal user i nter face,
baboon= X;
map = map2;
s av e baboon baboon map
How Decompositions Are Displayed
Note that the coeffi ci ents, appr oxi mati ons, and detai l s pr oduced by wavel et
decomposi ti on ar e not i ndexed i mage matri ces.
I n order to di spl ay these i mages i n a sui tabl e way, the gr aphi cal user i nter face
tool s fol l ow these rul es:
Reconstructed approxi mati ons ar e di spl ayed usi ng the col ormap map.
The coeffi ci ents and the r econstructed detai l s are di spl ayed usi ng the
col ormap map appl i ed to a rescal ed versi on of the matr i ces.
2 Usi ng Wavelets
2-72

3
Wavel et Appl i cati ons
3-3 Detecting Discontinuities and Breakdown Points I
3-4 Di scussi on
3-6 Detecting Discontinuities and Breakdown Points II
3-7 Di scussi on
3-8 Detecting Long-Term Evolution
3-9 Di scussi on
3-10 Detecting Self-Similarity
3-10 Wavel et Coeffi ci ents and Sel f-Si mi l ari ty
3-11 Di scussi on
3-12 Identifying Pure Frequencies
3-12 Di scussi on
3-15 Suppressing Signals
3-16 Di scussi on
3-18 De-Noising Signals
3-18 Di scussi on
3-21 Compressing Signals
3-22 Di scussi on
3 Wavelet Applications
3-2
Thi s chapter expl or es var i ous appl i cati ons of wavel ets by presenti ng a seri es of
sampl e anal yses deal i ng wi th:
Detecti ng Di sconti nui ti es and Br eakdown Poi nts (I and I I )
Detecti ng Long-Ter m Evol uti on
Detecti ng Sel f-Si mi l ari ty
I denti fyi ng Pur e Frequenci es
Suppr essi ng Si gnal s
De-Noi si ng Si gnal s
Compressi ng Si gnal s
Each exampl e i s fol l owed by a di scussi on of the useful ness of wavel et anal ysi s
for the parti cul ar appl i cati on ar ea under consi derati on.
Use the gr aphi cal i nter face tool s to fol l ow al ong:
1 Fr om the MATLAB command l i ne, type:
wav eme nu.
2 Cl i ck on Wavelets 1-D (or other tool as appropri ate).
3 Load the sampl e anal ysi s by sel ecti ng the appr opri ate submenu i tem from
FileDemo Analysis.
Feel fr ee to expl or e on your own use the di ffer ent opti ons provi ded i n the
gr aphi cal i nter face to l ook at di fferent components of the si gnal , to compress or
de-noi se the si gnal , to exami ne si gnal stati sti cs, or to zoom i n and out on
di fferent si gnal features.
I f you want, tr y l oadi ng the corr espondi ng MAT-fi l e from the MATLAB
command l i ne, and use the wavel et tool box functi ons to i nvesti gate fur ther the
sampl e si gnal s. The MAT-fi l es are l ocated i n the di rectory: t ool box/wav el et /
wav edemo.
Ther e are al so other si gnal s i n the wave de mo di r ector y that you can anal yze on
your own.
Detecting Discontinuities and Breakdown Points I
3-3
Detecting Discontinuities and Breakdown Points I
The purpose of thi s exampl e i s to show how anal ysi s by wavel ets can detect the
exact i nstant when a si gnal changes. The di sconti nuous si gnal consi sts of a
sl ow si ne wave abr uptl y fol l owed by a medi um si ne wave.
The fi r st- and second-l evel detai l s (D
1
and D
2
) show the di sconti nui ty most
cl ear l y, because the r upture contai ns the hi gh fr equency part. Note that i f we
wer e only i nter ested i n i denti fyi ng the di sconti nui ty, db1 woul d be a mor e
useful wavel et to use for the anal ysi s than db5.
The di sconti nui ty i s l ocal i zed ver y preci sel y: onl y a smal l domai n around
ti me = 500 contai ns any l arge fi r st- or second-l evel detai l s.
Her e i s a noteworthy exampl e of an i mportant advantage of wavel et anal ysi s
over Fouri er . I f the same si gnal had been anal yzed by the Four i er transform,
we woul d not have been abl e to detect the i nstant when the si gnal s fr equency
changed, wher eas i t i s cl ear l y observabl e here.
Demo Analysis:
Frequency
br eakdown
MAT-file:
f r e qbr k. mat
Wavelet:
db5
Level:
5
3 Wavelet Applications
3-4
Detai l s D
3
and D
4
contai n the medi um si ne wave. The sl ow si ne i s cl earl y
i sol ated i n appr oxi mati on A
5
, fr om whi ch the hi gher-frequency i nformati on has
been fi l ter ed.
Discussion
The determi ni sti c par t of the si gnal may undergo abr upt changes such as a
jump, or a sharp change i n the fi r st or second deri vati ve. I n i mage processi ng,
one of the major pr obl ems i s edge detecti on, whi ch al so i nvol ves detecti ng
abr upt changes. Al so i n thi s category, we fi nd si gnal s wi th very r api d
evol uti ons such as transi ent si gnal s i n dynami c systems.
The mai n char acter i sti c of these phenomena i s that the change i s l ocal i zed i n
ti me or i n space.
The pur pose of the anal ysi s i s to deter mi ne:
The si te of the change (e.g., ti me or posi ti on),
The type of change (a r upture of the si gnal , or an abr upt change i n i ts fi r st
or second deri vati ve),
The ampl i tude of the change.
The l ocal aspects of wavel et anal ysi s ar e wel l adapted for pr ocessi ng thi s type
of event, as the pr ocessi ng scal es are l i nked to the speed of the change.
Guidelines for Detecting Discontinuities
Short wavel ets are often mor e effecti ve than l ong ones i n detecti ng a si gnal
r upture. I n the i ni ti al anal ysi s scal es, the support i s smal l enough to al l ow fi ne
anal ysi s. The shapes of di sconti nui ti es that can be i denti fi ed by the smal l est
wavel ets ar e si mpl er than those that can be i denti fi ed by the l ongest wavel ets.
Ther efor e, to i denti fy:
A si gnal di sconti nui ty, use the haar wavel et.
A ruptur e i n the j-th der i vati ve, sel ect a suffi ci entl y regul ar wavel et wi th at
l east j vani shi ng moments. (See Detecti ng Di sconti nui ti es and Breakdown
Poi nts I I on page 3-6.)
Detecting Discontinuities and Breakdown Points I
3-5
The pr esence of noi se, whi ch i s after al l a fai r l y common si tuati on i n si gnal
processi ng, makes i denti fi cati on of di sconti nui ti es more compl i cated. I f the
fi rst l evel s of the decomposi ti on can be used to el i mi nate a l ar ge part of the
noi se, the ruptur e i s someti mes vi si bl e at deeper l evel s i n the decomposi ti on.
Check, for exampl e, the sampl e anal ysi s FileDemo Analysisramp +
white noise (MAT-fi l e wnoi s l op). The rupture i s vi si bl e i n the l evel -si x
approxi mati on (A
6
) of thi s si gnal .
3 Wavelet Applications
3-6
Detecting Discontinuities and Breakdown Points II
The pur pose of thi s exampl e i s to show how anal ysi s by wavel ets can detect a
di sconti nui ty i n one of a si gnal s der i vati ves. The si gnal , whi l e apparentl y a
si ngl e smooth cur ve, i s actual l y composed of two separate exponenti al s that are
connected at ti me = 500. The di sconti nui ty occurs onl y i n the second der i vati ve,
at ti me = 500.
We have zoomed i n on the mi ddl e part of the si gnal to show mor e cl earl y what
happens around ti me = 500. The detai l s are hi gh onl y i n the mi ddl e of the
si gnal and ar e negl i gi bl e el sewher e. Thi s suggests the pr esence of
hi gh-fr equency i nfor mati on a sudden change or di sconti nui ty ar ound
ti me = 500.
Demo Analysis:
Second derivative
breakdown
MAT-file:
s c ddvbr k. mat
Wavelet:
db4
Level:
2
Detecting Discontinuities and Breakdown Points II
3-7
Discussion
Regul ari ty can be an i mportant cr i ter i on i n sel ecti ng a wavel et. We have
chosen to use db4, whi ch i s suffi ci entl y regul ar for thi s anal ysi s. Had we chosen
the haar wavel et, the di sconti nui ty woul d not have been detected. I f you try
repeati ng thi s anal ysi s usi ng haar at l evel two, youl l noti ce that the detai l s are
equal to zero at ti me = 500.
Note that i n order to detect a si ngul ar i ty the sel ected wavel et must be
suffi ci entl y regul ar, whi ch i mpl i es a l onger fi l ter i mpul se response.
See Chapter 6, Advanced Topi cs for a di scussi on of the mathemati cal
meani ng of r egul ar i ty and a compar i son of the regul ari ty of var i ous wavel ets.
3 Wavelet Applications
3-8
Detecting Long-Term Evolution
The purpose of thi s exampl e i s to show how anal ysi s by wavel ets can detect the
over al l trend of a si gnal . The si gnal i n thi s case i s a r amp obscured by col or ed
(l i mi ted-spectrum) noi se. (We have zoomed i n al ong the x-axi s to avoi d showi ng
edge effects.)
Ther e i s so much noi se i n the ori gi nal si gnal , s , that i ts over al l shape i s not
appar ent upon vi sual i nspecti on. I n thi s l evel -si x anal ysi s, we note that the
tr end becomes mor e and more cl ear wi th each approxi mati on, A1 to A6. Why i s
thi s?
The trend r epresents the sl owest par t of the si gnal . I n wavel et anal ysi s terms,
thi s cor responds to the gr eatest scal e val ue. As the scal e i ncreases, the
r esol uti on decr eases, pr oduci ng a better esti mate of the unknown tr end.
Demo Analysis:
Ramp + colored noise
MAT-file:
cnoi s l op. mat
Wavelet:
db3
Level:
6
Detecting Long-Term Evolution
3-9
Another way to thi nk of thi s i s i n ter ms of frequency. Successi ve
approxi mati ons possess pr ogr essi vel y l ess hi gh-frequency i nfor mati on. Wi th
the hi gher fr equenci es removed, whats l eft i s the over al l trend of the si gnal .
Discussion
Wavel et anal ysi s i s useful i n reveal i ng si gnal trends, a goal that i s
compl ementary to the one of r eveal i ng a si gnal hi dden i n noi se. I ts i mpor tant
to r emember that the tr end i s the sl owest part of the si gnal . I f the si gnal i tsel f
i ncl udes sharp changes, then successi ve approxi mati ons l ook l ess and l ess
si mi l ar to the or i gi nal si gnal .
Consi der the demo anal ysi s FileDemo AnalysisStep signal (MAT-fi l e
ws t ep. mat ). I t i s i nstructi ve to anal yze thi s si gnal usi ng the Wavelet 1-D tool
and to see what happens to the successi ve approxi mati ons. Try i t.
3 Wavelet Applications
3-10
Detecting Self-Similarity
The pur pose of thi s exampl e i s to show how anal ysi s by wavel ets can detect a
sel f-si mi l ar, or fr actal , si gnal . The si gnal here i s the Koch curve a syntheti c
si gnal that i s bui l t r ecursi vel y.
Thi s anal ysi s was perfor med wi th the Continuous Wavelet 1-D gr aphi cal
tool . A repeati ng patter n i n the wavel et coeffi ci ents pl ot i s character i sti c of a
si gnal that l ooks si mi l ar on many scal es.
Wavelet Coefficients and Self-Similarity
From an i ntui ti ve poi nt of vi ew, the wavel et decomposi ti on consi sts of
cal cul ati ng a resembl ance i ndex between the si gnal and the wavel et. I f the
i ndex i s l arge, the resembl ance i s str ong, otherwi se i t i s sl i ght. The i ndi ces are
the wavel et coeffi ci ents.
Demo Analysis:
Koch curve
MAT-file:
vonkoc h. mat
Wavelet:
coi f 3
Level:
Continuous, 2:2:128
Detecting Self-Similarity
3-11
I f a si gnal i s si mi l ar to i tsel f at di fferent scal es, then the resembl ance i ndex,
or wavel et coeffi ci ents al so wi l l be si mi l ar at di fferent scal es. I n the coeffi ci ents
pl ot, whi ch shows scal e on the verti cal axi s, thi s sel f-si mi l ari ty generates a
character i sti c pattern.
Discussion
The work of many author s and the tr i al s that they have carr i ed out suggest
that wavel et decomposi ti on i s ver y wel l adapted to the study of the fr actal
properti es of si gnal s and i mages.
When the char acter i sti cs of a fractal evol ve wi th ti me and become l ocal , the
si gnal i s what i s known as a multifractal. The wavel ets then are an especi al l y
sui tabl e tool for practi cal anal ysi s and generati on.

3 Wavelet Applications
3-12
Identifying Pure Frequencies
The pur pose of thi s exampl e i s to show how anal ysi s by wavel ets can effecti vel y
perfor m what i s thought of as a Four i er-type functi on that i s, resol vi ng a
si gnal i nto consti tuent si nusoi ds of di fferent frequenci es. The si gnal i s a sum
of thr ee pur e si ne waves.
Discussion
The si gnal i s a sum of three si nes: sl ow, medi um, and rapi d, whi ch have
peri ods (rel ati ve to the sampl i ng peri od of 1) of 200, 20, and 2, r especti vel y.
The sl ow, medi um, and r api d si nusoi ds appear most cl ear l y i n
appr oxi mati on A4, detai l D4, and detai l D1, r especti vel y. The sl i ght di fferences
that can be obser ved on the decomposi ti ons can be attr i buted to the sampl i ng
peri od.
Demo Analysis:
Sum of sines
MAT-file:
s ums i n. mat
Wavelet:
db3
Level:
5
Identifying Pure Frequencies
3-13
Detai l D1 contai ns pri mari l y the si gnal components whose per i od i s between 1
and 2 (i .e., the rapi d si ne), but thi s peri od i s not vi si bl e at the scal e whi ch i s
used for the gr aph. Zoomi ng i n on detai l D1 (see bel ow) r eveal s that each bel l y
i s composed of 10 osci l l ati ons, and thi s can be used to esti mate the per i od. We
i ndeed fi nd that i t i s cl ose to 2.
The detai l D3, and to an even greater extent, detai l D4, contai n the medi um
si ne frequenci es. We noti ce that ther e i s a breakdown between approxi mati ons
A3 and A4, fr om whi ch the medi um frequency i nfor mati on has been subtr acted.
We shoul d ther efor e use approxi mati ons A1 to A3 to esti mate the peri od of the
medi um si ne. Zoomi ng i n on A1 r eveal s a per i od of around 20.
Now onl y the peri od of the sl ow si ne r emai ns to be deter mi ned. Exami nati on
of appr oxi mati on A4 (see the fi gur e on the previ ous page) shows the di stance
between two successi ve maxi mums to be 200.
3 Wavelet Applications
3-14
Thi s sl ow si ne sti l l i s vi si bl e i n approxi mati on A5, but wer e we to extend thi s
anal ysi s to further l evel s, we woul d fi nd that i t di sappears fr om the
appr oxi mati on and move i nto the detai l s at l evel 8.
I n summati on, we have used wavel et anal ysi s to deter mi ne the frequenci es of
pur e si nusoi dal si gnal components. We were abl e to do thi s because the
di fferent fr equenci es predomi nate at a di ffer ent scal es, and each scal e i s taken
account of by our anal ysi s.
Signal Component Found in Period Frequency
Sl ow si ne Appr oxi mati on A4 200 0.005
Medi um si ne Detai l D4 20 0.05
Rapi d si ne Detai l D1 2 0.5
Suppressing Signals
3-15
Suppressing Signals
The purpose of thi s exampl e i s to i l l ustr ate the pr operty that causes the
decomposi ti on of a pol ynomi al to produce nul l detai l s, pr ovi ded the number of
vani shi ng moments of the wavel et (N for a Daubechi es wavel et dbN) exceeds
the degr ee of the pol ynomi al . The si gnal her e i s a second-degr ee pol ynomi al
combi ned wi th a smal l amount of whi te noi se.
Note that onl y the noi se comes through i n the detai l s. The peak-to-peak
magni tude of the detai l s i s about 2, whi l e the ampl i tude of the pol ynomi al
si gnal i s on the order of 10
5
.
The db3 wavel et, whi ch has thr ee vani shi ng moments, was used for thi s
anal ysi s. Note that a wavel et of the Daubechi es fami l y wi th fewer vani shi ng
moments woul d fai l to suppr ess the pol ynomi al si gnal . For mor e i nformati on,
see that secti on, Daubechi es Wavel ets: dbN on page 6-63.
Demo Analysis:
Noisy polynomial
MAT-file:
noi s pol . mat
Wavelet:
db3
Level:
4
3 Wavelet Applications
3-16
Here i s what the fi r st three detai l s l ook l i ke when we perfor m the same
anal ysi s wi th db2.
The peak-to-peak magni tudes of the detai l s D1, D2, and D3 ar e 2, 10, and 40,
r especti vel y. These are much hi gher detai l magni tudes than those obtai ned
usi ng db3.
Discussion
For the db2 anal ysi s, the detai l s for l evel s 2 to 4 show a per i odi c for m that i s
ver y regul ar , and that i ncreases wi th the l evel . Thi s i s expl ai ned by the fact
that the detai l for l evel j takes i nto account pri mari l y the fl uctuati ons of the
pol ynomi al functi on ar ound i ts mean val ue on dyadi c i nterval s that ar e 2
j
l ong.
The fl uctuati ons ar e peri odi c and ver y l ar ge i n rel ati on to the detai l s of the
noi se decomposi ti on.
On the other hand, for the db3 anal ysi s, we fi nd the presence of whi te noi se
thus i ndi cati ng that the pol ynomi al does not come i nto pl ay i n any of the
detai l s. The wavel et suppresses the pol ynomi al part and anal yzes the noi se.
Suppressi ng par t of a si gnal al l ows us to hi ghl i ght the remai nder.
Suppressing Signals
3-17
Vanishing Moments
The abi l i ty of a wavel et to suppress a pol ynomi al depends on a cr uci al
mathemati cal char acteri sti c of the wavel et cal l ed i ts number of vanishing
moments. A techni cal di scussi on of vani shi ng moments appears i n Chapter 6,
Advanced Concepts. For the present di scussi on, i t suffi ces to thi nk of
moment as an extensi on of aver age. I f a wavel ets average val ue i s zero,
then i t has (at l east) one vani shi ng moment.
Mor e pr eci sel y, i f the average val ue of i s zero (where i s the wavel et
functi on), for then the wavel et has vani shi ng moments and
pol ynomi al s of degree n are suppr essed by thi s wavel et.
x
k
x ( ) x ( )
k 0 n, , , = n 1 +
3 Wavelet Applications
3-18
De-Noising Signals
The purpose of thi s exampl e i s to show how to de-noi se a si gnal usi ng wavel et
anal ysi s. Thi s exampl e al so gi ves us an opportuni ty to demonstrate the
automati c threshol di ng feature of the Wavelet 1-D gr aphi cal i nter face tool .
The si gnal to be anal yzed i s a Doppl er -shi fted si nusoi d wi th some added noi se.
Discussion
We note that the hi ghest fr equenci es appear at the start of the or i gi nal si gnal .
The successi ve approxi mati ons appear l ess and l ess noi sy; however , they al so
l ose progr essi vel y mor e hi gh-fr equency i nfor mati on. I n approxi mati on A5, for
exampl e, about the fi rst 20% of the si gnal i s truncated.
Demo Analysis:
Noisy Doppler
MAT-file:
noi s dopp. mat
Wavelet:
s y m4
Level:
5
De-Noising Signals
3-19
Cl i ck the De-noise button to bri ng up the Wavelet 1-D De-noising wi ndow.
Thi s wi ndow shows each detai l al ong wi th i ts automati cal l y set de-noi si ng
threshol d.
Press the De-noise button. On the screen, the ori gi nal and de-noi sed si gnal s
appear super i mposed i n r ed and yel l ow, r especti vel y. I n thi s fi gur e, the
de-noi sed si gnal i s shown i n bl ue for better contrast.
3 Wavelet Applications
3-20
Note that the de-noi sed si gnal i s fl at i ni ti al l y. Some of the hi ghest-frequency
si gnal i nformati on was l ost duri ng the de-noi si ng pr ocess, though l ess was l ost
her e than i n the hi gher -l evel approxi mati ons A4 and A5.
For thi s si gnal , wavel et packet anal ysi s does a better job of r emovi ng the noi se
wi thout compromi si ng the hi gh-frequency i nformati on. Expl ore on your own:
tr y repeati ng thi s anal ysi s usi ng the Wavelet Packet 1-D tool . Sel ect the
menu i tem FileDemo Analysisnoisdopp.
Compressing Signals
3-21
Compressing Signals
The purpose of thi s exampl e i s to show how to compress an i mage usi ng
two-di mensi onal wavel et anal ysi s. Compr essi on i s one of the most i mportant
appl i cati ons of wavel ets. The i mage to be compressed i s a fi nger pri nt.
For thi s exampl e, open the Wavelet 2-D tool and sel ect the menu i tem
FileDemo Analysisat level 3, with haar > finger.
The anal ysi s appears i n the Wavelet 2-D tool . Cl i ck the Compress button
(l ocated at the mi ddl e r i ght) to br i ng up the Wavelet 2-D Compression
wi ndow.
Demo Analysis:
finger
MAT-file:
de t f i ngr . mat
Wavelet:
haar
Level:
3
3 Wavelet Applications
3-22
Discussion
The gr aphi cal tool pr ovi des an automati cal l y-gener ated thr eshol d, whi ch for
thi s exampl e i s 3.5. Val ues under the thr eshol d ar e forced to zer o, achi evi ng
about 42% zeros whi l e r etai ni ng al most al l (99.95%) the ener gy of the or i gi nal
i mage.
The automati c threshol d usual l y achi eves a r easonabl e bal ance between
number of zeros and retai ned i mage ener gy. Dependi ng on your data and your
anal ysi s cr i teri a, you may fi nd setti ng more aggressi ve threshol ds achi eves
better r esul ts.
Here weve set the i ndi vi dual threshol ds to ar ound 30. Thi s resul ts i n a
compr essed i mage consi sti ng of 91.8% zer os wi th 97.7% r etai ned ener gy.

4
Wavel ets i n Acti on:
Exampl es and Case Studi es
4-3 Illustrated Examples
4-6 Advi ce to the Reader
4-8 Exampl e #1: A Sum of Si nes
4-10 Exampl e #2: A Frequency Br eakdown
4-12 Exampl e #3: Uni for m Whi te Noi se
4-14 Exampl e #4: Col ored AR(3) Noi se
4-16 Exampl e #5: Pol ynomi al + Whi te Noi se
4-18 Exampl e #6: A Step Si gnal
4-20 Exampl e #7: Two Pr oxi mal Di sconti nui ti es
4-22 Exampl e #8: A Second-Deri vati ve Di sconti nui ty
4-24 Exampl e #9: A Ramp + Whi te Noi se
4-26 Exampl e #10: A Ramp + Col or ed Noi se
4-28 Exampl e #11: A Si ne + Whi te Noi se
4-30 Exampl e #12: A Tri angl e + A Si ne
4-32 Exampl e #13: A Tri angl e + A Si ne + Noi se
4-34 Exampl e #14: A Real El ectr i ci ty Consumpti on Si gnal
4-36 A Case Study: An Electrical Signal
4-36 Data and the External I nformati on
4-38 Anal ysi s of the Mi dday Per i od
4-39 Anal ysi s of the End of the Ni ght Peri od
4-42 Suggesti ons for Further Anal ysi s
4-48 Fast Multiplication of Large Matrices
4 Waveletsi n Acti on: Examples and C ase Studi es
4-2
Thi s chapter pr esents the di fferent possi bi l i ti es offered by wavel et
decomposi ti on i n the for m of exampl es you can work wi th on your own.
Suggested ar eas for further expl orati on fol l ow most exampl es, al ong wi th a
summar y of the topi cs addr essed by that exampl e.
Thi s chapter al so i ncl udes a case study that exami nes the practi cal uses of
wavel et anal ysi s i n even greater detai l , as wel l as a demonstrati on of the
appl i cati on of wavel ets for fast mul ti pl i cati on of l ar ge matr i ces.
An extended di scussi on of many of the topi cs addr essed by the exampl es can be
found i n Chapter 6, Advanced Concepts.
Illustrated Examples
4-3
Illustrated Examples
Fourteen i l l ustr ated exampl es ar e i ncl uded i n thi s secti on, or gani zed as shown:
Figure Page Description of the Signal Signal
Name
MAT-file
Fi gure
4-1:
page 4-9 A sum of si nes: s
1
(t) s ums i n
Fi gure
4-2:
page 4-11 A frequency br eakdown: s
2
(t) f r eqbr k
Fi gure
4-3:
page 4-12 A uni for m whi te noi se:
on the i nterval
b
1
(t) whi t noi s
Fi gure
4-4:
page 4-14 A col ored AR(3) noi se b
2
(t) war ma
Fi gure
4-5:
page 4-17 A pol ynomi al + a whi te noi se:
on the i nterval
s
3
(t) noi s pol
Fi gure
4-6:
page 4-19 A step si gnal : s
4
(t) ws t e p
s
1
t ( ) 3t ( ) sin 0.3t ( ) sin 0.03t ( ) sin + + =
1 t 500,
501 t 1000,
s
2
t ( ) 0.03t ( ) sin =
s
2
t ( ) 0.3t ( ) sin =
0.5 0.5 [ ]
b
2
t ( ) 1.5b
2
t 1 ( ) 0.75b
2
t 2 ( ) =
0.125b
2
t 3 ( ) b
1
t ( ) 0.5 + +
1 1000 [ ]
s
3
t ( ) t
2
t 1 b
1
t ( ) + + =
1 t 500,
501 t 1000,
s
4
t ( ) 0 =
s
4
t ( ) 20 =
4 Waveletsi n Acti on: Examples and C ase Studi es
4-4
Fi gur e
4-7:
page 4-21 Two proxi mal di sconti nui ti es: s
5
(t) near br k
Fi gur e
4-8:
page 4-23 A second-der i vati ve di sconti nui ty:
s
6
i s f
3
sampl ed at 10
-3
s
6
(t) s cddv br k
Fi gur e
4-9:
page 4-25 A ramp + a whi te noi se: s
7
(t) wnoi s l op
Fi gur e
4-10:
page 4-28 A ramp + a col ored noi se: s
8
(t) c noi s l op
Fi gur e
4-11:
page 4-30 A si ne + a whi te noi se: s
9
(t) noi s s i n
Fi gur e
4-12:
page 4-21 A tr i angl e + a si ne: s
10
(t) t r s i n
Figure Page Description of the Signal Signal
Name
MAT-file
1 t 499,
500 t 510,
511 t,
s
5
t ( ) 3t =
s
5
t ( ) 1500 =
s
5
t ( ) 3t 30 =
t 0.5 0.5 [ ] R;
t 0, f
3
t ( ) < 4t
2
( ) exp =
t 0, f
3
t ( ) t
2
( ) exp =
1 t 499,
500 t 1000,
s
7
t ( )
3t
500
-------- - b
1
t ( ) + =
s
7
t ( ) 3 b
1
t ( ) + =
1 t 499,
500 t 1000,
s
8
t ( )
t
500
-------- - b
2
t ( ) + =
s
8
t ( ) 1 b
2
t ( ) + =
s
9
t ( ) 0.03t ( ) sin b
1
t ( ) + =
1 t 500,
501 t 1000,
s
10
t ( )
t 1
500
---------- 0.3t ( ) sin + =
s
10
t ( )
1000 t
500
------------------- 0.3t ( ) sin + =
Illustrated Examples
4-5
Pl ease note that:
Al l the decomposi ti ons use Daubechi es wavel ets.
The exampl es show the si gnal , the appr oxi mati ons, and the detai l s.
The exampl es i ncl ude speci fi c comments and featur e di sti nct domai ns for
i nstance i f the l evel of decomposi ti on i s 5:
The l eft col umn contai ns the si gnal and the appr oxi mati ons A
5
to A
1
.
The r i ght col umn contai ns the si gnal and the detai l s D
5
to D
1
.
The approxi mati on A
1
i s l ocated under A
2
, A
2
under A
3
and so on. The same
i s true for the detai l s.
The absci ssa axi s r epr esents the ti me. The uni t for the ordi nate axi s for
appr oxi mati ons and detai l s i s the same as that of the si gnal .
When the approxi mati ons do not pr ovi de enough i nformati on, they are
r epl aced by detai l s obtai ned by changi ng wavel ets.
The exampl es i ncl ude questi ons for you to thi nk about:
- What can be seen on the fi gur e?
- What addi ti onal questi ons can be studi ed?
Fi gure
4-13:
page 4-34 A tri angl e + a si ne + a noi se: s
11
(t) wnt r s i n
Fi gure
4-14:
page 4-36 A real el ectr i ci ty consumpti on si gnal l e l e cc um
Figure Page Description of the Signal Signal
Name
MAT-file
501 t 1000,
s
11
t ( )
1000 t
500
------------------- 0.3t ( ) sin b
1
t ( ) + + =
1 t 500, s
11
t ( )
t 1
500
---------- 0.3t ( ) sin b
1
t ( + + =
4 Waveletsi n Acti on: Examples and C ase Studi es
4-6
Advice to the Reader
You shoul d fol l ow al ong and process these exampl es on your own, usi ng ei ther
the graphi cal i nterface or the command l i ne functi ons.
Use the graphical interface for i mmedi ate si gnal pr ocessi ng. To execute the
anal yses i ncl uded i n the fi gur es:
1 To bri ng up the Wavelet Toolbox Main Menu type:
wave me nu
2 Sel ect the Wavelet 1-D menu opti on to open the Wavelet 1-D tool .
3 Fr om the Wavelet 1-D tool , choose the File_Demo Analysis menu opti on.
4 Fr om the di al og box, sel ect the sampl e anal ysi s i n questi on.
Thi s tri ggers the executi on of the exampl es.
Illustrated Examples
4-7
When using the command line, fol l ow the process i l l ustr ated i n thi s M-fi l e to
conduct cal cul ati ons:
% Load or i gi nal 1- D s i gnal .
l oad s ums i n; s = s ums i n;
% Per f or m t he de compos i t i on of s at l e ve l 5, us i ng coi f 3.
w = ' coi f 3'
[ c, l ] = wave de c( s , 5, w) ;
% Rec ons t r uc t t he appr oxi mat i on s i gnal s and de t ai l s i gnal s at
% l e v el s 1 t o 5, us i ng t he wave l e t de c ompos i t i on s t r uct ur e [ c , l ] .
f or i = 1: 5
e val ( [ ' a( ' , i nt 2s t r ( i ) , ' , : ) = wr c oe f ( ' ' a' ' , c , l , w, i ) ; ' ] ) ;
e val ( [ ' d( ' , i nt 2s t r ( i ) , ' , : ) = wr c oe f ( ' ' d' ' , c , l , w, i ) ; ' ] ) ;
e nd
Note: Thi s l oop repl aces 10 separate wr coe f statements defi ni ng vari abl es a1
through a5, and d1 thr ough d5.
% Pl ot s .
t = 100: 900;
s ubpl ot ( 621) ; pl ot ( t , s ( t ) , r ) ;
t i t l e ( Or i g. s i gnal and appr ox. 1 t o 5. ) ;
s ubpl ot ( 622) ; pl ot ( t , s ( t ) , r ) ;
t i t l e ( Or i g. s i gnal and det ai l s 1 t o 5. ) ;
f or i = 1: 5,
s ubpl ot ( 6, 2, 2*i +1) ; pl ot ( t , a( i , t ) , b ) ;
s ubpl ot ( 6, 2, 2*i +2) ; pl ot ( t , d( i , t ) , g ) ;
e nd
About Further Exploration
Tip 1: On al l fi gur es, vi sual l y check that for j = 0, 1, ..., A
j
= A
j+1
+ D
j+1
.
Tip 2: Dont forget to change wavel ets. Test the shortest ones fi r st.
4 Waveletsi n Acti on: Examples and C ase Studi es
4-8
Tip 3: I denti fy edge effects. They wi l l create probl ems for a corr ect anal ysi s. At
pr esent, there i s no easy way to avoi d them per fectl y. You can use tool s
descri bed i n the secti on Deal i ng wi th Bor der Di stor ti on on page 6-46 and see
al so the dwt mode functi on i n Chapter 8, Refer ence . They shoul d el i mi nate or
gr eatl y r educe these effects.
Tip 4: As much as possi bl e, conduct cal cul ati ons manual l y to cr oss-check
r esul ts wi th the val ues i n the gr aphi c repr esentati ons. Manual cal cul ati ons are
possi bl e wi th the db1 wavel et.
For the sake of si mpl i ci ty i n the fol l owi ng exampl es, we use onl y the haar and
db fami l y wavel ets, whi ch are the most frequentl y used wavel ets.
Example #1: A Sum of Sines
Anal yzi ng wavel et: db3
Decomposi ti on l evel s: 5
The si gnal i s composed of the sum of three si nes: sl ow, medi um and r api d
wi th regard to the sampl i ng per i od equal to 1, the peri ods ar e appr oxi matel y
200, 20 and 2 r especti vel y. We shoul d therefore see thi s l ater peri od i n D
1
, the
medi um si ne i n D
4
, and the sl ow si ne i n A
4
. The sl i ght di ffer ences that can be
obser ved on the decomposi ti ons can be attri buted to the sampl i ng per i od. The
scal e of the approxi mati on char ts i s 2, 4 or 10 ti mes l arger than that of the
detai l s. D
1
contai ns pr i mar i l y the components whose peri od i s si tuated
between 1 and 2 (i .e., the rapi d si ne), but thi s peri od i s not vi si bl e at the scal e
whi ch i s used for the graph. Zoomi ng i n on D
1
reveal s that each bel l y i s
composed of 10 osci l l ati ons, and can be used to esti mate the peri od. We fi nd
that the per i od i s cl ose to 2. D
2
i s very smal l . Thi s i s al so seen i n the
appr oxi mati ons: the fi r st two resembl e one another , si nce
The detai l D
3
, and to an even gr eat extent D
4
, contai n the medi um si ne. We
noti ce that there i s a br eakdown between approxi mati ons 3 and 4.
Approxi mati ons A
1
to A
3
can be used to esti mate the peri od of the medi um si ne.
Now, onl y the sl ow si ne, whi ch appear s i n A
4
remai ns to be determi ned. The
di stance between two successi ve maxi mums i s equal to 200, whi ch i s the per i od
of the sl ow si ne. Thi s l atter si ne i s sti l l vi si bl e i n A
5
, but wi l l di sappear from the
appr oxi mati on and move i nto the detai l s at l evel 8.
A
1
A
2
D
2
+ =
Illustrated Examples
4-9
Figure 4-1: A Sum of Sines
Example #1: A Sum of Sines
Addr essed topi cs Detecti ng br eakdown poi nts
Detecti ng l ong-term evol uti on
I denti fyi ng pur e frequenci es
The effect of a wavel et on a si ne
Detai l s and appr oxi mati ons: a si gnal moves from
an approxi mati on to a detai l
The l evel at whi ch characteri sti cs appear
Further expl orati on Compare wi th a Four i er anal ysi s
Change the fr equenci es. Anal yze other l i near
combi nati ons.
1
0
1
a5
1
0
1
a4
2
0
2
a3
2
0
2
a2
200 400 600 800 1000
1
0
1
a1
0.1
0
0.1
d5
1
0
1
d4
0.5
0
0.5
d3
0.1
0
0.1
d2
200 400 600 800 1000
1
0
1
d1
2
0
2
s
Signal and Approximations
2
0
2
s
Signal and Details
4 Waveletsi n Acti on: Examples and C ase Studi es
4-10
Example #2: A Frequency Breakdown
Anal yzi ng wavel et: db5
Decomposi ti on l evel s: 5
The si gnal i s formed of a sl ow si ne and a medi um si ne, on ei ther si de of 500.
These two si nes are not connected i n a conti nuous manner : D
1
and D
2
can be
used to detect thi s di sconti nui ty. I t i s l ocal i zed very preci sel y: onl y a smal l
domai n around 500 contai ns l arge detai l s. Thi s i s because the ruptur e contai ns
the hi gh fr equency part; the frequenci es i n the r est of the si gnal ar e not as hi gh.
I t shoul d be noted that i f we are i nter ested onl y i n i denti fyi ng the
di sconti nui ty, db1 i s mor e useful than db5.
D
3
and D
4
contai n the medi um si ne as i n the pr evi ous anal ysi s. The sl ow
si ne appears cl ear l y al one i n A
5
. I t i s more regul ar than i n the s
1
anal ysi s, si nce
db5 i s mor e r egul ar than db3. I f the same si gnal had been anal yzed by the
Four i er transform, we woul d not have been abl e to detect the i nstant
cor respondi ng to the si gnal s frequency change, wher eas i t i s cl ear l y observabl e
her e.
Illustrated Examples
4-11
Figure 4-2: A Frequency Breakdown
Example #2: A Frequency Breakdown
Addr essed topi cs Suppr essi ng si gnal s
Detecti ng l ong-term evol uti on
Further expl orati on Compare to the si gnal s
1
On a l onger si gnal , have the sl ow si nusoi d moved
i nto the detai l s
Compare wi th a Four i er anal ysi s
Compare wi th a wi ndowed Four i er anal ysi s
0.5
0
0.5
1
a5
0.5
0
0.5
1
a4
1
0
1
a3
1
0
1
a2
200 400 600 800 1000
1
0
1
a1
0.2
0
0.2
d5
1
0
1
d4
0.4
0.2
0
0.2
0.4
d3
0.1
0
0.1
0.2
d2
200 400 600 800 1000
0.2
0
0.2
0.4
d1
0.5
0
0.5
s
Signal and Approximations
0.5
0
0.5
s
Signal and Details
4 Waveletsi n Acti on: Examples and C ase Studi es
4-12
Example #3: Uniform White Noise
Anal yzi ng wavel et: db3
Decomposi ti on l evel s: 5
At al l l evel s we encounter noi se-type si gnal s, whi ch are cl earl y i r regul ar . Thi s
i s due to the fact that al l the fr equenci es carr y the same ener gy. The var i ances
however, decrease regul ar l y between one l evel and the next as can be seen
r eadi ng the detai l char t (on the r i ght) and the appr oxi mati ons (on the l eft).
The var i ance decreases two-fol d between one l evel and the next, i .e.
vari ance(D
j
) = var i ance(D
j - 1
)/2. Lastl y, i t shoul d be noted that the detai l s and
appr oxi mati ons are not whi te noi ses, and that these si gnal s ar e i ncr easi ngl y
i nterdependent as the r esol uti on decr eases. On the other hand, the wavel et
coeffi ci ents ar e r andom, non-cor rel ated var i abl es. Thi s property i s not evi dent
on the r econstructed si gnal s shown her e, but i t can be guessed at fr om the
r epr esentati on of the coeffi ci ents.
Figure 4-3: Uniform White Noise
0.1
0
0.1
a5
0.2
0.1
0
0.1
a4
0.2
0
0.2
a3
0.2
0
0.2
a2
200 400 600 800 1000
0.5
0
0.5
a1
0.1
0
0.1
d5
0.2
0
0.2
d4
0.2
0
0.2
d3
0.4
0.2
0
0.2
0.4
d2
200 400 600 800 1000
0.5
0
0.5
d1
0.4
0.2
0
0.2
0.4
s
Signal and Approximations
0.4
0.2
0
0.2
0.4
s
Signal and Details
Illustrated Examples
4-13
Example #3: Uniform White Noise
Addr essed topi cs Pr ocessi ng noi se
The shapes of the decomposi ti on val ues
The evol uti on of these shapes accordi ng to l evel :
the cor rel ati on i ncr eases, the vari ance decr eases
Compare the fr equenci es i ncl uded i n the detai l s
wi th those i n the approxi mati ons
Further expl orati on Study the val ues of the coeffi ci ents and thei r
di str i buti on
On the conti nuous anal ysi s, i denti fy the chaoti c
aspect of the col ors
Repl ace the uni for m whi te noi se by a Gaussi an
whi te noi se or other noi se.
4 Waveletsi n Acti on: Examples and C ase Studi es
4-14
Example #4: Colored AR(3) Noise
Anal yzi ng wavel et: db3
Decomposi ti on l evel s: 5
Note: AR(3) means AutoRegr essi ve model of or der 3.
Thi s fi gur e can be exami ned i n vi ew of the pr evi ous fi gure, si nce we are
confronted her e wi th a non-whi te noi se whose spectr um i s mai nl y at the hi gher
frequenci es. I t i s ther efor e found pr i mari l y i n D
1
, whi ch contai ns the major
porti on of the si gnal . I n thi s si tuati on, whi ch i s commonl y encountered i n
pr acti ce, the effects of the noi se on the anal ysi s decrease consi derabl y more
r api dl y than i n the case of whi te noi se. I n A
3
, A
4
and A
5
, we encounter the same
scheme as that i n the anal ysi s of (see the tabl e on page 4-3), the noi se from
whi ch i s bui l t usi ng l i near fi l teri ng.
Figure 4-4: Colored AR(3) Noise
b
1
b
2
0.12
0.14
0.16
0.18
a5
0.1
0.15
0.2
a4
0.05
0.1
0.15
0.2
a3
0
0.1
0.2
0.3
a2
200 400 600 800 1000
0
0.2
0.4
a1
0.04
0.02
0
0.02
0.04
d5
0.05
0
0.05
0.1
d4
0.1
0
0.1
0.2
d3
0.2
0
0.2
d2
200 400 600 800 1000
2
0
2
d1
2
0
2
s
Signal and Approximations
2
0
2
s
Signal and Details
Illustrated Examples
4-15
Example #4: Colored AR(3) Noise
Addr essed topi cs Pr ocessi ng noi se
The r el ati ve i mportance of di fferent detai l s
The comparati ve i mpor tance of D
1
and A
1
.
Compare the detai l fr equenci es wi th those i n the
approxi mati ons.
Further expl orati on Compare appr oxi mati ons A
3
, A
4
, and A
5
wi th those
shown i n Fi gur e 4-3.
Repl ace AR(3) wi th an ARMA (AutoRegressi ve
Movi ng Average) model noi se. For i nstance:
Study an ARI MA (I ntegr ated ARMA) model noi se.
For i nstance:
Check that each detai l can be model ed by an
ARMA process.
b
3
t ( ) 1.5 b
3
t 1 ( ) 0.75b
3
t 2 ( ) 0.125b
3
t 3 ( ) =
+ b
1
t ( ) 0.7b
1
t 1 ( )
b
4
t ( ) b
4
t 1 ( ) b
3
t ( ) + =
4 Waveletsi n Acti on: Examples and C ase Studi es
4-16
Example #5: Polynomial + White Noise
Anal yzi ng wavel ets: db2 and db3
Decomposi ti on l evel s: 4
The pur pose of thi s anal ysi s i s to i l l ustr ate the pr oper ty whi ch causes the
decomposi ti on by dbN of a p-degr ee pol ynomi al to produce nul l detai l s as l ong
as N > p. I n thi s case, p=2 and we exami ne the fi rst four l evel s of detai l s for two
val ues of N: one i s too smal l , N=2 on the l eft, and the other i s suffi ci ent, N=3 on
the r i ght. The appr oxi mati ons ar e l eft out si nce they di ffer very l i ttl e from the
si gnal i tsel f.
For db2 (on the l eft), we obtai n the decomposi ti on of t
2
+b
1
(t), si nce the -t + 1
par t of the si gnal i s suppr essed by the wavel et. I n fact, wi th the excepti on of
l evel 1, where noi se-generated i rr egul ar i ti es can be seen, the detai l s for l evel s
2 to 4 show a per i odi c for m that i s ver y regul ar , and whi ch i ncr eases wi th the
l evel . Thi s i s expl ai ned by the fact that the detai l for l evel j takes i nto account
pr i mari l y the fl uctuati ons of the functi on around i ts mean val ue on dyadi c
i nterval s that are l ong. The fl uctuati ons ar e per i odi c and ver y l ar ge i n r el ati on
to the detai l s of the noi se decomposi ti on.
On the other hand, for db3 (on the ri ght) we agai n fi nd the pr esence of whi te
noi se thus i ndi cati ng that the pol ynomi al does not come i nto pl ay i n any of the
detai l s. The wavel et suppresses the pol ynomi al part and anal yzes the noi se.
Illustrated Examples
4-17
Figure 4-5: Polynomial + White Noise
Example #5: Polynomial + White Noise
Addr essed topi cs Suppr essi ng si gnal s
Compare the resul ts of the pr ocessi ng for the
fol l owi ng wavel ets: the shor t db2 and the l onger
db3.
Expl ai n the regul ar i ty that i s vi si bl e i n D
3
and D
4

i n the anal ysi s by db2.
0.5
0
0.5
d4
0.5
0
0.5
d3
300 400 500 600 700
1
0
1
d1
2
4
6
8
x 10
5
s
Signal and Details with db3
50
0
50
d4
20
0
20
d3
5
0
5
d2
300 400 500 600 700
2
1
0
1
d1
0.5
0
0.5
1
d2
2
4
6
8
x 10
5
s
Signal and Details with db2
4 Waveletsi n Acti on: Examples and C ase Studi es
4-18
Example #6: A Step Signal
Anal yzi ng wavel et: db2
Decomposi ti on l evel s: 5
I n thi s case we are faced wi th the si mpl est exampl e of a ruptur e (i .e., a step).
The ti me i nstant when the jump occur s i s equal to 500. The break i s detected
at al l l evel s, but i t i s obvi ousl y detected wi th greater pr eci si on i n the hi gher
r esol uti ons (l evel s 1 and 2) than i n the l ower ones (l evel s 4 and 5). I t i s very
pr eci sel y l ocal i zed at l evel 1, wher e onl y a ver y smal l zone around the jump
ti me can be seen.
I t shoul d be noted that the r econstructed detai l s ar e pri mari l y composed of the
basi c wavel et r epresented i n the i ni ti al ti me.
What i s mor e, the ruptur e i s al l the more preci sel y l ocal i zed when the wavel et
cor responds to a shor t fi l ter.
Illustrated Examples
4-19
Figure 4-6: A Step Signal
Example #6: A Step Signal
Addr essed topi cs Detecti ng br eakdown poi nts
Suppr essi ng si gnal s
Detecti ng l ong-term evol uti on
I denti fy the r ange wi dth of the vari ati ons of detai l s
and approxi mati ons.
Further expl orati on Use the coeffi ci ents of the FI R fi l ter associ ated
wi th the wavel et to check the val ues of D
1
Repl ace the step by an i mpul se
Add noi se to the si gnal and repeat the anal ysi s
0
10
20
a5
0
10
20
a4
0
10
20
a3
0
10
20
a2
10
5
0
5
d5
4
2
0
2
4
6
d4
2
0
2
d3
5
0
5
d2
200 400 600 800
2
0
2
4
d1
0
10
20
s
Signal and Approximations
0
10
20
s
Signal and Details
200 400 600 800
0
10
20
a1
4 Waveletsi n Acti on: Examples and C ase Studi es
4-20
Example #7: Two Proximal Discontinuities
Anal yzi ng wavel et: db2 and db7
Decomposi ti on l evel s: 5
The si gnal i s for med of two str ai ght l i nes wi th i denti cal sl opes, extendi ng
across a ver y shor t pl ateau. On the i ni ti al si gnal , the pl ateau i s i n fact bar el y
vi si bl e to the naked eye. Two anal yses ar e thus carri ed out, one on a wel l
l ocal i zed wavel et wi th the shor t fi l ter (db2) on the l eft and the other on a
wavel et havi ng a l onger fi l ter (db7) on the ri ght. I n both anal yses, the pl ateau
i s detected cl ear l y; wi th the excepti on of a fai r l y l i mi ted domai n, D
1
i s equal to
zero. The r egul ar i ty of the si gnal i n the pl ateau however i s cl ear l y
di sti ngui shed for db2 (for whi ch pl ateau begi nni ng and end ti me ar e
di sti ngui shed), wher eas for db7 both di sconti nui ti es ar e fused and onl y the
enti re pl ateau can sai d to be vi si bl e. Thi s exampl e suggests that the sel ected
wavel ets shoul d be associ ated wi th shor t fi l ters to di sti ngui sh proxi mal
di sconti nui ti es of the fi rst der i vati ve. A l ook at the other detai l l evel s agai n
shows the l ack of pr eci si on when detecti ng at l ow resol uti ons. The wavel et
fi l ter s the str ai ght l i ne and anal yzes the di sconti nui ti es.
Illustrated Examples
4-21
Figure 4-7: Two Proximal Discontinuities
Example #7: Two Proximal Discontinuities
Addr essed topi cs Detecti ng br eakdown poi nts
Move the di sconti nui ti es cl oser together and
further apar t
Further expl orati on Add noi se to the si gnal unti l the ruptur e i s no
l onger vi si bl e
Tr y usi ng other wavel ets, haar for i nstance.
2
0
2
d5
10
0
10
d5
2
0
2
4
d4
2
0
2
4
6
d4
4
2
0
2
4
d3
1
0
1
d3
1
0
1
2
d2
0.5
0
0.5
d2
450 500 550 600
0.5
0
0.5
d1
450 500 550 600
0.2
0
0.2
d1
1300
1400
1500
1600
1700
s
Signal and Details with db2
1300
1400
1500
1600
1700
s
Signal and Details with db7
4 Waveletsi n Acti on: Examples and C ase Studi es
4-22
Example #8: A Second-Derivative Discontinuity
Anal yzi ng wavel et: db1 and db4
Decomposi ti on l evel s: 2
Thi s fi gure shows that the r egul ari ty can be an i mportant cr i teri on i n sel ecti ng
a wavel et. The basi c functi on i s composed of two exponenti al s that ar e
connected at 0, and the anal yzed si gnal i s the sampl i ng of the conti nuous
functi on wi th i ncr ements of 10
3
. The sampl ed si gnal i s anal yzed usi ng two
di fferent wavel ets: Haar whi ch i s i nsuffi ci entl y r egul ar, on the l eft, and db4
whi ch i s suffi ci entl y r egul ar, on the r i ght.
On the l eft we noti ce that the si ngul ar i ty has not been detected i n the extent
that the detai l s ar e equal to 0 at 0. The bl ack areas cor respond to very r api d
osci l l ati ons of the detai l s. These val ues are equal to the di ffer ence between the
functi on and an approxi mati on usi ng a constant functi on. Cl ose to 0, the sl ow
decr ease of the detai l s absol ute val ues fol l owed by a sl ow i ncrease i s due to the
fact that the functi on der i vati ve i s zer o and conti nuous at 0. The val ue of the
detai l s i s ver y smal l (cl ose to 10
3
for Haar and 10
4
for db4) si nce the si gnal i s
ver y smooth and does not contai n any hi gh fr equency. Thi s val ue i s even
smal l er for db4, si nce the wavel et i s mor e r egul ar than db1.
However wi th db4 (on the r i ght), the di sconti nui ty i s wel l detected: the detai l s
ar e hi gh onl y cl ose to 0 and are 0 ever ywhere el se. Thi s i s the onl y el ement that
can be der i ved fr om the anal ysi s. I n thi s case, as a concl usi on, we noti ce that
the sel ected wavel et must be suffi ci entl y r egul ar, whi ch thus i mpl i es a l onger
fi l ter i mpul se response i n or der to detect the si ngul ari ty.
Illustrated Examples
4-23
Figure 4-8: A Second-Derivative Discontinuity
Example #8: A Second-Derivative Discontinuity
Addr essed topi cs Detecti ng br eakdown poi nts
Suppr essi ng si gnal s
I denti fyi ng a di ffi cul t di sconti nui ty
Careful l y sel ecti ng a wavel et i n or der to reveal
an effect
Further expl orati on Cal cul ate the detai l val ues for the Haar wavel et
Bewar e of par asi ti c effects: r api d detai l
fl uctuati ons may be arti facts
Add noi se to the si gnal unti l the ruptur e i s no
l onger vi si bl e
1
0
1
2
x 10
6
d2
5
0
5
x 10
4
d2
0.95
0.96
0.97
0.98
0.99
1
s
Signal and Signals with db2
0.95
0.96
0.97
0.98
0.99
1
1.01
s
Signal and Details with db4
0.1 0.05 0 0.05 0.1
4
2
0
2
4
x 10
4
d1
0.1 0.05 0 0.05 0.1
6
4
2
0
2
4
x 10
7
d1
4 Waveletsi n Acti on: Examples and C ase Studi es
4-24
Example #9: A Ramp + White Noise
Anal yzi ng wavel et: db3
Decomposi ti on l evel s: 6
The si gnal i s bui l t from a trend pl us noi se. The trend i s a sl ow l i near ri se from 0
to 3, up to t=500 and becomi ng constant afterwards. The noi se i s a uni form zero
mean whi te noi se, varyi ng between -0.5 and 0.5 (see the anal yzed si gnal b
1
).
I n the char ts on the ri ght, we agai n fi nd the decomposi ti on of noi se i n the
detai l s. I n the charts on the l eft, the appr oxi mati ons for m i ncr easi ngl y preci se
esti mates of the r amp wi th l ess and l ess noi se. These approxi mati ons ar e qui te
acceptabl e from l evel 3, and the r amp i s wel l r econstructed at l evel 6.
We can ther efor e separate the ramp fr om the noi se. Al though the noi se affects
al l scal es, i ts effect decr eases suffi ci entl y qui ckl y for the l ow-resol uti on
appr oxi mati ons to r estore the ramp. I t shoul d al so be noted that the br eakdown
poi nt of the ramp i s shown wi th good preci si on. Thi s i s due to the fact that the
r amp i s r ecover ed at too l ow a resol uti on.
The uni form noi se i ndi cates that the r amp mi ght be best esti mated usi ng hal f
sums for the hi gher and l ower porti ons of the si gnal . Thi s approach i s not
appl i cabl e for other noi ses.
Illustrated Examples
4-25
Figure 4-9: A Ramp + White Noise
Example #9: A Ramp + White Noise
Addr essed topi cs Detecti ng br eakdown poi nts
Pr ocessi ng noi se
Detecti ng l ong-term evol uti on
Spl i tti ng si gnal components
I denti fyi ng noi ses and appr oxi mati ons
Compare wi th the whi te noi se b
1
(t) shown i n
Fi gur e 4-3.
I denti fy the number of l evel s needed to suppress
the noi se al most enti rel y.
Further expl orati on Change the noi se
1
2
3
a6
1
2
3
a5
1
2
3
a4
1
2
3
a3
0
1
2
3
a2
0.1
0
0.1
d5
0.2
0
0.2
d4
0.2
0
0.2
d3
0.4
0.2
0
0.2
0.4
d2
200 400 600 800
0.5
0
0.5
d1
0
1
2
3
s
Signal and Approximations
0
1
2
3
s
Signal and Details
200 400 600 800
0
1
2
3
a1
0.1
0
0.1
d6
4 Waveletsi n Acti on: Examples and C ase Studi es
4-26
Example #10: A Ramp + Colored Noise
Anal yzi ng wavel et: db3
Decomposi ti on l evel s: 6
The si gnal i s bui l t i n the same manner as the pr evi ous exampl e, usi ng a trend
pl us a noi se. The tr end i s a sl ow l i near i ncrease from 0 to 1, up to t=500. Beyond
thi s ti me, the val ue remai ns constant. The noi se i s a zero mean AR(3) noi se,
varyi ng between -3 and 3 (see the anal ysed si gnal b
2
). The scal e of the noi se i s
i ndeed si x ti mes gr eater than that of the ramp. At fi r st gl ance, the si tuati on
seems a l i ttl e bi t l ess favor abl e than i n the pr evi ous exampl e, i n terms of the
separ ati on between the r amp and the noi se. Thi s i s actual l y a mi sconcepti on,
si nce the two si gnal components are more pr eci sel y separated i n frequency.
The char ts on the r i ght show the detai l decomposi ti on of the col or ed noi se. The
char ts on the l eft show a decomposi ti on that r esembl es the one i n the previ ous
anal ysi s. Starti ng at l evel 3, the cur ves provi de sati sfactory appr oxi mati ons of
the r amp.
Illustrated Examples
4-27
Figure 4-10: A Ramp + Colored Noise
Example #10: A Ramp + Colored Noise
Addr essed topi cs Detecti ng br eakdown poi nts
Pr ocessi ng noi se
Detecti ng l ong-term evol uti on
Spl i tti ng si gnal components
Compare wi th the s
7
(t) si gnal shown i n Fi gure 4-9.
I denti fy the number of l evel s needed to suppress
the noi se al most enti rel y
Further expl orati on I denti fy the noi se char acter i sti cs. Use the
coeffi ci ents and the command l i ne mode.
0.4
0.6
0.8
1
1.2
a6
0.5
1
a5
0.5
1
a4
0.2
0.4
0.6
0.8
1
1.2
a3
0.2
0.4
0.6
0.8
1
1.2
a2
0.04
0.02
0
0.02
0.04
d5
0.05
0
0.05
0.1
d4
0.1
0
0.1
0.2
d3
0.2
0
0.2
d2
200 400 600 800
2
0
2
d1
1
0
1
2
3
s
Signal and Approximations
1
0
1
2
3
s
Signal and Details
200 400 600 800
0
0.5
1
a1
0.04
0.02
0
0.02
0.04
d6
4 Waveletsi n Acti on: Examples and C ase Studi es
4-28
Example #11: A Sine + White Noise
Anal yzi ng wavel et: db5
Decomposi ti on l evel s: 5
The si gnal i s for med of the sum of two pr evi ousl y anal yzed si gnal s: the sl ow
si ne wi th a per i od cl ose to 200 and the uni form whi te noi se b
1
. Thi s exampl e i s
an i l l ustr ati on of the l i near property of decomposi ti ons: the anal ysi s of the sum
of two si gnal s i s equal to the sum of anal yses.
The detai l s cor respond to those obtai ned duri ng the decomposi ti on of the whi te
noi se.
The si ne i s found i n the appr oxi mati on A
5
. Thi s i s a hi gh enough l evel for the
effect of the noi se to be negl i gi bl e i n r el ati on to the ampl i tude of the si ne.
Illustrated Examples
4-29
Figure 4-11: A Sine + White Noise
Example #11: A Sine + White Noise
Addr essed topi cs Pr ocessi ng noi se
Detecti ng l ong-term evol uti on
Spl i tti ng si gnal components
I denti fyi ng the frequency of a si ne
Further expl orati on I denti fy the noi se char acter i sti cs. Use the
coeffi ci ents and the command l i ne mode.
1
0.5
0
0.5
a5
1
0
1
a4
1
0
1
a3
1
0
1
a2
200 400 600 800 1000
1
0
1
a1
0.1
0
0.1
d5
0.2
0
0.2
d4
0.2
0
0.2
d3
0.4
0.2
0
0.2
0.4
d2
200 400 600 800 1000
0.5
0
0.5
d1
1
0
1
s
Signal and Approximations
1
0
1
s
Signal and Details
4 Waveletsi n Acti on: Examples and C ase Studi es
4-30
Example #12: A Triangle + A Sine
Anal yzi ng wavel et: db5
Decomposi ti on l evel s: 6
The si gnal i s the sum of a si ne havi ng a per i od of appr oxi matel y 20 and of a
tri angl e.
D
1
and D
2
are very smal l . Thi s suggests that the si gnal contai ns no components
wi th peri ods that are short i n r el ati on to the sampl i ng per i od.
D
3
and especi al l y D
4
can be attri buted to the si ne. The jump of the si ne from A
3

to D
4
i s cl ear l y vi si bl e.
The detai l s for the hi gher l evel s D
5
and D
6
are smal l , especi al l y D
5
. D
6
exhi bi ts
some edge effects.
A
6
contai ns the tri angl e whi ch i ncl udes onl y l ow frequenci es.
Illustrated Examples
4-31
Figure 4-12: A Triangle + A Sine
Example #12: A Triangle + A Sine
Addr essed topi cs Detecti ng l ong-term evol uti on
Spl i tti ng si gnal components
I denti fyi ng the frequency of a si ne
Further expl orati on Tr y usi ng si nusoi ds whose per i od i s a power of 2.
0.4
0.2
0
0.2
0.4
a6
0.2
0
0.2
0.4
a5
0.4
0.2
0
0.2
0.4
a4
1
0
1
a3
1
0
1
a2
0.1
0
0.1
d6
0.04
0.02
0
0.02
0.04
d5
1
0
1
d4
0.4
0.2
0
0.2
0.4
d3
0.02
0
0.02
d2
200 400 600 800
5
0
5
x 10
4
d1
1
0
1
s
Signal and Approximations
1
0
1
s
Signal and Details
200 400 600 800
1
0
1
a1
4 Waveletsi n Acti on: Examples and C ase Studi es
4-32
Example #13: A Triangle + A Sine + Noise
Noi se Anal yzi ng wavel et: db5
Decomposi ti on l evel s: 7
The si gnal exami ned her e i s the same as the pr evi ous si gnal pl us a uni form
whi te noi se di vi ded by 3. The anal ysi s can ther efor e be compared to the
pr evi ous anal ysi s. Al l di ffer ences are due to the presence of the noi se.
D
1
and D
2
are due to the noi se.
D
3
and especi al l y D
4
ar e due to the si ne.
The hi gher-l evel detai l s ar e i ncr easi ngl y l ow, and ori gi nate i n the noi se.
A
7
contai ns a tr i angl e, al though i t i s not as wel l r econstructed as i n the
pr evi ous exampl e.
Illustrated Examples
4-33
Figure 4-13: A Triangle + A Sine + Noise
Example #13: A Triangle + A Sine + Noise
Addr essed topi cs Detecti ng l ong-term evol uti on
Spl i tti ng si gnal components
Further expl orati on I ncrease the ampl i tude of the noi se
Repl ace the tri angl e by a pol ynomi al
Repl ace the whi te noi se by an ARMA noi se
0.2
0
0.2
0.4
a7
0.4
0.2
0
0.2
0.4
a6
0.4
0.2
0
0.2
0.4
a5
0.4
0.2
0
0.2
0.4
a4
1
0
1
a3
1
0
1
a2
0.1
0
0.1
d7
0.2
0
0.2
d6
0.1
0
0.1
d5
1
0
1
d4
0.5
0
0.5
d3
0.4
0.2
0
0.2
0.4
d2
200 300 400 500 600 700 800
0.5
0
0.5
d1
1
0
1
s
Signal and Approximations
1
0
1
s
Signal and Details
200 300 400 500 600 700 800
1
0
1
a1
4 Waveletsi n Acti on: Examples and C ase Studi es
4-34
Example #14: A Real Electricity Consumption Signal
Anal yzi ng wavel et: db3
Decomposi ti on l evel s: 5
The seri es presents a peak i n the center , fol l owed by two dr ops, a shal l ow dr op,
and then a consi der abl y weaker peak.
The detai l s for l evel s 1 and 2 ar e of the same or der of magni tude and gi ve a good
expr essi on of the l ocal i r regul ari ti es caused by the noi se. The detai l for l evel 3
pr esents hi gh val ues i n the begi nni ng and at the end of the mai n peak, thus
al l owi ng us to l ocate the corr espondi ng dr ops. The detai l D
4
shows coarser
morphol ogi cal aspects for the ser i es i .e., thr ee successi ve peaks. Thi s fi ts the
shape of the curve remar kabl y wel l , and i ncl udes the essenti al si gnal
components for per i ods of l ess than 32 ti me-uni ts. The approxi mati ons show
thi s effect cl ear l y: A
1
and A
2
bear a strong resembl ance; A
3
for ms a reasonabl y
accurate approxi mati on of the or i gi nal si gnal . A l ook at A
4
, however, shows
that a consi der abl e amount of i nformati on has been l ost.
I n thi s case, as a concl usi on, the mul ti -scal e aspect i s the most i nteresti ng and
the most si gni fi cant feature: the essenti al components of the el ectri cal si gnal
used to compl ete the descr i pti on at 32 ti me-uni ts (homogeneous to A
5
) are the
components wi th a per i od between 8 to 16 ti me-uni ts.
Illustrated Examples
4-35
Figure 4-14: A Real Electricity Consumption Signal
Thi s si gnal i s expl or ed i n much gr eater detai l i n A Case Study: An El ectri cal
Si gnal on page 4-37.
Example #14: A Real Electricity Consumption Signal
Addr essed topi cs Detecti ng l ong-term evol uti on
Spl i tti ng si gnal components
Detecti ng br eakdown poi nts
Mul ti scal e anal ysi s
Further expl orati on Tr y the same anal ysi s on vari ous secti ons of the
si gnal . Focus on a r ange other than the
[ 3600: 3700] shown her e.
300
320
340
a4
300
320
340
a3
300
320
340
a2
3600 3620 3640 3660 3680 3700
300
320
340
a1
300
320
340
a5
300
320
340
s
Signal and Details
300
320
340
s
Signal and Approximations
10
0
10
d4
10
0
10
d5
10
0
10
d3
10
0
10
d2
3600 3620 3640 3660 3680 3700
10
0
10
d1
4 Waveletsi n Acti on: Examples and C ase Studi es
4-36
A Case Study: An Electrical Signal
The goal of thi s secti on i s to pr ovi de a stati sti cal descr i pti on of an el ectr i cal l oad
consumpti on usi ng the wavel et decomposi ti ons as a mul ti scal e anal ysi s.
Two probl ems ar e addressed. They both deal wi th si gnal extracti on from the
l oad curve cor rupted by noi se:
1 What i nformati on i s contai ned i n the si gnal , and what pi eces of
i nformati on are useful ?
2 Ar e there var i ous ki nds of noi ses, and can they be di sti ngui shed from
one another?
The context of the study i s the for ecast of the el ectr i cal l oad. Curr entl y,
short-ter m for ecasts ar e based on the data sampl ed over 30 mi nutes. After
el i mi nati ng cer tai n components l i nked to weather condi ti ons, cal endar effects,
outl i ers and known external acti ons, a SARI MA par ametri c model i s
devel oped. The model del i vers forecasts fr om hal f-an-hour to two days. The
qual i ty of the forecasts i s ver y hi gh at l east for 90% of al l days, but the method
fai l s when wor ki ng wi th the data sampl ed over 1 mi nute.
Data and the External Information
The data consi st of measurement of a compl ex, hi ghl y-aggregated pl ant: the
el ectri cal l oad consumpti on, sampl ed mi nute by mi nute, over a 5-week peri od.
Thi s ti me ser i es of 50,400 poi nts i s par tl y pl otted at the top of the Fi gure 4-17.
External i nformati on i s gi ven by el ectri cal engi neer s, and addi ti onal
i ndi cati ons can be found i n several papers. Thi s i nfor mati on, used to defi ne
r efer ence si tuati ons for the purpose of compar i son, i ncl udes these poi nts:
The l oad curve i s the aggr egati on of hundreds of sensors measur ements, thus
gener ati ng measur ement er ror s.
Roughl y speaki ng, the consumpti on i s accounted for by i ndustry for 50% and
by i ndi vi dual consumers for the other hal f. The component of the l oad curve
produced by i ndustr y has a r ather regul ar profi l e and exhi bi ts l ow-fr equency
changes. On the other hand, the consumpti on of i ndi vi dual consumer s may
be hi ghl y i rr egul ar, l eadi ng to hi gh-frequency components.
A C ase Study: An Electri cal Si gnal
4-37
There are mor e than 10 mi l l i ons i ndi vi dual consumer s.
The fundamental peri ods ar e the weekl y-dai l y cycl es, l i nked to
economi c r hythms.
Dai l y consumpti on patter ns al so change accor di ng to rate changes at
di ffer ent ti mes (e.g. r el ay-swi tched water heaters to benefi t fr om speci al
ni ght rates).
Mi ssi ng data have been r epl aced.
Outl i ers have not been cor rected.
For the obser vati ons 2400 to 3400, the measur ement er ror s are unusual l y
hi gh, due to sensor s fai l ur es.
From a methodol ogi cal poi nt of vi ew, the wavel et techni ques provi de a
mul ti scal e anal ysi s of the si gnal as a sum of orthogonal si gnal s corr espondi ng
to di ffer ent ti me scal es, al l owi ng a ki nd of ti me-scal e anal ysi s.
Because of the absence of a model for the one mi nute data, the descr i pti on
str ategy pr oceeds essenti al l y by successi ve uses of var i ous compar ati ve
methods appl i ed to si gnal s obtai ned by the wavel et decomposi ti on.
Wi thout model i ng, i t i s i mpossi bl e to defi ne a si gnal or a noi se effect.
Neverthel ess, we say that any repeti ti ve patter n i s due to si gnal and i s
meani ngful .
Fi nal l y i t i s known that two ki nds of noi se cor rupt the si gnal : sensors err or s
and the state noi se.
We shal l not report her e the compl ete anal ysi s whi ch i s i ncl uded i n a paper.
I nstead, we i l l ustrate the contr i buti on of wavel et tr ansfor ms to the l ocal
descr i pti on of ti me ser i es. We choose two smal l sampl es: one taken at mi dday,
and the other at the end of the ni ght.
I n the fi rst per i od the si gnal structure i s compl ex, i n the second one, much
si mpl er .The mi dday peri od has a compl i cated structure because the i ntensi ty
of the el ectr i ci ty consumer s acti vi ty i s hi gh and i t presents very l arge changes.
At the end of the ni ght the acti vi ty i s l ow and changes sl owl y.
For the l ocal anal ysi s, the decomposi ti on i s taken up to the l evel j = 5, because
2
5
= 32 i s ver y cl ose to hal f an hour. We are then abl e to study the components
of the si gnal for whi ch the per i od i s l ess than hal f an hour .
The anal yzi ng wavel et used her e i s db3.
The resul ts are descr i bed si mi l ar l y for the two per i ods.
4 Waveletsi n Acti on: Examples and C ase Studi es
4-38
Analysis of the Midday Period
Thi s si gnal (see Fi gur e 4-14) i s al so anal yzed i n Exampl e #14: A Real
El ectri ci ty Consumpti on Si gnal on page 4-35 more cr udel y.
The shape i s a mi ddl e mode between 00h30 pm and 01h00 pm, pr eceded and
fol l owed by a hol l ow off-peak, and next a second smoother mode at 01h15 pm.
The appr oxi mati on A
5
corr espondi ng to the ti me scal e of 32 mi nutes, i s a ver y
crude approxi mati on, par ti cul ar l y for the centr al mode: ther e i s a peak ti me l ag
and an underesti mati on of the maxi mum val ue. So at thi s l evel the most
essenti al i nfor mati on i s mi ssi ng. We have to l ook at l ower scal es (4 for
i nstance).
Let us exami ne the cor respondi ng detai l s.
The detai l s D
1
and D
2
have smal l val ues and may be consi der ed as l ocal
short-peri od di screpanci es caused by the hi gh fr equency components of sensor
and state noi ses. I n thi s bandpass, these noi ses ar e essenti al l y due to
measurement er rors and fast vari ati ons of the si gnal i nduced by mi l l i ons of
state changes of personal el ectr i cal appl i ances.
The detai l D
3
exhi bi ts hi gh val ues at ti mes corr espondi ng to the start and the
end of the ori gi nal mi ddl e mode. I t al l ows ti me l ocal i zati on of the l ocal mi ni ma.
The detai l D
4
contai ns the mai n patterns: thr ee successi ve modes. I t i s
r emarkabl y cl ose to the shape of the curve. The rati o of the val ues of thi s l evel
to the other l evel s i s equal to 5. The detai l D
5
does not bear much i nformati on.
So the contri buti on of the l evel 4 i s the hi ghest one, both i n qual i tati ve and
quanti tati ve aspects. I t captures the shape of the curve i n the concer ned per i od.
A C ase Study: An Electri cal Si gnal
4-39
I n concl usi on, wi th r espect to the appr oxi mati on A
5
, the detai l D
4
i s the mai n
addi ti onal corr ecti on: the components of peri od 8 to 16 mi nutes contai n the
cr uci al dynami cs.
Figure 4-15: Analysis of the Midday Period
Analysis of the End of the Night Period
See Fi gur e 4-16.
The shape of the curve duri ng the end of the ni ght i s a sl ow descent gl obal l y
smooth but l ocal l y hi ghl y i rr egul ar. One can hardl y di sti ngui sh two successi ve
l ocal extr ema i n the vi ci ni ty of ti me t=1600 and t=1625. The approxi mati on A
5
i s qui te good except at these two modes.
The accur acy of the appr oxi mati on can be expl ai ned by the fact that there
remai ns onl y a l ow frequency si gnal corr upted by noi ses. The massi ve and
si mul taneous changes of per sonal el ectri c appl i ances ar e absent.
300
320
340
a4
300
320
340
a3
300
320
340
a2
3600 3620 3640 3660 3680 3700
300
320
340
a1
300
320
340
a5
300
320
340
s
Signal and Details
300
320
340
s
Signal and Approximations
10
0
10
d4
10
0
10
d5
10
0
10
d3
10
0
10
d2
3600 3620 3640 3660 3680 3700
10
0
10
d1
4 Waveletsi n Acti on: Examples and C ase Studi es
4-40
The detai l s D
1
, D
2
, and D
3
show the ki nd of vari ati on and have, roughl y
speaki ng, si mi l ar shape and mean val ue. They contai n the l ocal shor t per i od
i r regul ar i ti es caused by noi ses and the i nspecti on of D
2
and D
3
al l ows one to
detect the l ocal mi ni mum ar ound t=1625.
The detai l s D
4
and D
5
exhi bi t the sl ope changes of the r egul ar par t of the si gnal
and A
4
and A
5
ar e pi ecewi se l i near .
I n concl usi on, none of the ti me scal es bri ngs a si gni fi cant contri buti on,
suffi ci entl y di ffer ent from the noi se l evel , and no addi ti onal cor recti on i s
needed. The retai ned appr oxi mati on i s A
4
or A
5
.
Figure 4-16: Analysis of the End of the Night Period
5
0
5
d5
5
0
5
d4
5
0
5
d3
220
240
260
280
300
s
Signal and Approximations
220
240
260
280
300
a5
220
240
260
280
300
a4
220
240
260
280
300
a3
220
240
260
280
300
a2
1600 1650 1700
220
240
260
280
300
a1
220
240
260
280
300
s
Signal and Details
1600 1650 1700
5
0
5
d1
5
0
5
d2
A C ase Study: An Electri cal Si gnal
4-41
Al l the fi gures i n thi s paragraph have been gener ated usi ng the Gr aphi cal User
I nter face tool s, but the user can al so process the anal ysi s usi ng the command
l i ne mode. The fol l owi ng exampl e gi ves some i ndi cati ons and cor responds to a
command l i ne equi val ent of produci ng Fi gur e 4-17.
% Load t he or i gi nal 1- D s i gnal , dec ompos e, r ec ons t r uc t de t ai l s i n
% or i gi nal t i me and pl ot .
% l oad t he s i gnal .
l oad l e l e cc um; s = l el e cc um;
% Dec ompos e t he s i gnal s at l ev el 5 us i ng t he wav el et w.
w = db3 ; [ c, l ] = wav e de c( s , 5, w) ;
% Rec ons t r uc t t he de t ai l s us i ng t he coef f i ci ent s .
f or i = 1: 5
ev al ( [ ' d( ' , i nt 2s t r ( i ) , ' , : ) = wr c oef ( ' ' d' ' , c , l , w, i ) ; ' ] ) ;
e nd
Note: Thi s l oop repl aces 5 separ ate wr coef statements defi ni ng vari abl es D
1

through D
5
.
% Avoi d e dge e f f ec t s by s uppr es s i ng edge v al ue s and pl ot .
t t = 1+100: l engt h( s ) - 100;
s ubpl ot ( 611) ; pl ot ( t t , s ( t t ) , r ) ;
t i t l e ( El ec t r i cal Si gnal and De t ai l s ) ;
f or i = 1: 5, s ubpl ot ( 6, 1, i +1) ; pl ot ( t t , d( i , t t ) , g ) ; end
4 Waveletsi n Acti on: Examples and C ase Studi es
4-42
Figure 4-17: Decomposition of Three-Day Electrical Signal at
Level 5 Using db3
Suggestions for Further Analysis
Let us now make some suggesti ons for possi bl e fur ther anal ysi s starti ng from
the detai l s of the decomposi ti on at l evel 5 of thr ee days (see Fi gur e 4-17).
Identify the Sensor Failure
Focus on the wavel et decomposi ti on and try to i denti fy the sensor fai l ur e
di r ectl y on the detai l s D
1
, D
2
and D
3
and not the other ones. Try to i denti fy the
other part of the noi se.
20
0
20
d5
10
0
10
20
d3
10
0
10
20
d2
500 1000 1500 2000 2500 3000 3500 4000
20
0
20
d1
20
0
20
40
d4
200
300
400
500
s
Electrical Signal and Details
A C ase Study: An Electri cal Si gnal
4-43
I ndi cati on: see Fi gure 4-18.
Figure 4-18: Identification of Sensor Failure
Suppress the Noise
Suppr ess measurement noi se. Tr y by yoursel f and use, afterwards, the
de-noi si ng tool s.
10
0
10
20
d3
2200 2400 2600 2800 3000 3200 3400 3600
20
10
0
10
20
d1
200
300
400
500
s
Signal and Details
10
0
10
20
d2
4 Waveletsi n Acti on: Examples and C ase Studi es
4-44
I ndi cati on: study the approxi mati ons and compare two successi ve days, the
fi r st wi thout sensor fai l ur e and the second corr upted by fai l ure
(see Fi gur e 4-19).
Figure 4-19: Comparison of Smoothed Versions of the Signal
Identify Patterns in the Details
The i dea here i s to i denti fy a patter n i n the detai l s typi cal of rel ay-swi tched
water heater s.
200
300
400
500
a4
200
300
400
500
a3
200
300
400
500
a2
500 1000 1500 2000 2500 3000 3500 4000
200
300
400
500
a1
200
300
400
500
s
Signal and Approximations
A C ase Study: An Electri cal Si gnal
4-45
I ndi cati on: the Fi gure 4-20 gi ves an exampl e of such a per i od. Focus on detai l s
D
2
, D
3
and D
4
ar ound absci ssa 1350, 1383, and 1415 i n or der to detect abr upt
changes of the si gnal i nduced by automati c swi tches.
Figure 4-20: Location of the Water Heaters and Identification of the
Effects on the Details
340
360
380
400
420
440
s
Signal and Details
10
0
10
d4
10
0
10
d3
5
0
5
d2
1350 1360 1370 1380 1390 1400 1410 1420 1430 1440 1450
2
0
2
d1
4 Waveletsi n Acti on: Examples and C ase Studi es
4-46
Locate and Suppress Outlying Values
Suppress the outl i ers by setti ng the cor respondi ng val ues of the detai l s to 0.
I ndi cati on: the Fi gur e 4-21 gi ves two exampl es of outl i ers around t = 1193 and
t = 1215, the effect pr oduced on the detai l s i s cl ear when focusi ng on the l ow
l evel s. As far as outl i ers ar e concerned, D
1
and D
2
are synchr oni zed wi th s, D
3

shows a del ayed effect.
Figure 4-21: Location of the Outliers and Identification of the Effects
on the Details
10
0
10
20
d3
1170 1180 1190 1200 1210 1220 1230
20
10
0
10
20
d1
10
0
10
20
d2
340
360
380
400
s
Signal and Details
A C ase Study: An Electri cal Si gnal
4-47
Study Missing Data
Mi ssi ng data have been cr udel y substi tuted (ar ound obser vati on 2870) by
esti mati on of hal f an hour sampl ed data and spl i ne smoothi ng for the
i nter medi ate ti me poi nts. I mprove the i nter pol ati on by usi ng an approxi mati on
and porti ons of the detai l s taken el sewhere, thus i mpl ementi ng a sort of
gr aft.
I ndi cati on: see Fi gure 4-22 focusi ng ar ound ti me 2870, and use the smal l
var i ati ons part of D
1
i n or der to detect the mi ssi ng data.
Figure 4-22: Detection of Missing Data Replaced Using Splines
360
380
400
420
440
a2
2840 2860 2880 2900
360
380
400
420
440
a1
10
5
0
5
10
d2
2840 2860 2880 2900
10
5
0
5
10
d1
360
380
400
420
s
Signal and Details
360
380
400
420
s
Signal and Approximations
4 Waveletsi n Acti on: Examples and C ase Studi es
4-48
Fast Multiplication of Large Matrices
Thi s secti on i l l ustr ates matr i x-vector mul ti pl i cati on i n the wavel et domai n.
The pr obl em i s:
l et m be a dense matr i x of l ar ge si ze (n, n). We want to perform a l ar ge number
L of mul ti pl i cati ons of m by vector s v.
The i dea i s:
Stage 1: (executed once) compute the matr i x approxi mati on sm at a sui tabl e
l evel k, the matri x bei ng assi mi l ated wi th an i mage.
Stage 2: (executed L ti mes) di vi ded i n the fol l owi ng thr ee steps:
1 Compute vector approxi mati on.
2 Compute mul ti pl i cati on i n wavel et domai n.
3 Reconstr uct vector appr oxi mati on.
I t i s cl ear that when sm i s a suffi ci entl y good approxi mati on of m, the er ror wi th
r espect to or di nar y mul ti pl i cati on can be smal l . Thi s i s the case i n the fi r st
exampl e bel ow wher e m i s a magi c squar e. Conver sel y, when the wavel et
r epr esentati on of the matri x m i s dense, for exampl e i f al l the coeffi ci ents have
the same order of magni tude, the err or wi l l be l arge. Thi s i s the case i n the
second exampl e bel ow where m i s a two-di mensi onal Gaussi an whi te noi se. The
Fi gure 4-23 compar es for n = 512, the number of fl ops requi red by wavel et
based method and by ordi nary method ver sus L.
Fast M ulti pli cati on of Large M atri ces
4-49
Example 1: Effective Fast Matrix Multiplication
n = 512; l e v = 5; wav = db1 ;
% Wav el et bas e d mat r i x mul t i pl i cat i on by a v ec t or :
% a good e xampl e
% Mat r i x i s magi c( 512) Ve ct or i s ( 1: 512)
m = magi c ( n) ; v = ( 1: n) ;
[ LoF_D, Hi F_D, LoF_R, Hi F_R] = wf i l t er s ( wav ) ;
% or di nar y mat r i x mul t i pl i c at i on by a ve ct or .
f l ops ( 0) , p = m * v; f l omv = f l ops
f l omv =
524288
% Comput e mat r i x appr ox i mat i on at l e ve l 5.
f l ops ( 0)
s m = m;
f or i = 1: l e v
s m = dy addown( conv 2( s m, LoF_D) , c ) ;
s m = dy addown( conv 2( s m, LoF_D ) , r ) ;
e nd
f l mapp = f l ops
f l mapp =
2095104
% The t hr ee s t eps :
% 1. Comput e v ec t or appr oxi mat i on.
% 2. Comput e mul t i pl i c at i on i n wave l et domai n.
% 3. Re cons t r uct v ec t or appr oxi mat i on.
4 Waveletsi n Acti on: Examples and C ase Studi es
4-50
f l ops ( 0)
s v = v;
f or i = 1: l e v, s v = dyaddown( c onv( s v , LoF_D) ) ; e nd
s p = s m * s v ;
f or i = 1: l e v, s p = c onv( dy adup( s p) , LoF_R) ; e nd
s p = wke ep( s p, l e ngt h( v) ) ;
f l wmv = f l ops
f l wmv =
8958
% Pl ot or di nar y ve r s us wave l e t bas ed m*v f l ops i n l ogl og.
Figure 4-23: Wavelet Based Matrix Multiplication by a Vector
% Rel at i ve s quar e nor m er r or i n pe r c ent whe n us i ng wav el et s .
r nr m = 100 ( nor m( p- s p) /nor m( p) )
r nr m =
2. 9744e- 06
10
0
10
1
10
2
10
3
10
4
10
5
10
5
10
6
10
7
10
8
10
9
10
10
10
11
log(L) for a given matrix
l
o
g
(
f
l
o
p
s
)
Ordinary (dashed line) versus wavelet (solid line) based m*v flops
Fast M ulti pli cati on of Large M atri ces
4-51
Example 2: Ineffective Fast Matrix Multiplication
The commands used ar e the same as i n Exampl e 1.
% Wav el et bas e d mat r i x mul t i pl i cat i on by a v ec t or :
% a bad e x ampl e
% Mat r i x i s r andn( 512, 512) Ve ct or i s ( 1: 512)
% Rel at i v e s quar e nor m er r or i n per c ent
r nr m = 100 * ( nor m( p- s p) /nor m( p) )
r nr m =
98. 8839
4 Waveletsi n Acti on: Examples and C ase Studi es
4-52

5
Usi ng Wavel et Packets
5-3 About Wavelet Packet Analysis
5-6 One-Dimensional Wavelet Packet Analysis
5-14 De-Noi si ng a Si gnal Usi ng Wavel et Packet
5-19 Two-Dimensional Wavelet Packet Analysis
5-26 Importing and Exporting from Graphical Tools
5-26 Savi ng I nformati on to the Di sk
5-28 Loadi ng I nformati on i nto the Gr aphi cal Tool s
5 Usi ng Wavelet Packets
5-2
The Wavel et Tool box contai ns graphi cal tool s and command l i ne functi ons that
l et you:
Exami ne and expl or e char acteri sti cs of i ndi vi dual wavel et packets.
Per form wavel et packet anal ysi s of one- and two-di mensi onal si gnal s.
Use wavel et packets to compr ess and r emove noi se from si gnal s and i mages.
Thi s chapter takes you step-by-step thr ough exampl es that teach you how to
use the Wavelet Packet 1-D and Wavelet Packet 2-D graphi cal tool s. The
l ast secti on di scusses how to tr ansfer i nformati on from the gr aphi cal tool s i nto
your di sk, and back agai n.
Because of the i nherent compl exi ty of packi ng and unpacki ng compl ete wavel et
packet decomposi ti on tree structures, we r ecommend usi ng the Wavelet
Packet 1-D and Wavelet Packet 2-D graphi cal tool s for per formi ng
expl or atory anal yses.
The command l i ne functi ons ar e al so avai l abl e and provi de the same
capabi l i ti es. However, i t i s most effi ci ent to use the command l i ne onl y for
perfor mi ng batch processi ng.
About Wavelet Packet Analysi s
5-3
About Wavelet Packet Analysis
Thi s chapter takes you through the featur es of one- and two-di mensi onal
wavel et packet anal ysi s usi ng the MATLAB Wavel et Tool box. Youl l l earn
how to:
Load a si gnal or i mage
Per for m a wavel et packet anal ysi s of a si gnal or i mage
Remove noi se from a si gnal
Compr ess an i mage
Show stati sti cs and hi stogr ams
The Wavel et Tool box provi des these functi ons for wavel et packet anal ysi s. For
more i nformati on, see the Command Refer ence (Chapter 8). The r efer ence
entr i es for these functi ons i ncl ude exampl es showi ng how to per for m wavel et
packet anal ysi s vi a the command l i ne.
Analysis-Decomposition Functions:
Synthesis-Reconstruction Functions:
Function Name Purpose
wpde c and wpde c2 Ful l decomposi ti on
wps pl t Decompose packet
Function Name Purpose
wpr c oe f Reconstr uct coeffi ci ents
wpr e c Ful l r econstructi on
wpj oi n Recompose packet
5 Usi ng Wavelet Packets
5-4
Decomposition Structure Utilities:
De-noising and Compression:
I n the wavel et packet framework, compressi on and de-noi si ng i deas are exactl y
the same as those devel oped i n the wavel et framewor k. The onl y di ffer ence i s
that wavel et packets offer a mor e compl ex and fl exi bl e anal ysi s, because i n
wavel et packet anal ysi s, the detai l s as wel l as the approxi mati ons ar e spl i t:
A si ngl e wavel et packet decomposi ti on gi ves a l ot of bases fr om whi ch you can
l ook for the best r epr esentati on wi th respect to a desi gn objecti ve. Thi s can be
done by fi ndi ng the best tr ee based on an entr opy cr i teri on.
Function Name Purpose
be s t t r e e Fi nd best tr ee
be s t l ev t Fi nd best l evel tree
we nt r opy Entr opy
ent r upd Update wavel et packets entropy
Function Name Purpose
ddenc mp Defaul t val ues for de-noi si ng and compressi on
wpt hc oe f Wavel et packets coeffi ci ents thr eshol di ng
wpde ncmp De-noi si ng and compr essi on usi ng wavel et packets
S
A
1
D
1
AA
2
DA
2
AAA
3
DAA
3
AD
2
DD
2
ADA
3
DDA
3
AAD
3
DAD
3
ADD
3
DDD
3
About Wavelet Packet Analysi s
5-5
De-noi si ng and compr essi on ar e i nteresti ng appl i cati ons of wavel et packet
anal ysi s. The wavel et packet de-noi si ng or compressi on procedure i nvol ves
four steps:
1 Decomposi ti on
For a gi ven wavel et, compute the wavel et packet decomposi ti on of si gnal x
at l evel N.
2 Computati on of the best tree
For a gi ven entropy, compute the opti mal wavel et packet tr ee. Of cour se,
thi s step i s opti onal . The gr aphi cal tool s pr ovi de a Best Tree button for
maki ng thi s computati on qui ck and easy.
3 Thr eshol di ng of wavel et packet coeffi ci ents
For each packet (except for the appr oxi mati on), sel ect a threshol d and appl y
threshol di ng to coeffi ci ents.
The gr aphi cal tool s automati cal l y pr ovi de an i ni ti al thr eshol d based on
bal anci ng the amount of compressi on and retai ned energy. Thi s thr eshol d i s
a reasonabl e fi rst appr oxi mati on for most cases. However , i n gener al you
wi l l have to r efi ne your threshol d by tri al and er ror so as to opti mi ze the
r esul ts to fi t your parti cul ar anal ysi s and desi gn cr i teri a.
The tool s faci l i tate exper i mentati on wi th di ffer ent thr eshol ds, and make i t
easy to al ter the trade-off between amount of compr essi on and r etai ned
si gnal ener gy.
4 Reconstr ucti on
Compute wavel et packet r econstructi on based on the ori gi nal approxi mati on
coeffi ci ents at l evel N and the modi fi ed coeffi ci ents.
I n thi s exampl e wel l show how you can use one-di mensi onal wavel et packet
anal ysi s to compr ess and to de-noi se a si gnal .
5 Usi ng Wavelet Packets
5-6
One-Dimensional Wavelet Packet Analysis
We now turn to the Wavelet Packet 1-D tool to anal yze a syntheti c si gnal that
i s the sum of two l i near chi rps.
Starting the Wavelet Packet 1-D Tool.
1 Fr om the MATLAB pr ompt, type wave me nu.
The Wavelet Toolbox Main Menu appears.
2 Cl i ck the Wavelet Packet 1-D menu i tem.
The tool appears on the desktop.
O ne-Di mensi onal Wavelet Packet Analysi s
5-7
Loading a Signal.
3 From the File menu, choose the Load Signal opti on.
4 When the Load Signal di al og box appears, sel ect the demo MAT-fi l e
s uml i chr . mat , whi ch shoul d resi de i n the MATLAB di r ectory
t ool box /wave l e t /wav edemo. Cl i ck the OK button.
The s uml i chr si gnal i s l oaded i nto the Wavelet Packet 1-D tool .
5 Usi ng Wavelet Packets
5-8
Analyzing a Signal.
5 Make the appr opri ate setti ngs for the anal ysi s. Sel ect the db2 wavel et, l evel
4, entropy type t hr e s hol d, and thr eshol d parameter 1. Cl i ck the Analyze
button.
The avai l abl e entropy types ar e:
Type Description
Shannon Non-nor mal i zed entr opy i nvol vi ng the l ogari thm of
the squar ed val ue of each si gnal sampl e or, mor e
formal l y:
Thr eshol d The number of sampl es for whi ch the absol ute val ue
of the si gnal exceeds a threshol d .
Norm The concentr ati on i n norm wi th .
Log Energy The l ogar i thm of energy, defi ned as the sum over al l
sampl es:
s
i
2
s
i
2
( ) log

l
p
1 p 2 <
s
i
2
( ) log

O ne-Di mensi onal Wavelet Packet Analysi s


5-9
For more i nfor mati on about the avai l abl e entropy types, user -defi ned entropy,
and threshol d par ameters, see the reference entr y for we nt r opy , and Chapter 6.
Note: Many capabi l i ti es are avai l abl e usi ng the command ar ea on the r i ght of
the Wavelet Packet 1-D wi ndow. Some of them ar e used i n the sequel . Pl ease
refer to the Appendi x A, GUI Reference for a more compl ete descri pti on.
SURE (Stei ns Unbi -
ased Ri sk Esti mate)
A thr eshol d-based method i n whi ch the threshol d
equal s:
where n i s the number of sampl es i n the si gnal .
User An entr opy type cri teri on you defi ne i n an M-fi l e.
Type Description
2log
e
nlog
2
n ( ) ( )
5 Usi ng Wavelet Packets
5-10
Computing the Best Tree.
Because ther e ar e so many ways to reconstr uct the or i gi nal si gnal from the
wavel et packet decomposi ti on tr ee, we sel ect the best tr ee befor e attempti ng to
compr ess the si gnal .
6 Cl i ck the Best Tree button.
After a pause for computati on, the Wavelet Packet 1-D tool di spl ays the
best tr ee. Use the top and bottom sl i ders to spr ead nodes apart and pan over
to par ti cul ar ar eas of the tr ee, r especti vel y.
Obser ve that, for thi s anal ysi s, the best tr ee and the i ni ti al tr ee are al most
the same. One br anch at the far ri ght of the tree was el i mi nated.
Spread or contract tree nodes
Pan left or right
to improve readability
O ne-Di mensi onal Wavelet Packet Analysi s
5-11
Selecting a Threshold for Compression.
7 Cl i ck the Compress button.
The Wavelet Packet 1-D Compression wi ndow appear s wi th an
appr oxi mate thr eshol d val ue automati cal l y sel ected.
The l eft most graph shows how the threshol d (ver ti cal yel l ow dotted l i ne)
has been chosen automati cal l y (1.482) to bal ance the number of zer os i n the
compr essed si gnal (bl ue curve that i ncr eases as the threshol d i ncr eases)
wi th the amount of energy retai ned i n the compressed si gnal (purpl e curve
that decreases as the thr eshol d i ncreases).
Thi s threshol d means that any si gnal el ement whose val ue i s l ess than 1.482
wi l l be set to zer o when we perform the compr essi on.
Thr eshol d contr ol s are l ocated to the r i ght (see red box i n fi gure). Note that
the automati c threshol d of 1.482 resul ts i n a retai ned energy of onl y 81.49%.
Thi s may cause unacceptabl e amounts of di storti on, especi al l y i n the peak
val ues of the osci l l ati ng si gnal . Dependi ng on your desi gn cr i teri a, you may
want to choose a threshol d that r etai ns more of the ori gi nal si gnal s ener gy.
5 Usi ng Wavelet Packets
5-12
8 Adjust the threshol d by typi ng 0. 8938 i n the text fi el d opposi te the thr eshol d
sl i der, then press the Enter key.
The val ue 0. 8938 i s a number that we have di scovered thr ough tr i al and
er ror yi el ds mor e sati sfactory r esul ts for thi s anal ysi s.
After a pause, the Wavelet Packet 1-D Compression wi ndow di spl ays
new i nformati on.
Note that, as we have reduced the threshol d fr om 1.482 to 0.8938:
- The ver ti cal yel l ow dotted l i ne has shi fted to the l eft.
- The r etai ned energy has increased from 81.49% to 90.96%.
- The number of zer os (equi val ent to the amount of compr essi on) has
decreased from 81.55% to 75.28%.
O ne-Di mensi onal Wavelet Packet Analysi s
5-13
Compressing a Signal.
9 Cl i ck the Compress button.
The Wavelet Packet 1-D tool compr esses the si gnal usi ng the thr eshol di ng
cri ter i on we sel ected.
The ori gi nal (red) and compressed (yel l ow) si gnal s are di spl ayed
superi mposed. Vi sual i nspecti on suggests the compr essi on qual i ty i s qui te
good.
Looki ng more cl osel y at the compressed si gnal , we see that the number of zer os
i n the wavel et packets repr esentati on of the compr essed si gnal i s about 75.3%,
and the retai ned energy about 91%.
I f you try to compress the same si gnal usi ng wavel ets wi th exactl y the same
parameter s, onl y 89% of the si gnal energy i s retai ned, and onl y 59% of the
wavel et coeffi ci ents set to zero. Thi s i l l ustrates the superi or i ty of wavel et
packets for per formi ng compressi on, at l east on certai n si gnal s.
You can demonstr ate thi s to your sel f by returni ng to the mai n Wavelet
Packet 1-D wi ndow, computi ng the wavel et tree, and then repeati ng the
compr essi on.
5 Usi ng Wavelet Packets
5-14
De-Noising a Signal Using Wavelet Packet
We now use the Wavelet Packet 1-D tool to anal yze a noi sy chi r p si gnal . Thi s
anal ysi s i l l ustrates the use of Stei ns Unbi ased Esti mate of Ri sk (SURE) as a
pr i nci pl e for sel ecti ng a thr eshol d to be used for de-noi si ng.
Thi s techni que cal l s for setti ng the thr eshol d T to
where n i s the l ength of the si gnal .
A more thorough di scussi on of the SURE cri ter i on appears i n Chapter 6. For
now, suffi ce i t to say that thi s method works wel l i f your si gnal i s nor mal i zed
i n such a way that the data fi t the model x(t) = f(t) + e(t), wher e e(t) i s a Gaussi an
whi te noi se wi th zer o mean and uni t vari ance.
I f youve al r eady star ted the Wavelet Packet 1-D tool and i t i s acti ve on your
computers desktop, skip to step 3.
Starting the Wavelet Packet 1-D Tool.
1 Fr om the MATLAB pr ompt, type wave me nu.
The Wavelet Toolbox Main Menu appears.
T 2log
e
nlog
2
n ( ) ( ) =
O ne-Di mensi onal Wavelet Packet Analysi s
5-15
2 Cl i ck the Wavelet Packet 1-D menu i tem.
The tool appear s on the desktop.
Loading a Signal.
3 From the File menu, choose the Load Signal opti on.
4 When the Load Signal di al og box appears, sel ect the demo MAT-fi l e
noi s c hi r . mat , whi ch shoul d resi de i n the MATLAB di r ectory
t ool box /wave l e t /wav edemo. Cl i ck the OK button.
5 Usi ng Wavelet Packets
5-16
The noi s chi r si gnal i s l oaded i nto the Wavelet Packet 1-D tool . Noti ce
that the si gnal s l ength i s 1024. Thi s means we shoul d set the SURE
cri teri on threshol d equal to s qr t ( 2. *l og( 1024. *l og2( 1024) ) ) , or 4.2975.
Analyzing a Signal.
5 Make the appr opri ate setti ngs for the anal ysi s. Sel ect the db2 wavel et, l evel
4, entropy type s ur e , and threshol d par ameter 4.2975. Cl i ck the Analyze
button.
Ther e i s a pause whi l e the wavel et packet anal ysi s i s computed.
Note: Many capabi l i ti es are avai l abl e usi ng the command ar ea on the r i ght of
the Wavelet Packet 1-D wi ndow. Some of them are used i n the sequel . Pl ease
r efer to the Appendi x A, GUI Reference for a mor e compl ete descr i pti on.
Signal length
O ne-Di mensi onal Wavelet Packet Analysi s
5-17
Computing the Best Tree and Performing De-Noising.
6 Cl i ck the Best Tree button.
Computi ng the best tr ee makes the de-noi si ng cal cul ati ons more effi ci ent.
7 Cl i ck the De-noise button, br i ngi ng up the Wavelet Packet 1-D
De-Noising wi ndow.
5 Usi ng Wavelet Packets
5-18
8 Cl i ck the De-noise button l ocated at the center r i ght si de of the Wavelet
Packet 1-D De-Noising wi ndow.
The resul ts of the de-noi si ng operati on are qui te good, as can be seen by l ooki ng
at the threshol ded coeffi ci ents. The frequency of the chi rp si gnal i ncreases
quadrati cal l y over ti me, and the threshol ded coeffi ci ents essenti al l y captur e
the quadrati c curve i n the ti me-fr equency pl ane.
You can al so use the M-fi l e wpde nc mp to per for m wavel et packet de-noi si ng or
compr essi on fr om the command l i ne.
Two-Di mensi onal Wavelet Packet Analysi s
5-19
Two-Dimensional Wavelet Packet Analysis
I n thi s secti on, we empl oy the Wavelet Packet 2-D tool to anal yze and
compr ess an i mage of a fi nger pri nt. Thi s i s a r eal -worl d probl em: the Federal
Bur eau of I nvesti gati on (FBI ) mai ntai ns a l arge database of fi nger pri nts
about 30 mi l l i on sets of them. The cost of stor i ng al l thi s data r uns to hundr eds
of mi l l i ons of dol l ar s. By turni ng to wavel ets, the FBI has achi eved a 15:1
compr essi on rati o. I n thi s appl i cati on, wavel et compressi on i s better than the
more tradi ti onal JPEG compressi on, as i t avoi ds smal l square ar ti facts, and i s
parti cul arl y wel l sui ted to detect di sconti nui ti es (l i nes) i n the fi ngerpr i nt.
5 Usi ng Wavelet Packets
5-20
Starting the Wavelet Packet 2-D Tool.
1 Fr om the MATLAB pr ompt, type:
wave me nu.
The Wavelet Toolbox Main Menu appears.
2 Cl i ck the Wavelet Packet 2-D menu i tem.
The tool appears on the desktop.
Two-Di mensi onal Wavelet Packet Analysi s
5-21
Loading an Image.
From the File menu, choose the Load Image opti on.
3 When the Load Image di al og box appears, sel ect the demo MAT-fi l e
det f i ngr . mat , whi ch shoul d resi de i n the MATLAB di r ectory
t ool box /wave l e t /wav edemo. Cl i ck the OK button.
The fi nger pri nt i mage i s l oaded i nto the Wavelet Packet 2-D tool .
5 Usi ng Wavelet Packets
5-22
Analyzing an Image.
4 Make the appropr i ate setti ngs for the anal ysi s. Sel ect the haar wavel et,
l evel 3, and entropy type s hannon. Cl i ck the Analyze button.
Ther e i s a pause whi l e the wavel et packet anal ysi s i s computed.
Note: Many capabi l i ti es are avai l abl e usi ng the command ar ea on the r i ght of
the Wavelet Packet 2-D wi ndow. Some of them are used i n the sequel . Pl ease
r efer to the Appendi x A, GUI Reference for a mor e compl ete descr i pti on.
5 Cl i ck the Best Tree button to compute the best tr ee before compr essi ng the
i mage.
Two-Di mensi onal Wavelet Packet Analysi s
5-23
Compressing an image.
6 Cl i ck the Compress button to br i ng up the Wavelet Packet 2-D
Compression wi ndow.
Noti ce that the defaul t threshol d (7.25) pr ovi des about 64% compressi on
whi l e retai ni ng vi rtual l y al l the ener gy of the or i gi nal i mage. Dependi ng on
your cr i teri a, i t may be worthwhi l e exper i menti ng wi th mor e aggr essi ve
threshol ds to achi eve a hi gher degree of compressi on. Recal l that we are not
doi ng any quanti zati on of the i mage, merel y setti ng speci fi c coeffi ci ents to
zer o. Thi s can be consi dered a pr e-compressi on step i n a br oader
compr essi on system.
7 Al ter the thr eshol d: type the number 30 i n the text fi el d opposi te the
threshol d sl i der l ocated on the ri ght si de of the Wavelet Packet 2-D
Compression wi ndow. Then pr ess the Enter key.
5 Usi ng Wavelet Packets
5-24
Setti ng al l wavel et packet coeffi ci ents whose val ue fal l s bel ow 30 to zero
yi el ds much better resul ts. Note that the new threshol d achi eves a
compressi on rati o of better than 12:1, whi l e sti l l retai ni ng near l y 98% of the
i mage ener gy. Compare thi s wavel et packet anal ysi s to the wavel et anal ysi s
of the same i mage i n Compressi ng Si gnal s i n Chapter 3.
8 Cl i ck the Compress button to star t the compressi on.
You can see the resul t obtai ned by wavel et packet coeffi ci ents thr eshol di ng
and i mage r econstructi on. The vi sual recovery i s cor rect but not perfect. The
compressed i mage, shown si de-by-si de wi th the or i gi nal , shows some
arti facts.
9 Cl i ck the Close button l ocated at the bottom of the Wavelet Packet 2-D
Compression wi ndow. Update the synthesi zed i mage by cl i cki ng Yes when
the di al og box appear s.
Take thi s oppor tuni ty to try out your own compressi on strategy. Adjust the
threshol d val ue, the entropy functi on, and the wavel et, and see i f you can
obtai n better resul ts.
Hint: The bi or 6. 8 wavel et i s better sui ted to thi s anal ysi s than i s haar , and
can l ead to a compressi on rati o of 24:1.
Two-Di mensi onal Wavelet Packet Analysi s
5-25
Befor e concl udi ng thi s anal ysi s, i t i s worth turni ng our attenti on to the col or ed
coeffi ci ents for termi nal nodes pl ot and consi der i ng the best tr ee
decomposi ti on for thi s i mage.
Thi s pl ot i s shown i n the l ower ri ght si de of the Wavelet Packet 2-D tool . The
pl ot shows us whi ch detai l s have been decomposed and whi ch have not. Lar ger
squares r epr esent detai l s that have not been broken down to as many l evel s as
smal l er squares. Consi der, for exampl e, thi s l evel 2 decomposi ti on patter n:
Looki ng at the pattern of smal l and l ar ge squar es i n the fi nger pri nt anal ysi s
shows that the best tree al gori thm has appar entl y si ngl ed out the di agonal
detai l s, often spari ng these from further decomposi ti on. Why i s thi s?
I f we consi der the ori gi nal i mage, we real i ze that much of i ts i nfor mati on i s
concentrated i n the sharp edges that consti tute the fi nger pri nts pattern.
Looki ng at these edges, we see that they ar e pr edomi nantl y or i ented
hor i zontal l y and verti cal l y. Thi s expl ai ns why the best tr ee al gor i thm has
chosen not to decompose the di agonal detai l s they do not pr ovi de ver y
much i nfor mati on.
Approximation, Level 2
Vertical Detail, Level 2
Diagonal Detail, Level 1
Decomposition of the Level 1
Horizontal Detail
Decomposition of the Level 1
Vertical Detail
5 Usi ng Wavelet Packets
5-26
Importing and Exporting from Graphical Tools
The Wavelet Packet 1-D and Wavelet Packet 2-D tool s l et you i mport
i nfor mati on fr om and export i nformati on to your di sk.
I f you adher e to the proper fi l e formats, you can:
Save decomposi ti ons as wel l as synthesi zed si gnal s and i mages from the
wavel et packet gr aphi cal tool s i nto your di sk.
Load si gnal s, i mages, and one- and two-di mensi onal decomposi ti ons fr om
your di sk i nto the Wavelet Packet 1-D and Wavelet Packet 2-D gr aphi cal
tool s.
Saving Information to the Disk
The gr aphi cal tool s functi ons l et you save synthesi zed si gnal s or i mages, as
wel l as one- or two-di mensi onal wavel et packet decomposi ti on structures,
usi ng speci fi c fi l e for mats. Thi s featur e pr ovi des fl exi bi l i ty and al l ows you to
combi ne command l i ne and graphi cal i nterface operati ons.
Saving Synthesized Signals
You can process a si gnal i n the Wavelet Packet 1-D tool and then save the
pr ocessed si gnal to a MAT-fi l e.
For exampl e, l oad the demo anal ysi s: FileDemo Analysiswith db3 at
level 5 > Sum of sines, and perfor m a compressi on or de-noi si ng oper ati on
on the ori gi nal si gnal . When you cl ose the Wavelet Packet 1-D De-noising
or Wavelet Packet 1-D Compression wi ndow, update the synthesi zed si gnal
by cl i cki ng Yes i n the di al og box.
Then, from the Wavelet Packet 1-D tool , sel ect the FileSave Synthesized
Signal menu opti on.
A di al og box appears al l owi ng you to sel ect a di r ectory and fi l ename for the
MAT-fi l e. For thi s exampl e, choose the name s ynt hs i g.
To l oad the si gnal i nto your wor kspace, si mpl y type:
l oad s ynt hs i g
whos
Name Si z e El eme nt s By t e s Cl as s
s y nt hs i g 1 by 1000 1000 8000 doubl e ar r ay
Importi ng and Exporti ng from G raphi cal Tools
5-27
Saving Synthesized Images
You can process an i mage i n the Wavelet Packet 2-D tool and then save the
processed i mage to a MAT-fi l e.
For exampl e, l oad the demo anal ysi s FileDemo Analysisdb1 depth: 1
ent: shannon > woman, and per for m a compr essi on on the ori gi nal
i mage. When you cl ose the Wavelet Packet 2-D Compression wi ndow,
update the synthesi zed i mage by cl i cki ng Yes i n the di al og box that appears.
Then, fr om the Wavelet 2-D tool , sel ect the FileSave Synthesized Image
menu opti on.
A di al og box appear s al l owi ng you to sel ect a di rectory and fi l ename for the
MAT-fi l e. For thi s exampl e, choose the name wps ymage.
To l oad the i mage i nto your workspace, si mpl y type:
l oad wps y mage
whos
Saving One-Dimensional Decomposition Structures
The Wavelet Packet 1-D tool l ets you save an enti re wavel et packet
decomposi ti on tr ee and r el ated data to your di sk. The tool box creates a
MAT-fi l e i n the curr ent di rector y wi th a name you choose, fol l owed by the
extensi on wp1 (wavel et packet 1-D).
Open the Wavelet Packet 1-D tool and l oad the demo anal ysi s FileDemo
Analysisdb1 depth: 2 ent: shannon > sumsin.
To save the data fr om thi s anal ysi s, use the menu opti on FileSave
Decomposition.
A di al og box appear s that l ets you speci fy a di rectory and fi l e name for stori ng
the decomposi ti on data. Type the name wpde ce x.
Name Si z e El ement s Byt es Cl as s
map 255 by 3 765 6120 doubl e ar r ay
wps ymage 256 by 256 65536 524288 doubl e ar r ay
5 Usi ng Wavelet Packets
5-28
After savi ng the decomposi ti on data to the fi l e wpdec ex 1d. wp1, l oad the
vari abl es i nto your wor kspace.
l oad wpdec ex 1d. wp1 - mat
whos
Var i abl es t r e e_s t r uc t and dat a_s t r uct contai n the wavel et packet
decomposi ti on structur e (tree and data). The other vari abl e contai ns the data
name.
Saving Two-Dimensional Decomposition Structures
The fi l e format, var i abl es, and conventi ons are exactl y the same as i n the
one-di mensi onal case except for the extensi on, whi ch i s wp2 (wavel et packet
2-D). The vari abl es saved are the same as wi th the one-di mensi onal case, wi th
the addi ti on of the col ormap matri x map:
Loading Information into the Graphical Tools
You can l oad si gnal s, i mages, or one- and two-di mensi onal wavel et packet
decomposi ti ons i nto the gr aphi cal i nter face tool s. The i nfor mati on you l oad
may have been pr evi ousl y exported from the graphi cal i nterface and then
mani pul ated i n the wor kspace, or i t may have been i nformati on you generated
i ni ti al l y fr om the command l i ne.
I n ei ther case, you must obser ve the str i ct fi l e formats and data str uctur es used
by the graphi cal tool s, or el se err ors wi l l r esul t when you tr y to l oad
i nfor mati on.
Name Si z e El ement s Byt es Cl as s
dat a_name 1 by 6 6 48 doubl e ar r ay
dat a_s t r uc t 1 by 1057 1057 8456 doubl e ar r ay
t r ee _s t r uc t 2 by 5 3 80 doubl e ar r ay
Name Si z e El e me nt s Byt es Cl as s
dat a_name 1 by 5 5 40 doubl e ar r ay
dat a_s t r uc t 1 by 65590 65590 524720 doubl e ar r ay
map 255 by 3 765 6120 doubl e ar r ay
t r e e _s t r uc t 3 by 5 15 120 doubl e ar r ay
Importi ng and Exporti ng from G raphi cal Tools
5-29
Loading Signals
To l oad a si gnal youve constructed i n your MATLAB workspace i nto the
Wavelet Packet 1-D tool , save the si gnal i n a MAT-fi l e that has the same
name as the si gnal vari abl e i tsel f.
For i nstance, suppose youve desi gned a si gnal cal l ed war ma and want to
anal yze i t i n the Wavelet Packet 1-D tool .
l s ave war ma
The workspace vari abl e war ma must be a vector.
s i z war ma = s i z e( war ma)
s i z war ma =
1 1000
To l oad thi s si gnal i nto the Wavelet Packet 1-D tool , use the menu opti on
FileLoad Signal.
A di al og box appear s that l ets you sel ect the appr opri ate MAT-fi l e to be l oaded.
Loading Images
Thi s tool box suppor ts onl y indexed images. An i ndexed i mage i s a matr i x
contai ni ng onl y i nteger s fr om 1 to n, where n i s the number of col ors i n the
i mage.
Thi s i mage may opti onal l y be accompani ed by a n-by-3 matri x cal l ed map. Thi s
i s the col or map associ ated wi th the i mage. When MATLAB di spl ays such an
i mage, i t uses the val ues of the matr i x to l ook up the desi red col or i n thi s
col or map. I f the col or map i s not gi ven, the Wavelet Packet 2-D gr aphi cal tool
uses a monotoni c col or map wi th max ( max ( X) ) mi n( mi n( X) ) +1 col or s.
To l oad an i mage youve constructed i n your MATLAB workspace i nto the
Wavelet Packet 2-D tool , save the i mage (and opti onal l y, the var i abl e map) i n
a MAT-fi l e that has the same name as the i mage matri x i tsel f.
For i nstance, suppose youve cr eated an i mage cal l ed br ai n and want to
anal yze i t i n the Wavelet Packet 2-D tool . Type:
l s ave br ai n
To l oad thi s i mage i nto the Wavelet Packet 2-D tool , use the menu opti on
FileLoad Image.
5 Usi ng Wavelet Packets
5-30
A di al og box appear s that l ets you sel ect the appropri ate MAT-fi l e to be l oaded.
Caution: The graphi cal tool s al l ow you to l oad an i mage that does not contai n
i ntegers fr om 1 to n. The computati ons wi l l be cor rect si nce they act di r ectl y
on the matr i x, but the di spl ay of the i mage wi l l be strange. The val ues l ess
than 1 wi l l be eval uated as 1, the val ues greater than n wi l l be eval uated as n,
and a real val ue wi thi n the i nterval [ 1, n] wi l l be eval uated as the cl osest
i nteger.
Note that the coeffi ci ents, approxi mati ons, and detai l s produced by wavel et
packets decomposi ti on are not i ndexed i mage matr i ces.
I n order to di spl ay these i mages i n a sui tabl e way, the Wavelet Packet 2-D
tool fol l ows these rul es:
Reconstructed approxi mati ons ar e di spl ayed usi ng the col ormap map. The
same hol ds for the resul t of the reconstr ucti on of sel ected nodes.
The coeffi ci ents and the r econstructed detai l s ar e di spl ayed usi ng the
col ormap map appl i ed to a r escal ed ver si on of the matr i ces.
Loading Wavelet Packet Decomposition Structures
You can l oad one- and two-di mensi onal wavel et packet decomposi ti ons i nto the
gr aphi cal tool s pr ovi di ng you have pr evi ousl y saved the decomposi ti on data i n
a MAT-fi l e of the appropri ate format.
Whi l e i t i s possi bl e to edi t data or i gi nal l y created usi ng the graphi cal tool s and
then exported, you must be car eful about doi ng so. Wavel et packet data
structures ar e compl ex, and the gr aphi cal tool s do not do any consi stency
checki ng. Thi s can l ead to er rors i f you tr y to l oad i mproperl y for matted data.
One-di mensi onal data structur es must contai n the vari abl es:
Variable Description
dat a_name Stri ng speci fyi ng name of decomposi ti on
dat a_s t r uc t Vector speci fyi ng data i n tr ee str uctur e
t r e e_s t r uc t Vector speci fyi ng tr ee str uctur e
Importi ng and Exporti ng from G raphi cal Tools
5-31
These var i abl es must be saved i n a MAT-fi l e wi th the extensi on . wp1.
Two-di mensi onal data str uctur es must contai n the vari abl es:
These var i abl es must be saved i n a MAT-fi l e wi th the extensi on . wp2.
To l oad the properl y-for matted data, use the menu opti on FileLoad
Decomposition Structure from the appr opri ate tool , then sel ect the desi r ed
MAT-fi l e fr om the di al og box that appears.
The Wavelet Packet 1-D or 2-D gr aphi cal tool then automati cal l y updates i ts
di spl ay to show the new anal ysi s.
Variable Description
dat a_name Str i ng speci fyi ng name of decomposi ti on
dat a_s t r uct Vector speci fyi ng data i n tree str uctur e
map I mage map
t r e e_s t r uct Vector speci fyi ng tree str uctur e
5 Usi ng Wavelet Packets
5-32

6
Advanced Concepts
6-2 Mathematical Conventions
6-5 General Concepts
6-21 The Fast Wavelet Transform (FWT) Algorithm
6-34 One-Dimensional Wavelet Capabilities
6-40 Two-Dimensional Wavelet Capabilities
6-46 Dealing with Border Distortion
6-56 Frequently Asked Questions
6-62 Wavelet Families: Additional Discussion
6-73 Summary of Wavelet Families and Associated Properties
6-74 Wavelet Applications: More Detail
6-95 Wavelet Packets
6-114 References
6 Advanced C oncepts
6-2
Thi s chapter presents an al ternati ve and mor e advanced treatment of wavel et
methods. I t assumes that the reader i s comfor tabl e wi th mathemati cal i deas.
For more detai l on the theor y, the r eader i s di r ected to the book Wavelets and
Filter Banks by Str ang and Nguyen, and to the r efer ences at the end of thi s
Chapter.
Mathematical Conventions
Thi s chapter and the reference secti on use cer tai n mathemati cal conventi ons.
General Notation Interpretation
Dyadi c scal e. j i s the l evel , 1/a or 2
-j
i s the resol uti on
Dyadi c transl ati on
t Conti nuous ti me
k or n Di screte ti me
(i, j) Pi xel
s Si gnal or i mage. The si gnal i s a functi on defi ned on R
or Z, the i mage i s defi ned on R
2
or Z
2
. A fi ni te-l ength
si gnal i s extended to al l R, Z, R
2
or Z
2
usi ng zeros (thi s
i s zer o-paddi ng).
Four i er transform of the functi on f or the sequence f.
Conti nuous ti me
L
2
(R)
Set of si gnal s of fi ni te ener gy
Energy of the si gnal s
Scal ar product of si gnal s s and
L
2
(R
2
)
Set of i mages of fi ni te ener gy
Energy of the i mage s
Scalar product of images s and
a 2
j
= j Z ,
b ka = k Z ,
f

s x ( )
2
x d
R

s s , s x ( )s x ( )d
R

=
s
R
s x y , ( )
2
x d y d
R
s s , s x y , ( )s x y , ( ) x d y d
R

=
s
6-3
Discrete time
l
2
(Z)
Set of signals of finite energy
Energy of the signal s
Scal ar pr oduct of si gnal s s and
l
2
(Z
2
)
Set of i mages of fi ni te ener gy
Energy of the i mage s
Scal ar pr oduct of i mages s and
General Notation Interpretation
s n ( )
2
Z

s s , s n ( )s n ( )
Z

=
s
Z

s n m , ( )
2
Z

s s , s n m , ( )s n m , ( )
Z

=
s
Wavelet Notation Interpretation
A
j
j-l evel appr oxi mati on or appr oxi mati on at l evel j
D
j
j-l evel detai l or detai l at l evel j
f Scal e or scal i ng functi on
y Wavel et
Fami l y associ ated wi th the one-di mensi onal wavel et,
and .
Fami l y associ ated wi th the two-di mensi onal wavel et,
.
Fami l y associ ated wi th the one-di mensi onal scal e func-
ti on for dyadi c scal es a = 2
j
, b = ka.
I t shoul d be noted that =
0,0
.
1
a
-------
x b
a
-----------


a 0 > b R
1
a
1
a
2
---------------
x
1
b
1

a
1
----------------
x
2
b
2

a
2
---------------- ,


x x
1
x
2
( , ) = R
2
,
a
1
0 a
2
0 b
1
R b
2
R , , > , >

j k ,
x ( ) 2
j 2
2
j
x k ( ) = j Z k Z , ,
6 Advanced C oncepts
6-4
Fami l y associ ated wi th the one-di mensi onal for
dyadi c scal es a = 2
j
, b = ka.
I t shoul d be noted that =
0,0
.
Scal e or scal i ng fi l ter associ ated wi th a di screte
wavel et
Di screte wavel et
Wavelet Notation Interpretation

j k ,
x ( ) 2
j 2
2
j
x k ( ) = j Z k Z , ,
h
k
( ) k Z ,
g
k
( ) k Z ,
G eneral C oncepts
6-5
General Concepts
Thi s secti on presents a bri ef over vi ew of wavel et concepts.
Wavelets: A New Tool for Signal Analysis
Wavel et anal ysi s consi sts of decomposi ng a si gnal or an i mage i nto a
hi er archi cal set of appr oxi mati ons and detai l s. The l evel s i n the hi er ar chy often
cor respond to those i n a dyadi c scal e.
From the si gnal anal ysts poi nt of vi ew, wavel et anal ysi s i s a decomposi ti on of
the si gnal on a fami l y of anal yzi ng si gnal s, whi ch i s an or thogonal functi on
method. Fr om an al gori thmi c poi nt of vi ew, wavel et anal ysi s offers a
har moni ous compromi se between decomposi ti on and smoothi ng techni ques.
Wavelet Decomposition:
A Hierarchical Organization
Unl i ke conventi onal techni ques, wavel et decomposi ti on produces a fami l y of
hi er archi cal l y or gani zed decomposi ti ons The sel ecti on of a sui tabl e l evel for
the hi er archy wi l l depend on the si gnal and experi ence. Often the l evel i s
chosen based on a desi r ed l ow-pass cutoff frequency.
At each l evel j, we bui l d the j-l evel appr oxi mati on, A
j
, or appr oxi mati on at l evel
j, and a devi ati on si gnal cal l ed the j-l evel detai l , D
j
, or detai l at l evel j. The
ori gi nal si gnal we coul d consi der as the appr oxi mati on at l evel 0, denoted by
A
0
. The words approxi mati on and detai l are justi fi ed by the fact that A
1
i s
an appr oxi mati on of A
0
taki ng i nto account the l ow frequenci es of A
0
, wher eas
the detai l D
1
cor responds to the hi gh fr equency corr ecti on. The fi gur e on Page
1-23 gr aphi cal l y r epr esents thi s hi er archi cal decomposi ti on.
As outl i ned i n Chapter 1, one way of under standi ng thi s decomposi ti on consi sts
of usi ng an opti cal compari son. Successi ve i mages A
1
, A
2
, A
3
of a gi ven object ar e
bui l t. We use the same type of photogr aphi c devi ces, but wi th i ncreasi ngl y poor
resol uti on. The i mages are successi ve approxi mati ons; one detai l i s the
di screpancy between two successi ve i mages. I mage A
2
i s therefore the sum of
i mage A
4
and i nter medi ate detai l s D
4
, D
3
:
A
2
A
3
D
3
A
4
D
4
D
3
+ + = + =
6 Advanced C oncepts
6-6
Finer and Coarser Resolutions
The organi zi ng parameter , the scal e a, i s r el ated to l evel j, by . I f we
defi ne resol uti on as 1/a, then the r esol uti on i ncr eases as the scal e decr eases.
The gr eater the resol uti on, the smal l er and fi ner are the detai l s that can be
accessed.
From a techni cal poi nt of vi ew, the si ze of the reveal ed detai l s for any j i s
pr opor ti onal to the si ze of the domai n i n whi ch the wavel et or anal yzi ng
functi on of the var i abl e x, , i s not too cl ose to 0. The pr opor ti onal i ty
coeffi ci ent depends on the wavel et.
Wavelet Shapes
One-di mensi onal anal ysi s i s based on one scal i ng functi on and one wavel et .
Two-di mensi onal anal ysi s (on a square or rectangul ar gri d) i s based on one
scal i ng functi on and three wavel ets.
Fi gure 6-1 shows and for each wavel et, except the Morl et wavel et and the
Mexi can hat for whi ch does not exi st. Al l the functi ons decay qui ckl y to zero.
The Haar wavel et i s the onl y nonconti nuous functi on wi th thr ee poi nts of
di sconti nui ty (0, 0.5, 1). The functi ons osci l l ate mor e than associ ated
functi ons. c oi f 2 exhi bi ts some angul ar poi nts, db6 and s ym6 ar e qui te smooth.
The Morl et and Mexi can hat wavel ets are symmetr i cal .
j 10 9 ... 2 1 0 -1 -2
Scale 1024 512 ... 4 2 1 1/2 1/4
Resolution 1/2
10
1/2
9
... 1/4 1/2 1 2 4
a 2
j
=

x
a
---


x
1
x
2
, ( )
G eneral C oncepts
6-7
Figure 6-1: Various One-Dimensional Wavelets
4 2 0 2
0.5
0
0.5
Morlet wavelet function
5 0 5
0.2
0
0.2
0.4
0.6
0.8
Mexican hat wavelet function
5 0 5
0.5
0
0.5
1
Meyer scaling function
5 0 5
0.5
0
0.5
1
Meyer wavelet function
0 0.5 1
1
0.5
0
0.5
1
Haar scaling function
0 0.5 1
1
0.5
0
0.5
1
Haar wavelet function
0 5 10
1
0.5
0
0.5
1
db6 scaling function
0 5 10
1
0.5
0
0.5
1
db6 wavelet function
0 5 10
1
0.5
0
0.5
1
1.5
coif2 scaling function
0 5 10
1
0.5
0
0.5
1
1.5
coif2 wavelet function
0 5 10
1
0.5
0
0.5
1
1.5
sym6 scaling function
0 5 10
1
0.5
0
0.5
1
1.5
sym6 wavelet function
6 Advanced C oncepts
6-8
Wavelets and Associated Families
I n the one-di mensi onal context, we di sti ngui sh the wavel et fr om the
associ ated functi on , cal l ed the scal i ng functi on. Some properti es of the and
are:
The i ntegr al of i s zero, , and i s used to defi ne the detai l s.
The i ntegr al of i s 1, , and i s used to defi ne the
approxi mati ons.
The usual two-di mensi onal wavel ets are defi ned as tensor products of
one-di mensi onal wavel ets: (x,y) = (x)(y) i s the scal i ng functi on and

1
(x,y) = (x)(y),
2
(x,y) = (x)(y),
3
(x,y) = (x)(y) are the three wavel ets.
Fi gure 6-2 shows the four functi ons associ ated wi th the two-di mensi onal coi f 2
wavel et.
x ( ) x d

0 = ( )
x ( ) x d

1 = ( )
G eneral C oncepts
6-9
Figure 6-2: Two-Dimensional coif2 Wavelet
6 Advanced C oncepts
6-10
To each of these functi ons, we associ ate i ts doubl y i ndexed fami l y, whi ch i s
used to:
Move the shape, transl ati ng i t to posi ti on b (see Fi gure 6-3).
Keep the shape whi l e changi ng the one-di mensi onal ti me scal e a ( ), see
Fi gur e 6-4.
So a wavel et has to be thought as a functi on l ocated at a posi ti on b, and havi ng
a scal e a.
I n one-di mensi onal si tuati ons, the fami l y of transl ated and scal ed wavel ets
associ ated wi th i s expressed as:
Figure 6-3: Translated Wavelets
Wavel et db3(x) i s i n the mi ddl e, db3(x + 8) on the l eft, db3(x-8) on the ri ght.
Translation Change of scale Translation and change of scale
(x-b)
a 0 >
1
a
-------
x
a
---


1
a
-------
x b
a
-----------


10 5 0 5 10 15
1.5
1
0.5
0
0.5
1
1.5
2
G eneral C oncepts
6-11
Figure 6-4: Time scaled one-dimensional wavelet
Wavel et db3(x) i s i n the mi ddl e, db3(2x + 7) on the l eft, db3(x/2 - 7) on the r i ght.
I n a two-di mensi onal context, we have the tr ansl ati on by vector and a
change of scal e of par ameter .
Transl ati on and change of scal e become: where
.
I n most cases, we wi l l l i mi t our choi ce of a and b val ues by usi ng onl y the
fol l owi ng di scr ete set (comi ng back to the one-di mensi onal context):
What i s more, l et us defi ne:
We now have a hi erarchi cal or gani zati on si mi l ar to the or gani zati on of a
decomposi ti on, whi ch i s r epr esented i n the exampl e of the Fi gure 6-5. Let
k = 0 and l eave the tr ansl ati ons asi de for the moment. The functi ons (expressed
as
j,0
) associ ated wi th j = 0, 1, 2, 3 for and wi th j = 1, 2, 3 for (expr essed as

j,0
) ar e di spl ayed i n Fi gure 6-5 for the db3 wavel et.
10 5 0 5 10 15 20
1.5
1
0.5
0
0.5
1
1.5
2
b
1
b
2
[ , ]
a
1
a
2
[ , ]
1
a
1
a
2
---------------
x
1
b
1

a
1
----------------
x
2
b
2

a
2
---------------- ,


x x
1
x
2
( , ) R
2
=
j k ( , ) Z
2
: a 2
j
, = b k2
j
ka. = =
j k ( , ) Z
2
:
j k ,
2
j 2
2
j
x k ( )
j k ,
2
j 2
2
j
x k ( ). = , =
6 Advanced C oncepts
6-12
Figure 6-5: Wavelets Organization
0 20 40
1
0
1
2
phi(x)
0 20 40
1
0
1
2
phi(x/2)
0 20 40
1
0
1
2
phi(x/4)
0 20 40
1
0
1
2
psi(x/2)
0 20 40
1
0
1
2
psi(x/4)
0 20 40
1
0
1
2
phi(x/8)
0 20 40
1
0
1
2
psi(x/8)
G eneral C oncepts
6-13
I n Fi gur e 6-5, the four l evel decomposi ti on i s shown, progr essi ng fr om the top
to the bottom, we fi nd
0,0
, then 2
1/2

1,0
, 2
1/2

1,0
then 2
2,0
, 2
2,0
then
2
3/2

3,0
, 2
3/2

3,0
. The wavel et i s db3.
Wavelets on a Regular Discrete Grid
To compl ement the wavel ets i ntroduced pr evi ousl y, we use wavel ets defi ned on
gr i ds, when the si gnal i s sampl ed on a r egul ar gr i d. The si mpl est of these
wavel ets i s deduced fr om wavel ets capabl e of anal yzi ng the si gnal s that are
recorded conti nuousl y. Fi gur e 6-6 shows some of these wavel ets
(non-normal i zed).
Figure 6-6: Discrete wavelets
0 1
0.6
0.4
0.2
0
0.2
0.4
0.6
Haar scaling filter
0 1
0.6
0.4
0.2
0
0.2
0.4
0.6
Haar wavelet filter
0 2 4 6 8 10
0.6
0.4
0.2
0
0.2
0.4
0.6
db6 scaling filter
0 2 4 6 8 10
0.6
0.4
0.2
0
0.2
0.4
0.6
db6 wavelet filter
0 2 4 6 8 10
0.6
0.4
0.2
0
0.2
0.4
0.6
sym6 scaling filter
0 2 4 6 8 10
0.6
0.4
0.2
0
0.2
0.4
0.6
sym6 wavelet filter
0 2 4 6 8 10
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
coif2 scaling filter
0 2 4 6 8 10
0.8
0.6
0.4
0.2
0
0.2
0.4
0.6
0.8
coif2 wavelet filter
6 Advanced C oncepts
6-14
The wavel et fi l ter g, pl ays the rol e of . The scal i ng fi l ter h pl ays the rol e of .
They ar e defi ned on a r egul ar gr i d Z, where i s the sampl i ng per i od. Let us
set = 1. Li ke the previ ous wavel ets, functi ons g and h ar e subjected to scal i ngs
and tr ansl ati ons.
Usi ng a functi on g defi ned on Z and a scal e equal to 2
j
, for and , we
defi ne the functi on g
j,k
by:
Wavelet Transforms: Continuous and Discrete
The wavel et transform of a si gnal s i s the fami l y C(a,b), whi ch depends on two
i ndi ces a and b. The set to whi ch a and b bel ong i s gi ven bel ow i n the tabl e. The
studi es focus on three ki nds of si gnal s:
Conti nuous ti me si gnal , recor ded conti nuousl y
Sampl ed si gnal
Di scr ete ti me si gnal recor ded i n di screte ti me
and two transforms:
Conti nuous transform
Di scr ete tr ansfor m.
From an i ntui ti ve poi nt of vi ew, the wavel et decomposi ti on consi sts of
cal cul ati ng a resembl ance i ndex between the si gnal and the wavel et. I f the
i ndex i s l arge, the r esembl ance i s str ong, otherwi se i t i s sl i ght. The i ndexes
C(a,b) are cal l ed coeffi ci ents.
j N k N
n Z , g
j k ,
n ( ) 2
j 2
g 2
j
n k ( ) =
G eneral C oncepts
6-15
We defi ne the coeffi ci ents i n the fol l owi ng tabl es. We have three types of
anal ysi s at our di sposal .
Let us i l l ustrate the di fferences between the two tr ansfor ms, for the anal ysi s
of a fractal si gnal (see Fi gur e 6-7).
Figure 6-7: Continuous versus discrete transform
Continuous time
continuous analysis
Continuous time
discrete analysis
Discrete time ( = 1)
discrete analysis
C a b , ( ) s t ( )
1
a
-------
t b
a
----------


t d
R

=
C a b , ( ) s t ( )
1
a
-------
t b
a
----------


t d
R

= C a b , ( ) C j k , ( ) s n ( )g
j k ,
n ( )
n Z

= =
a R
+
0 { } b R , a 2
j
= b k2
j
= j k ( , ) Z
2
, , a 2
j
= b k2
j
= j N k Z , , ,
0 100 200 300 400 500
0
0.005
0.01
0.015
0.02
Analyzed signal.
Discrete Transform, absolute coefficients.
l
e
v
e
l
100 200 300 400 500
Continuous Transform, absolute coefficients.
S
c
a
l
e
100 200 300 400 500
6 Advanced C oncepts
6-16
Usi ng a redundant repr esentati on cl ose to the so-cal l ed conti nuous anal ysi s,
i nstead of a non-r edundant di scr ete ti me-scal e r epresentati on, can be useful for
anal ysi s purposes. The non-redundant r epresentati on i s associ ated wi th an
orthonor mal basi s, wher eas the redundant r epr esentati on uses much more
scal e and posi ti on parameters than a basi s. For a cl assi cal fractal si gnal , the
r edundant methods are qui te accurate.
Graphic representation of continuous analysis: ti me i s on the absci ssa
and on the ordi nate the scal e var i es al most conti nuousl y between 2
1
and 2
5

by step 1 (down to up). Keep i n mi nd that when a scal e i s smal l , onl y smal l
detai l s ar e anal yzed, as i n a geogr aphi cal map.
Graphic representation of discrete analysis: (i n the mi ddl e of the
fi gure) ti me i s on the absci ssa and on the or di nate the scal e a i s dyadi c: 2
1
,
2
2
, 2
3
, 2
4
and 2
5
(down to up). Each coeffi ci ent of l evel k i s repeated 2
k
ti mes.
Local and Global Analysis
A smal l scal e val ue permi ts us to per for m a l ocal anal ysi s; a l ar ge scal e val ue
i s used for a gl obal anal ysi s. Combi ni ng l ocal and gl obal i s a useful feature of
the method. Let us be a bi t more preci se about the l ocal par t and gl ance at the
frequency domai n counterpar t.
I magi ne that the anal yzi ng functi on or i s zer o outsi de of a domai n U, whi ch
i s contai ned i n a di sk of radi us : . The wavel et i s l ocal i zed.
The si gnal s and the functi on ar e then compar ed i n the di sk, taki ng i nto
account onl y the x val ues i n the di sk. The si gnal val ues, whi ch are l ocated
outsi de of thi s domai n, do not i nfl uence the val ue of the coeffi ci ent
. The same argument hol ds when i s tr ansl ated to posi ti on b and
the cor respondi ng coeffi ci ent anal yzes s around b. So thi s anal ysi s i s l ocal .
The wavel ets havi ng a compact support ar e used i n l ocal anal ysi s. Thi s i s the
case for Haar and Daubechi es wavel ets, for exampl e. The wavel ets whose
val ues ar e consi dered as very smal l outsi de a domai n U can be used wi th
cauti on, as i f they were i n fact actual l y zero outsi de U. Not ever y wavel et has a
compact suppor t. Thi s i s the case, for i nstance, of the Meyer wavel et.
u ( ) = 0, u U
s t ( ) t ( ) t d
R

G eneral C oncepts
6-17
The pr evi ous l ocal i zati on i s tempor al , and i s useful i n anal yzi ng a tempor al
si gnal (or spati al si gnal i f anal yzi ng an i mage). A resul t (l i nked to the
Hei senber g uncertai nty pr i nci pl e) l i nks the si gnal di sper si on f and the
di spersi on of i ts Four i er transform , and therefore of the di spersi on of
and . The product of these di sper si ons i s al ways greater than a constant c
(whi ch does not depend on the si gnal , but onl y on the di mensi on of the space).
So, i t i s i mpossi bl e to reduce ar bi tr ar i l y both ti me and frequency l ocal i zati on.
I n the Fouri er and spectr al anal ysi s, the basi c functi on i s .
Thi s functi on i s not a l ocal i zed functi on. The suppor t i s R. I ts Fouri er
tr ansfor m i s a di stri buti on concentr ated at poi nt . The functi on f i s very
poor l y l ocal i zed i n ti me, but i s per fectl y l ocal i zed i n fr equency. The wavel ets
gener ate an i nter esti ng compr omi se on the supports, and thi s compromi se
di ffer s from that of compl ex exponenti al s, si ne, or cosi ne.
Synthesis: An Inverse Transform
I n order to be effi ci ent and useful , a method desi gned for anal ysi s al so has to
be abl e to perform synthesi s. The wavel et method achi eves thi s.
The anal ysi s starts fr om s and resul ts i n the coeffi ci ents C(a,b). The synthesi s
starts from the coeffi ci ents C(a,b) and reconstr ucts s. Synthesi s i s the reci pr ocal
oper ati on of anal ysi s.
For si gnal s of fi ni te ener gy, ther e ar e two formul as to per for m the i nver se
wavel et transform:
Conti nuous synthesi s:
where i s a constant dependi ng on .
Di screte synthesi s:
f

f x ( ) exp ix ( ) =
f

s t ( )
1
K

-------
R
+
C a b , ( )
1
a
-------
t b
a
----------



da db
a
2
----------------
R

=
K

s t ( ) C j k , ( )
j k ,
t ( ).
k Z

j Z

=
6 Advanced C oncepts
6-18
Details and Approximations
The equati ons for conti nuous and di screte synthesi s ar e of consi der abl e
i nterest and can be r ead i n or der to defi ne the detai l at l evel j:
1 Let us fi x j and sum on k. A detai l i s nothi ng more than the functi on
2 Now l et us sum on j. The si gnal i s the sum of al l the detai l s: .
The detai l s have just been defi ned. Take a reference l evel cal l ed J. Ther e ar e
two sorts of detai l s. Those associ ated wi th i ndi ces correspond to the scal es
whi ch ar e the fi ne detai l s. The others, whi ch corr espond to j > J, are
the coarser detai l s. We group these l atter detai l s i nto
whi ch defi nes what i s cal l ed an approxi mati on of the si gnal s. We have just
created the detai l s and an appr oxi mati on. They are connected. The equal i ty
si gni fi es that s i s the sum of i ts appr oxi mati on A
J
and of i ts fi ne detai l s. Fr om
the pr evi ous formul a, i t i s obvi ous that the appr oxi mati ons are rel ated to one
another by:
The cal cul ati on of the appr oxi mati on coeffi ci ents wi l l be di scussed l ater.
D
j
D
j
t ( ) C j k ( , )
j k ,
t ( ).
k Z

=
s D
j
j Z

=
j J
a 2
j
2
J
=
A
J
D
j
j J >

=
s A
J
D
j
j J

+ =
A
J 1
A
J
D
J
. + =
G eneral C oncepts
6-19
For an orthogonal anal ysi s, i n whi ch the
j,k
i s an or thonormal fami l y,
A
J
i s or thogonal to D
J
, D
J -1
, D
J -2
, ...,
s i s the sum of the two orthogonal si gnal s: A
J
and ,
.
the qual i ty (i n energy) of the approxi mati on of s by A
J
i s ,
.
The fol l owi ng tabl e contai ns defi ni ti ons of detai l s and approxi mati ons.
From a graphi cal poi nt of vi ew, when anal yzi ng a si gnal , i t i s al ways val uabl e
to r epresent the di fferent si gnal s and coeffi ci ents.
Defi ni ti on of the detai l at l evel j
The si gnal i s the sum of i ts detai l s
The appr oxi mati on at l evel J
Li nk between A
J -1
and A
J

A
J-1
= A
J
+ D
J
Several decomposi ti ons
D
j
j J

D
j
D
k
for j k
qual
J
A
J
2
s
2
------------- =
qual
J 1
qual
J
D
J
2
s
2
------------- - + =
D
j
t ( ) C j k ( , )
j k ,
t ( )
k Z

=
s D
j
j Z

=
A
J
D
j
j J >

=
s A
J
D
j
j J

+ =
6 Advanced C oncepts
6-20
Let us consi der the Fi gure 6-8. The di fferent si gnal s that ar e presented exi st i n
the same ti me gr i d. We can consi der that the t i ndex of detai l D
4
(t), for exampl e,
that of an appr oxi mati on A
5
(t) and that of the si gnal s(t), i denti fy the same
temporal i nstant. Thi s i denti ty i s of consi der abl e practi cal i nterest i n
understandi ng the composi ti on of the si gnal , even i f the wavel et someti mes
i ntroduces dephasi ng.
Figure 6-8: Approximations, details and coefficients
200
400
s
200
300
400
500
a4
200
300
400
500
a3
200
300
400
500
a2
1000 2000 3000 4000
200
300
400
500
a1
20
0
20
40
d4
10
0
10
20
d3
10
0
10
20
d2
1000 2000 3000 4000
20
0
20
d1
200
300
400
500
a5
20
0
20
d5
200
300
400
500
s
Signal and Approximation(s)
cfs
Signal and Detail(s)
1
2
3
4
5
The Fast W avelet Transform (FWT) Algori thm
6-21
The Fast Wavelet Transform (FWT) Algorithm
I n 1988, Mal l at pr oduced a fast wavel et decomposi ti on and r econstructi on
al gor i thm [Mal 89]. The Mal l at al gor i thm for di scr ete wavel et tr ansfor m (DWT)
i s, i n fact, a cl assi cal scheme i n the si gnal processi ng communi ty, known as a
two channel subband coder usi ng conjugate quadr atur e fi l ter s or quadr ature
mi r ror fi l ter s (QMF).
The decomposi ti on al gori thm star ts wi th si gnal s, then cal cul ates the
coordi nates of A
1
and D
1
, then those of A
2
and D
2
and so on.
The r econstructi on al gori thm cal l ed the i nverse di screte wavel et tr ansfor m
(I DWT), starts fr om the coordi nates of A
J
and D
J
then cal cul ates the
coordi nates of A
J -1
, then fr om the coordi nates of A
J -1
and D
J -1
cal cul ates those
of A
J -2
and so on.
Filters Used to Calculate the DWT and IDWT
For an orthogonal wavel et, i n the mul ti r esol uti on fr amework (see [Dau92]
chap. 5), we start wi th the scal i ng functi on and the wavel et functi on . One
of the fundamental r el ati ons i s the twi n-scal e rel ati on (di l ati on equati on or
refi nement equati on):
Al l the fi l ters used i n DWT and I DWT are i nti matel y rel ated to the sequence
. Cl ear l y i f i s compactl y supported, the sequence (w
n
) i s fi ni te and can
be vi ewed as a fi l ter . The fi l ter W, whi ch i s cal l ed the scal i ng fi l ter
(non-normal i zed), i s:
Fi ni te I mpul se Response (FI R)
of l ength 2N
of sum 1
of nor m
a l ow-pass fi l ter
1
2
---
x
2
---


w
n
x n ( ).
n Z

=
w
n
( )
n Z
1
2
-------
6 Advanced C oncepts
6-22
For exampl e, for the db3 scal i ng fi l ter:
l oad db3
db3
db3 =
0. 2352 0. 5706 0. 3252 - 0. 0955 - 0. 0604 0. 0249
s um( db3)
ans =
1. 0000
nor m( db3)
ans =
0. 7071
From fi l ter W, we defi ne four FI R fi l ters, of l ength 2N and of nor m 1, organi zed
as fol l ows:
The four fi l ter s are computed usi ng the fol l owi ng scheme:
Filters Low-pass High-pass
Decomposi ti on LoF_D Hi F_D
Reconstructi on LoF_R Hi F_R
LoF_R =
norm(W)

LoF_D = wr ev (LoF_R)
Hi F_D = wr e v(Hi F_R)
W
W
Hi F_R = qmf (LoF_R)
The Fast W avelet Transform (FWT) Algori thm
6-23
where qmf i s such that Hi F_R and LoF_R are quadr atur e mi r ror fi l ter s (i .e.,
Hi F_R(k) = (-1)
k
LoF_R(2N - 1 - k)). Note that wr ev fl i ps the fi l ter coeffi ci ents. So
Hi F_D an LoF_D are al so quadr atur e mi rr or fi l ter s. The computati on of these
fi l ters i s perfor med usi ng or t hf i l t . Let us i l l ustr ate these pr oper ti es wi th the
db6 wavel et. The pl ots associ ated wi th the fol l owi ng M-fi l e ar e shown i n the
Fi gure 6-9.
% Load s c al i ng f i l t e r .
l oad db6; w = db6;
s ubpl ot ( 421) ; s t em( w) ; t i t l e( ' Or i gi nal s cal i ng f i l t er ) ;
% Comput e t he f our f i l t er s .
[ LoF_D, Hi F_D, LoF_R, Hi F_R] = or t hf i l t ( w) ;
s ubpl ot ( 423) ; s t em( LoF_D) ;
t i t l e ( ' De compos i t i on l ow- pas s f i l t e r ) ;
s ubpl ot ( 424) ; s t em( Hi F_D) ;
t i t l e ( ' De compos i t i on hi gh- pas s f i l t e r ) ;
s ubpl ot ( 425) ; s t em( LoF_R) ;
t i t l e ( ' Re cons t r uct i on l ow- pas s f i l t e r ) ;
s ubpl ot ( 426) ; s t em( Hi F_R) ;
t i t l e ( ' Re cons t r uct i on hi gh- pas s f i l t er ) ;
% Hi gh and l ow f r e quenc y i l l us t r at i on.
f f t l d = f f t ( LoF_D) ; f f t hd = f f t ( Hi F_D) ;
f r e q = [ 1: l e ngt h( LoF_D) ] /l e ngt h( LoF_D) ;
s ubpl ot ( 427) ; pl ot ( f r e q, abs ( f f t l d) ) ;
t i t l e ( ' Tr ans f e r modul us : l ow- pas s )
s ubpl ot ( 428) ; pl ot ( f r e q, abs ( f f t hd) ) ;
t i t l e ( ' Tr ans f e r modul us : hi gh- pas s )
6 Advanced C oncepts
6-24
Figure 6-9: The four wavelet filters
Algorithms
Gi ven a si gnal s of l ength N, the DWT consi sts of l og
2
N stages at most. The
fi rst step produces, starti ng fr om s, two sets of coeffi ci ents: appr oxi mati on
coeffi ci ents cA
1
and detai l coeffi ci ents cD
1
. These vectors ar e obtai ned by
convol vi ng s wi th the l ow-pass fi l ter LoF_D for appr oxi mati on, and wi th the
hi gh-pass fi l ter Hi F_D for detai l , fol l owed by dyadi c deci mati on.
0 5 10 15
1
0.5
0
0.5
1
Original scaling filter
0 5 10 15
1
0.5
0
0.5
1
Decomposition lowpass filter
0 5 10 15
1
0.5
0
0.5
1
Decomposition highpass filter
0 5 10 15
1
0.5
0
0.5
1
Reconstruction lowpass filter
0 5 10 15
1
0.5
0
0.5
1
Reconstruction highpass filter
0 0.2 0.4 0.6 0.8 1
0
0.5
1
1.5
Transfer modulus: lowpass
0 0.2 0.4 0.6 0.8 1
0
0.5
1
1.5
Transfer modulus: highpass
The Fast W avelet Transform (FWT) Algori thm
6-25
Mor e preci sel y, the fi rst step i s:
The l ength of each fi l ter i s equal to 2N. I f n = l ength(s), the si gnal s F and G, are
of l ength n + 2N - 1 and then the coeffi ci ents cA
1
and cD
1
are of l ength
.
The next step spl i ts the appr oxi mati on coeffi ci ents cA
1
i n two par ts usi ng the
same scheme, repl aci ng s by cA
1
, and pr oduci ng cA
2
and cD
2
, and so on.
So the wavel et decomposi ti on of the si gnal s anal yzed at l evel j has the
fol l owi ng str uctur e: [cA
j
, cD
j
, ..., cD
1
].
s
LoF_D
HiF_D
high-pass filter
F
G
downsample
downsample
approximation
cA
1
cD
1
2
detail
low-pass filter
2
where:
2
X Convolve with filter X.
Keep the even indexed elements
(see dyaddown).
coefficients
coefficients
floor
n 1
2
----------- -


N +
One-Dimensional DWT
Decomposition step
LoF_D
HiF_D
cA
j
2
Initialization
Convolve with filter X.
Downsample.
cA
0
= s.
where
2
2
X
cA
j+1
cD
j+1
level j+1
level j
6 Advanced C oncepts
6-26
Thi s str uctur e contai ns for J=3, the ter mi nal nodes of the fol l owi ng tr ee:
Conver sel y, star ti ng fr om cA
j
and cD
j
, the I DWT reconstr ucts cA
j-1
, i nverti ng
the decomposi ti on step by i nserti ng zeros and convol vi ng the resul ts wi th the
reconstr ucti on fi l ters.
s
cD
1
cD
2
cD
3 cA
3
cA
j-1
LoF_R
HiF_R
high-pass
U
upsample
upsample
cA
j
cD
j
2
level j
low-pass
where:
2
X Convolve with filter X.
Insert zeros at odd-indexed elements.
Take the central part of U with the
2
wkeep
wkeep
convenient length.
level j-1
One-Dimensional IDWT
Reconstruction step
The Fast W avelet Transform (FWT) Algori thm
6-27
For i mages, a si mi l ar al gor i thm i s possi bl e for two-di mensi onal wavel ets and
scal i ng functi ons obtai ned from one-di mensi onal wavel ets by tensori al
pr oduct.
Thi s ki nd of two-di mensi onal DWT l eads to a decomposi ti on of
appr oxi mati on coeffi ci ents at l evel j i n four components: the appr oxi mati on
at l evel j + 1 and the detai l s i n three or i entati ons (hor i zontal , verti cal , and
di agonal ).
The fol l owi ng charts descri be the basi c decomposi ti on and r econstructi on
steps for i mages:
Two-Dimensional DWT
Decomposition step
rows
Lo_D
Hi_D
rows
cA
j
2 1
columns
Initialization
Downsample columns: keep the even indexed columns.
Downsample rows: keep the even indexed rows.
Convolve with filter X the rows of the entry.
Convolve with filter X the columns of the entry.
CA
0
= s for the decomposition initialization.
Where:
2 1
2 1
2 1
2 1
2 1
2 1
2 1
X
columns
Hi_D
Lo_D
X
columns
columns
Hi_D
Lo_D
cA
j+1
cD
j+1
cD
j+1
cD
j+1
(h)
(v)
(d)
horizontal
vertical
diagonal
columns
rows
6 Advanced C oncepts
6-28
Two-Dimensional IDWT
Reconstruction step
cA
j
rows
Upsample columns: insert zeros at odd-indexed columns.
Upsample rows: insert zeros at odd-indexed rows.
Convolve with filter X the rows of the entry.
Convolve with filter X the columns of the entry.
Where:
1 2
1 2
1 2
1 2
2 1
2 1
X
rows
Hi_R
Lo_R
X
rows
rows
Hi_R
Lo_R
cA
j+1
cD
j+1
cD
j+1
cD
j+1
(h)
(v)
(d)
horizontal
vertical
diagonal
columns
rows
columns
Lo_R
Hi_R
columns
1 2
1 2
wkeep
The Fast W avelet Transform (FWT) Algori thm
6-29
So, for J = 2, the two-di mensi onal wavel et tree has the form:
Fi nal l y, l et us menti on that, for bi orthogonal wavel ets, the same al gori thms
hol d but the decomposi ti on fi l ters on one hand and the r econstr ucti on fi l ter s on
the other hand ar e obtai ned from two di sti nct scal i ng functi ons associ ated wi th
two mul ti resol uti on anal yses i n dual i ty.
I n thi s case, the fi l ter s for decomposi ti on and r econstructi on ar e, i n gener al , of
di ffer ent odd l engths. Thi s si tuati on occurs, for exampl e, for spl i nes
bi orthogonal wavel ets used i n the tool box. By zer o-paddi ng, the four fi l ter s can
be extended i n such a way that they wi l l have the same even l ength.
Why Does Such an Algorithm Exist?
Let us denote h = LoF_R and g = Hi F_R and focus on the one-di mensi onal case.
We fi r st justi fy how to go from l evel j to l evel j+1, for the approxi mati on vector.
Thi s i s the mai n step of the decomposi ti on al gor i thm for the computati on of the
approxi mati ons. The detai l s are cal cul ated i n the same way usi ng the fi l ter g
i nstead of fi l ter h.
Let be the coor di nates of the vector A
j
:
cD
(h)
1
cD
(d)
1
cD
(v)
1
cA
2
cD
(h)
2
cD
(d)
2
cD
(v)
2
s
A
k
j ( )
( )
k Z
A
j
A
k
j ( )

j k ,
k

=
6 Advanced C oncepts
6-30

and the coor di nates of the vector A
j+1
:
i s cal cul ated usi ng the for mul a:
Thi s for mul a resembl es a convol uti on for mul a.
The computati on i s ver y si mpl e. Let us defi ne , and
We obtai n:
We have to take the even i ndex val ues of F. Thi s i s downsampl i ng.
The i ni ti al i zati on i s car ri ed out usi ng where s(k) i s the si gnal val ue
at ti me k.
Ther e ar e sever al reasons for thi s surpr i si ng resul t, al l of whi ch are l i nked to
the mul ti resol uti on si tuati on and to a few of the properti es of the functi ons
j,k

and
j,k
.
A
k
j 1 + ( )
A
j 1 +
A
k
j 1 + ( )

j 1 + k ,
k

=
A
k
j 1 + ( )
A
k
j 1 + ( )
h
n 2k
A
n
j ( )
n

=
h

k ( ) h k ( ) =
F
k
j 1 + ( )
h

k n
A
n
j ( )
n

=
A
k
j 1 + ( )
F
2k
j 1 + ( )
=
A
k
0 ( )
s k ( ) =
The Fast W avelet Transform (FWT) Algori thm
6-31
Let us now descr i be some of them.
1 The fami l y i s formed of orthonormal functi ons. As a conse-
quence for any j, the fami l y i s orthonormal .
2 The doubl e i ndexed fami l y i s or thonormal .
3 For any j, the ar e orthogonal to
4 Between two successi ve scal es, we have a fundamental rel ati on, cal l ed the
twi n-scal e rel ati on:
Twin-scale relation for

0 k ,
k Z , ( )

j k ,
k Z , ( )

j k ,
j Z k Z , , ( )

j k ,
k Z , ( )
j k ,
j j k Z , , ( )

1 0 ,
h
k

0 k ,
k Z

=
j 1 + 0 ,
h
k

j k ,
k Z

=
6 Advanced C oncepts
6-32
Thi s r el ati on i ntroduces the al gor i thms h fi l ter ( ), see the secti on
Fi l ter s Used to Cal cul ate the DWT and I DWT on page 6-21).
5 We check that:
a. the coor di nate of on
j,k
i s and does not depend on j,
b. the coordi nate of on
j,k
i s equal to: .
6 These r el ati ons suppl y the i ngredi ents for the al gori thm.
7 Up to now we used the fi l ter h. The hi gh-pass fi l ter g i s used i n the twi n
scal es rel ati on l i nki ng the and functi ons. Between two successi ve scal es,
we have the fol l owi ng twi n-scal e fundamental rel ati on.
8 We justi fy now the r econstructi on al gori thm by bui l di ng i t. Let us si mpl i fy
the notati on, star ti ng from A
1
and D
1
, l et us study A
0
= A
1
+ D
1
. The
pr ocedur e i s the same to cal cul ate A
j
= A
j+1
+ D
j+1
.
Let us defi ne
n
,
n
, by:
Let us assess the coordi nates as:
We wi l l focus our study on the fi r st sum ; the second sum
Twin-scale relation between and
h
n
2w
n
=

j 1 + 0 ,
h
k

j 1 + n ,

j 1 + n ,

j k ,
, h
k 2n
=

1 0 ,
g
k

0 k ,
k Z

=
j 1 + 0 ,
g
k

j k ,
k Z

k
0
A
1

n

1 n ,
n

= , D
1

n

1 n ,
n

= , A
0

k
0

0 k ,
k

= ,

k
0

k
0
A
0

0 k ,
, A
1
D
1
+
0 k ,
, A
1

0 k ,
, D
1

0 k ,
, + = = =

n

1 n ,

0 k ,
,
n


n

1 n ,

0 k ,
,
n

+ =

n
h
k 2n
n


n
g
k 2n
n

+ =

n
h
k 2n
n

The Fast W avelet Transform (FWT) Algori thm


6-33
i s handl ed i n a si mi l ar manner . The cal cul ati ons are easi l y
organi zed i f we note that (taki ng k = 0 i n the previ ous formul as, makes thi ngs
si mpl er ):
I f we tr ansfor m the (
n
) sequence i nto a new sequence defi ned by
...,
-1
, 0,
0
, 0,
1
, 0,
2
, 0, ... or
Then:
and by extensi on:
Si nce the pr ocedur e thus becomes:
Repl ace the and sequences by upsampl ed ver si ons and i nserti ng
zer os
Fi l ter by h and g respecti vel y
Sum the obtai ned sequences
These are exactl y the reconstr ucti on steps.

n
g
k 2n
n


1
h
2
0h
1

0
h
0
0h
1

1
h
2
0h
3

2
h
4
+ + + + + + + + =

n
h
2n
n


1
h
2

0
h
0

1
h
2

2
h
4
+ + + + + =

n
( )

2n

2n 1 +
, 0 = =

n
h
2n
n

n
h
n
n

n
h
k 2n
n

n
h
k n
n

k
0

n
h
k n
n

n
g
k n
n

+ =

6 Advanced C oncepts
6-34
One-Dimensional Wavelet Capabilities
The basi c one-di mensi onal objects ar e:
The anal ysi s-decomposi ti on capabi l i ti es ar e:
The synthesi s-reconstr ucti on capabi l i ti es ar e:
Objects Description
Si gnal i n or i gi nal ti me s
A
k
, 0 k j
D
k
, 1 k j
Or i gi nal si gnal
Approxi mati on at l evel k
Detai l at l evel k
Coeffi ci ents i n scal e-rel ated ti me cA
k
, 1 k j
cD
k
, 1 k j
[cA
j
, cD
j
, ..., cD
1
]
Approxi mati on coeffi ci ents at l evel k
Detai l coeffi ci ents at l evel k
Wavel et decomposi ti on at l evel j, j 1
Purpose Input Output M-file
Si ngl e-l evel decomposi ti on s cA
1
, cD
1
dwt
Si ngl e-l evel decomposi ti on cA
j
cA
j+1
, cD
j+1
dwt
Decomposi ti on s [cA
j
, cD
j
, ..., cD
1
] wav e de c
Purpose Input Output M-file
Si ngl e-l evel r econstructi on cA
1
, cD
1
s or A
0
i dwt
Si ngl e-l evel r econstructi on cA
j+1
, cD
j+1
cA
j
i dwt
Ful l r econstructi on [cA
j
, cD
j
, ..., cD
1
] s or A
0
wav e r e c
Sel ecti ve reconstr ucti on [cA
j
, cD
j
, ..., cD
1
] A
l
, D
m
wr c oef
Si ngl e reconstructi on cA
j
(or cD
j
) A
j
(or D
j
) upc oef
O ne-Di mensi onal W avelet C apabi li ti es
6-35
The decomposi ti on str uctur e uti l i ti es ar e:
Let us i l l ustrate the command l i ne mode for one-di mensi onal capabi l i ti es:
% Load or i gi nal 1D s i gnal .
l oad l e l e cc um; s = l el e cc um( 1: 3920) ;
l s = l e ngt h( s) ;
% Per f or m one s t ep dec ompos i t i on
% of s us i ng db1.
[ ca1, cd1] = dwt ( s, ' db1' ) ;
Resul ts are di spl ayed i n Fi gure 6-10
% Per f or m one s t ep r ec ons t r uc t i on of
% c a1 and c d1.
a1 = upcoef ( ' a' , ca1, ' db1' , 1, l s ) ;
d1 = upcoef ( ' d' , cd1, ' db1' , 1, l s ) ;
Resul ts are di spl ayed i n Fi gure 6-11.
Purpose Input Output M-file
Extracti on of detai l
coeffi ci ents
[cA
j
, cD
j
, ..., cD
1
] cD
k
,
1 k j
de t c oe f
Extracti on of
appr oxi mati on
coeffi ci ents
[cA
j
, cD
j
, ..., cD
1
] cA
k
,
0 k j
appc oe f
Recomposi ti on of
the decomposi ti on
structure
[cA
j
, cD
j
, ..., cD
1
] [cA
k
, cD
k
, ..., cD
1
]
1 k j
upwl ev
6 Advanced C oncepts
6-36
Figure 6-10: Coefficients at level 1
0 500 1000 1500 2000 2500 3000 3500 4000
100
200
300
400
500
600
Original signal s.
0 500 1000 1500 2000
0
200
400
600
800
Approx. coef. : ca1
0 500 1000 1500 2000
30
20
10
0
10
20
30
Detail coef. : cd1
O ne-Di mensi onal W avelet C apabi li ti es
6-37
Figure 6-11: Signals at level 1
% I nv er t di r ec t de compos i t i on of s
% us i ng c oe f f i ci ent s .
a0 = i dwt ( c a1, cd1, ' db1' , l s ) ;
% Per f or m de compos i t i on at l e ve l 3
% of s us i ng db1.
[ c, l ] = wav e de c( s, 3, ' db1' ) ;
% Ext r act t he appr ox i mat i on c oe f f i c i ent s
% at l e ve l 3, f r om t he wave l e t de compos i t i on
% s t r uc t ur e [ c , l ] .
0 500 1000 1500 2000 2500 3000 3500 4000
0
200
400
600
Original signal s.
0 500 1000 1500 2000 2500 3000 3500 4000
0
200
400
600
Approximation : a1.
0 500 1000 1500 2000 2500 3000 3500 4000
50
0
50
Detail : d1.
6 Advanced C oncepts
6-38
c a3 = appc oe f ( c, l , ' db1' , 3) ;
% Ext r ac t t he de t ai l coef f i ci e nt s at l ev e l s
% 1, 2 and 3, f r om t he wave l e t dec ompos i t i on
% s t r uc t ur e [ c , l ] .
c d3 = de t c oe f ( c, l , 3) ;
c d2 = de t c oe f ( c, l , 2) ;
c d1 = de t c oe f ( c, l , 1) ;
Resul ts are di spl ayed i n Fi gure 6-12, the si gnal s , ca3, cd3, c d2 and cd1 from
the top to the bottom.
Figure 6-12: Coefficients at levels 1 to 3
0 500
0
1000
2000
0 500 1000 1500 2000 2500 3000 3500 4000
0
500
1000
Original signal s and coefficients.
0 500
100
0
100
0 500 1000
50
0
50
0 500 1000 1500 2000
50
0
50
O ne-Di mensi onal W avelet C apabi li ti es
6-39
% Rec ons t r uc t t he appr oxi mat i on at l ev el 3,
% f r om t he wav el et dec ompos i t i on
% s t r uc t ur e [ c , l ] .
a3 = wr coef ( ' a' , c, l , ' db1' , 3) ;
% Rec ons t r uc t t he de t ai l at
% l ev el 2, f r om t he wav el et
% dec ompos i t i on s t r uct ur e [ c, l ] .
d2 = wr coef ( ' d' , c, l , ' db1' , 2) ;
% Rec ons t r uc t s f r om t he wav el e t
% dec ompos i t i on s t r uct ur e [ c, l ] , s = a0.
a0 = wave r e c ( c , l , ' db1' ) ;
6 Advanced C oncepts
6-40
Two-Dimensional Wavelet Capabilities
The basi c two-di mensi onal objects ar e:
D
k
stands for , the hor i zontal , verti cal and di agonal
detai l s at l evel k.
The same hol ds for cD
k
whi ch stands for: .
The two-di mensi onal M-fi l es ar e exactl y the same as i n one-di mensi onal case,
appendi ng a 2 on the end of the command. For exampl e, i dwt becomes i dwt 2.
Objects Description
I mage i n ori gi nal
resol uti on
s Or i gi nal i mage
A
0
Approxi mati on at l evel 0
A
k
, 1 k j Approxi mati on at l evel k
D
k
, 1 k j Detai l s at l evel k
Coeffi ci ents i n
scal e-rel ated
resol uti on
cA
k
, 1 k j Approxi mati on coeffi ci ents at l evel k
cD
k
, 1 k j Detai l coeffi ci ents at l evel k
[cA
j
, cD
j
, ..., cD
1
] Wavel et decomposi ti on at l evel j
D
k
h ( )
D
k
v ( )
, D
k
d ( )
, [ ]
cD
k
h ( )
cD
k
v ( )
, cD
k
d ( )
, [ ]
Two-Di mensi onal W avelet C apabi li ti es
6-41
Let us i l l ustrate the command l i ne mode for two-di mensi onal capabi l i ti es:
% Load or i gi nal i mage.
l oad woman;
s X = s i z e ( X) ;
% X c ont ai ns t he l oade d i mage and
% map c ont ai ns t he l oaded c ol or map.
r ow = s X( 1) ; c ol = s X( 2) ;
% I mage c odi ng.
nbc ol = s i z e ( map, 1) ;
c od_X = wcodemat ( X, nbc ol ) ;
% Per f or m one s t ep dec ompos i t i on
% of X us i ng db1.
[ ca1, chd1, c v d1, c dd1] = dwt 2( X, ' db1' ) ;
% I mage s codi ng.
c od_c a1 = wc odemat ( c a1, nbcol ) ;
c od_c hd1 = wcode mat ( chd1, nbcol ) ;
c od_c vd1 = wcode mat ( cv d1, nbcol ) ;
c od_c dd1 = wcode mat ( cdd1, nbcol ) ;
dec 2d = [ . . .
c od_ca1, c od_c hd1; . . .
c od_cv d1, cod_c dd1 . . .
] ;
% Vi s ual i z e t he coef f i c i e nt s of t he de compos i t i on
% at l e ve l 1.
Resul ts are di spl ayed i n Fi gure 6-13.
6 Advanced C oncepts
6-42
Figure 6-13: Decomposition at level 1
% Per f or m s e cond s t ep dec ompos i t i on:
% dec ompos e appr ox . c f s of l e v el 1.
[ ca2, chd2, cv d2, c dd2] = dwt 2( c a1, ' db1' ) ;
% I nv er t di r ec t l y dec ompos i t i on of X
% us i ng coef f i ci ent s at l ev el 1.
a0 = i dwt 2( c a1, c hd1, c vd1, cdd1, ' db1' , s X) ;
% Per f or m de compos i t i on at l e v el 2
% of X us i ng db1.
[ c, s ] = wave de c2( X, 2, ' db1' ) ;
Resul ts ar e di spl ayed i n Fi gure 6-14.
Two-Di mensi onal W avelet C apabi li ti es
6-43
Figure 6-14: Decomposition at level 2
% Ext r act appr ox i mat i on c oe f f i c i e nt s
% at l e ve l 2, f r om wav e l e t de compos i t i on
% s t r uc t ur e [ c , s ] .
c a2 = appcoe f 2( c , s , ' db1' , 2) ;
% Ext r act de t ai l s coef f i c i e nt s at l e ve l 2
% f r om wave l et dec ompos i t i on
% s t r uc t ur e [ c , s ] .
c hd2 = de t c oef 2( ' h' , c, s , 2) ;
c vd2 = de t c oef 2( ' v ' , c, s , 2) ;
c dd2 = de t c oef 2( ' d' , c, s , 2) ;
% Ext r act appr ox i mat i on and det ai l s coef f i ci ent s
% at l e ve l 1, f r om wav e l e t de compos i t i on
% s t r uc t ur e [ c , s ] .
c a1 = appcoe f 2( c , s , ' db1' , 1) ;
c hd1 = de t c oef 2( ' h' , c, s , 1) ;
c vd1 = de t c oef 2( ' v ' , c, s , 1) ;
c dd1 = de t c oef 2( ' d' , c, s , 1) ;
6 Advanced C oncepts
6-44
% Rec ons t r uc t appr oxi mat i on at l ev el 2,
% f r om t he wav el et de compos i t i on
% s t r uc t ur e [ c , s ] .
a2 = wr c oe f 2( ' a' , c , s , ' db1' , 2) ;
% Rec ons t r uc t de t ai l s at l e ve l 2,
% f r om t he wav el et de compos i t i on
% s t r uc t ur e [ c , s ] .
hd2 = wr coef 2( ' h' , c , s , ' db1' , 2) ;
v d2 = wr coef 2( ' v ' , c , s , ' db1' , 2) ;
dd2 = wr coef 2( ' d' , c , s , ' db1' , 2) ;
% One s t ep r ec ons t r uc t i on of wav el et
% dec ompos i t i on s t r uc t ur e [ c, s ] .
s c = s i z e( c)
s c =
1 65536
v al _s = s
v al _s =
64 64
64 64
128 128
256 256
[ c, s ] = upwl ev 2( c, s , ' db1' ) ; s c = s i z e( c)
s c =
1 65536
v al _s = s
v al _s =
128 128
128 128
256 256
Two-Di mensi onal W avelet C apabi li ti es
6-45
% Rec ons t r uc t appr ox i mat i on and det ai l s
% at l e ve l 1, f r om c oe f f i ci ent s .
%
% s t e p 1: e x t r ac t coef f i c i e nt s
% dec ompos i t i on s t r uct ur e [ c, s ] .
%
% s t e p 2: r e cons t r uc t .
s i z = s ( s i z e ( s , 1) , : ) ;
c a1 = appcoe f 2( c , s , ' db1' , 1) ;
a1 = upcoef 2( ' a' , c a1, ' db1' , 1, s i z ) ;
c l e ar c a1
c hd1 = de t c oef 2( ' h' , c, s , 1) ;
hd1 = upc oe f 2( ' h' , chd1, ' db1' , 1, s i z ) ;
c l e ar c hd1
c vd1 = de t c oef 2( ' v ' , c, s , 1) ;
v d1 = upc oe f 2( ' v ' , cv d1, ' db1' , 1, s i z ) ;
c l e ar c vd1
c dd1 = de t c oef 2( ' d' , c, s , 1) ;
dd1 = upc oe f 2( ' d' , cdd1, ' db1' , 1, s i z ) ;
c l e ar c dd1
% Rec ons t r uc t X f r om t he wave l e t
% dec ompos i t i on s t r uct ur e [ c, s ] .
a0 = wave r e c 2( c, s , ' db1' ) ;
6 Advanced C oncepts
6-46
Dealing with Border Distortion
Cl assi cal l y the DWT i s defi ned for sequences wi th l ength of some power of two,
and di fferent ways of extendi ng sampl es of other si zes ar e needed. Methods for
extendi ng the si gnal i ncl ude: zero-paddi ng, peri odi c extensi on, and boundary
val ue repl i cati on (symmetr i zati on).
The basi c al gori thm for the DWT i s not l i mi ted to dyadi c l ength and i s based
on a si mpl e scheme; convol uti on and downsampl i ng. As usual , when a
convol uti on i s performed on fi ni te-l ength si gnal s, border di stor ti ons ar i se.
Signal Extensions: Zero-Padding, Symmetrization,
and Smooth Padding
I n order to deal wi th bor der di storti ons, the bor der shoul d be treated
di fferentl y. Vari ous methods ar e avai l abl e to deal wi th thi s probl em, r efer red
as ''wavel ets on the i nter val (see [CohDJV93]). These i nteresti ng
constr ucti ons ar e effecti ve i n theory but are not enti r el y sati sfactor y fr om a
pr acti cal vi ewpoi nt.
Often i t i s pr efer abl e to use si mpl e schemes based on si gnal extensi on on the
boundar i es. Thi s i nvol ves the computati on of a few extr a coeffi ci ents at each
stage of the decomposi ti on pr ocess i n order to get a per fect reconstr ucti on.
Detai l s about the r ati onal e of these schemes can be found i n Chapter 8 of the
book Wavelets and Filter Banks, by Strang and Nguyen.
Deali ng wi th Border Di storti on
6-47
The avai l abl e si gnal extensi on modes are: (see dwt mode)
zero-padding: Thi s method i s used i n the ver si on of the DWT gi ven i n the
pr evi ous secti ons and assumes that the si gnal i s zero outsi de the ori gi nal
support. I t i s the defaul t mode of the wavel et transform i n the tool box.
The di sadvantage of zero-paddi ng i s that di sconti nui ti es ar e ar ti fi ci al l y
created at the border .
symmetrization: Thi s method assumes that si gnal s or i mages can be
r ecover ed outsi de thei r ori gi nal suppor t by symmetri c boundar y val ue
r epl i cati on.
Symmetr i zati on has the di sadvantage of ar ti fi ci al l y creati ng di sconti nui ti es
of the fi r st deri vati ve at the bor der, but thi s method wor ks wel l i n gener al for
i mages.
smooth padding: Thi s method assumes that si gnal s or i mages can be
r ecover ed outsi de thei r ori gi nal suppor t by a si mpl e fi r st order deri vati ve
extrapol ati on. Smooth paddi ng works wel l i n general for smooth si gnal s.
Befor e l ooki ng at an i l l ustrati ve exampl e, note that the decomposi ti on step
wi th any of these thr ee extensi on modes has the same i nver se reconstr ucti on
step. So al l the capabi l i ti es descri bed i n the previ ous par agr aphs ar e avai l abl e
wi thout any reference to the extensi on mode.
I t i s i nteresti ng to noti ce that i f ar bi trary extensi on i s done, and decomposi ti on
performed usi ng the convol uti on-downsampl i ng scheme, per fect reconstr ucti on
i s recovered usi ng i dwt or i dwt 2. Thi s poi nt i s i l l ustrated by the fol l owi ng
exampl e.
% Set i ni t i al s i gnal and ge t f i l t er s .
x = s i n( 0. 3*[ 1: 451] ) ;
w = ' db9' ;
[ LoF_D, Hi F_D, LoF_R, Hi F_R] = wf i l t e r s ( w) ;
% I n f act us i ng a s l i ght l y r e dundant s cheme, any s i gnal
% e xt ens i on s t r at e gy wor ks we l l .
% For e xampl e us e r andom paddi ng.
6 Advanced C oncepts
6-48
l x = l engt h( x) ; l f = l e ngt h( LoF_D) ;
r andn( ' s ee d' , 654) ;
e x = [ r andn( 1, l f ) x r andn( 1, l f ) ] ;
axi s ( [ 1 l x +2*l f - 2 3] )
s ubpl ot ( 211) , pl ot ( l f +1: l f +l x, x) , t i t l e ( ' Or i gi nal s i gnal ' )
axi s ( [ 1 l x +2*l f - 2 3] )
s ubpl ot ( 212) , pl ot ( ex ) , t i t l e( ' Ext ended s i gnal ' )
axi s ( [ 1 l x +2*l f - 2 3] )
% Dec ompos i t i on.
l a = f l oor ( ( l x +l f - 1) /2) ;
ar = wke ep( dyaddown( c onv( e x, LoF_D) ) , l a) ;
dr = wke ep( dyaddown( c onv( e x, Hi F_D) ) , l a) ;
% Rec ons t r uc t i on.
x r = i dwt ( ar , dr , w, l x) ;
% Che ck pe r f ec t r e c ons t r uct i on.
e r r 0 = max ( abs ( x- xr ) )
e r r 0 =
3. 0464e- 11
50 100 150 200 250 300 350 400 450
2
1
0
1
2
3
Original signal
50 100 150 200 250 300 350 400 450
2
1
0
1
2
3
Extended signal
Deali ng wi th Border Di storti on
6-49
Now l et us i l l ustrate the di fferences between the three methods both for 1-D
and 2-D si gnal s.
Zero-Padding.
Usi ng the GUI we wi l l exami ne the effects of zer o-paddi ng.
1 From the MATLAB prompt, type
dwt mode ( ' z pd' )
2 From the MATLAB prompt, type wave me nu.The Wavel et Tool box Mai n Menu
appear s.
3 Cl i ck the Wavelet 1-D menu i tem.The di screte wavel et anal ysi s tool for
one-di mensi onal si gnal data appears.
4 From the File menu, choose the Demo Analysis opti on and sel ect wi th db2
at l evel 5 --> two nearby di sconti nui ti es.
5 Sel ect Display Mode: Show and Scroll
The detai l coeffi ci ents cl earl y show the si gnal end effects.
Symmetric Extension.
6 From the MATLAB prompt, type
dwt mode ( ' s y m' )
7 From the MATLAB prompt, type wav eme nu.
The Wavel et Tool box Mai n Menu appear s.
6 Advanced C oncepts
6-50
8 Cl i ck the Wavelet 1-D menu i tem.
The di screte wavel et anal ysi s tool for one-di mensi onal si gnal data appears.
9 Fr om the File menu, choose the Demo Analysis opti on and sel ect with
db2 at level 5 --> two nearby discontinuities.
10 Sel ect Display Mode: Show and Scroll
The detai l coeffi ci ents show the si gnal end effects ar e pr esent, but the
di sconti nui ti es are wel l detected.
Deali ng wi th Border Di storti on
6-51
Smooth Padding.
11 From the MATLAB prompt, type
dwt mode ( ' s pd' )
12 From the MATLAB prompt, type wav eme nu.
The Wavel et Tool box Mai n Menu appear s.
13 Cl i ck the Wavelet 1-D menu i tem.
The di screte wavel et anal ysi s tool for one-di mensi onal si gnal data appears.
14 From the File menu, choose the Demo Analysis opti on and sel ect with
db2 at level 5 --> two nearby discontinuities.
15 Sel ect Display Mode: Show and Scroll
The detai l coeffi ci ents show the si gnal end effects ar e not present, and the
di sconti nui ti es are wel l detected.
Let us now consi der an i mage exampl e.
6 Advanced C oncepts
6-52
Original Image.
1 Fr om the MATLAB pr ompt, type
l oad ge ome t r y; s X = s i z e( X) ;
% X c ont ai ns t he l oaded i mage and
% map c ont ai ns t he l oaded c ol or map.
r ow = s X( 1) ; c ol = s X( 2) ;
nbc ol = s i z e ( map, 1) ;
c ol or map( pi nk( nbcol ) ) ;
i mage ( wc odemat ( X, nbcol ) ) ;
Deali ng wi th Border Di storti on
6-53
Zero-Padding.
Now we set the extensi on mode to zero-paddi ng and per for m a decomposi ti on
of the i mage to l evel 3 usi ng the s y m4 wavel et, and then r econstruct the
approxi mati on of l evel 3.
2 From the MATLAB prompt, type
dwt mode ( ' z pd' )
l ev = 3;
[ c, s ] = wav e de c2( X, l ev , ' s ym4' ) ;
a = wr c oe f 2( ' a' , c, s , ' s y m4' , l e v) ;
i mage ( wcode mat ( a, nbc ol ) ) ;
6 Advanced C oncepts
6-54
Symmetric Extension.
Now we set the extensi on mode to symmetri c extensi on and per form a
decomposi ti on of the i mage agai n to l evel 3 usi ng the s ym4 wavel et, and then
r econstruct the approxi mati on of l evel 3.
3 Fr om the MATLAB pr ompt, type
dwt mode ( ' s ym' )
[ c, s ] = wave de c2( X, l e v, ' s ym4' ) ;
a = wr c oef 2( ' a' , c, s , ' s y m4' , l e v ) ;
i mage ( wc odemat ( a, nbcol ) ) ;
Deali ng wi th Border Di storti on
6-55
Smooth Padding.
Fi nal l y we set the extensi on mode to smooth paddi ng and per for m a
decomposi ti on of the i mage agai n to l evel 3 usi ng the s y m4 wavel et, and then
reconstr uct the approxi mati on of l evel 3.
4 From the MATLAB prompt, type
dwt mode ( ' s pd' )
[ c, s ] = wav e de c2( X, l ev , ' s ym4' ) ;
a = wr c oe f 2( ' a' , c, s , ' s y m4' , l e v) ;
i mage ( wcode mat ( a, nbc ol ) ) ;
Periodized Wavelet Transform
Another method i s the per i odi zed wavel et transform. Thi s method supposes
that si gnal s or i mages ar e peri odi c. I t i s cl ear that i n gener al i t i s far from a
reasonabl e assumpti on. The mai n advantage of thi s transform i s that i t does
not requi re extr a coeffi ci ents.
I n the tool box, the per i odi zed wavel et transform i s handl ed separ atel y (see
dwt pe r , dwt pe r 2, i dwt per , i dwt per 2). For the peri odi zed wavel et tr ansfor m,
the ful l command l i ne capabi l i ti es descr i bed previ ousl y are not defi ned and the
GUI tool s do not suppor t the per i odi zed wavel et transform.
6 Advanced C oncepts
6-56
Frequently Asked Questions
Continuous or Discrete Analysis?
When i s conti nuous anal ysi s more appropri ate than di screte anal ysi s? To
answer thi s, consi der the rel ated questi ons: Do you need to know al l val ues of
a conti nuous decomposi ti on to reconstr uct the si gnal s exactl y? Can you
perfor m non-redundant anal ysi s?
When the ener gy of the si gnal i s fi ni te, not al l val ues of a decomposi ti on are
needed to exactl y r econstruct the ori gi nal si gnal , provi ded that you ar e usi ng a
wavel et that sati sfi es some admi ssi bi l i ty condi ti on (see [Dau92] p. 7, 24, 27).
Usual wavel ets sati sfy thi s condi ti on. I n that case, a conti nuous-ti me si gnal s
i s enti rel y char acter i zed by the knowl edge of the di scr ete transform
. I n such cases, di screte anal ysi s i s suffi ci ent and conti nuous
anal ysi s i s r edundant. When the si gnal i s recor ded i n conti nuous ti me or on a
ver y fi ne ti me gri d, both types of anal ysi s are possi bl e. Whi ch shoul d be used?
The answer i s: each has i ts own advantages.
Di scr ete anal ysi s ensur es space-savi ng codi ng and i s suffi ci ent for the
synthesi s.
Conti nuous anal ysi s i s often easi er to i nter pr et, si nce i ts r edundancy tends
to r ei nforce the trai ts and makes al l i nfor mati on more vi si bl e. Thi s i s
especi al l y true of very subtl e i nformati on. The anal ysi s gai ns i n readabi l i ty
and i n ease of i nter pretati on what i t l oses i n ter ms of space savi ng.
Why Are Wavelets Useful for Space-Saving Coding?
The fami l y of functi ons (
0,k
;
j,l
) j 0, , used for the anal ysi s i s an
orthogonal basi s, therefor e l eadi ng to non-redundancy: as soon as
, and as soon as . Let us r emember that
stands for , for one di mensi onal si gnal s.
For bi orthogonal wavel ets, the i dea i s si mi l ar .
C j k , ( ) j k ( , ) , Z
2

k l , Z

0 k ,

j k ,

j 0
j k ,

j k ,
j k ( , ) j k ( , ) u v
u x ( )v x ( ) x d
R

0 =
Frequently Asked Q uesti ons
6-57
Why Do All Wavelets Have Zero Average and Sometimes
Several Vanishing Moments?
When the wavel ets k + 1 moments ar e equal to zero ( for
) al l the pol ynomi al si gnal s have zero wavel et
coeffi ci ents, the detai l s ar e al so zer o. Thi s property ensures the suppr essi on of
si gnal s that are pol ynomi al s.
What About the Regularity of a Wavelet ?
The noti on of r egul ari ty has been assumi ng i ncr easi ng i mpor tance i n
theor eti cal and pr acti cal studi es. Wavel ets ar e tool s used to study regul ari ty
and to conduct l ocal studi es. Deter mi ni sti c fractal si gnal s or Browni an moti on
tr ajector i es are l ocal l y very i r regul ar ; for exampl e, the l atter are conti nuous
si gnal s, but thei r fi rst der i vati ve exi sts al most nowher e.
The defi ni ti on of the concept of r egul ari ty i s somewhat techni cal . To make
thi ngs si mpl e, l et us say that a si gnal f, defined on R, has a r egul ari ty of s.
When s i s an i nteger, the r egul ari ty i n x
0
i s defi ned as usual , s i s the order of
di ffer enti abi l i ty. When s i s not an i nteger, l et m be the integer such that
m < s < m + 1, then f has a r egul ari ty of s i n x
0
i f i ts der i vati ve f
(m)
of or der m
resembl es l ocal l y ar ound x
0
.
The regul ari ty of f i n a domai n i s that of i ts l east r egul ar poi nt.
The greater s, the more regul ar the si gnal .
The regul ari ty of cer tai n wavel ets i s known. The fol l owi ng tabl e gi ves some
i ndi cati ons for Daubechi es wavel ets.
We have an asymptoti c rel ati on l i nki ng the si ze of the support of the
Daubechi es wavel ets dbN and thei r r egul ar i ty: when ,
l ength(support) = 2N, regul ari ty .
db1 = Haar db2 db3 db4 db5 db7 db10
Regul ari ty 0 0.5 0.91 1.27 1.59 2.15 2.90
t
j
t ( ) t d
R
0 =
j 0 = k , , s t ( ) a
j
t
j
0 j k

=
x x
0

s m
N
s
N
5
----
6 Advanced C oncepts
6-58
The functi ons are mor e r egul ar at certai n poi nts than at other s
(see Fi gur e 6-15).
Figure 6-15: Zooming in on db3 wavelet
Sel ecti ng a regul ari ty and a wavel et for thi s regul ar i ty i s useful i n esti mati ons
of the l ocal properti es of functi ons or si gnal s. Thi s can be used, for exampl e, to
make sur e that a si gnal has a constant r egul ari ty at al l poi nts. Work on
functi on esti mati on and nonl i near regressi on i s cur rentl y under way, notabl y
by Donoho, Johnstone, Kerkyachari an and Pi car d, i n order to adapt the
stati sti cal esti mators to unknown regul ar i ty. See al so the r emarks by
I . Daubechi es (see [Dau92] p. 301).
From a pr acti cal poi nt of vi ew, these questi ons ari se i n the worl d of fi nance i n
deal i ng wi th monetary and stock markets for fi ne studi es of ver y fast
tr ansacti ons.
Are Wavelets Useful in Fields Other Than Signal or
Image Processing?
From a theor eti cal poi nt of vi ew, wavel ets can be used to characteri ze l ar ge
sets of mathemati cal functi ons and ar e used i n the study of oper ator s l i nked
to par ti al di fferenti al equati ons.
From a pr acti cal poi nt of vi ew, wavel ets are used i n sever al fi el ds of
numer i cal anal ysi s, maki ng cer tai n compl ex cal cul ati ons easi er to handl e or
more pr eci se.
Frequently Asked Q uesti ons
6-59
What Functions Are Candidates to Be a Wavelet?
I f a functi on f i s conti nuous, has nul l moments, decr eases qui ckl y towar ds 0
when x tends towar ds i nfi ni ty, or i s nul l outsi de a segment of R, i t i s a l i kel y
candi date to become a wavel et. The fami l y of shi fts and di l ati ons of f al l ows al l
fi ni te energy si gnal s to be reconstr ucted usi ng the detai l s i n al l scal es. Such a
functi on wi l l be cal l ed . Thi s al l ows onl y conti nuous anal ysi s.
I n the tool box, the wavel et i s usual l y associ ated wi th a scal i ng functi on .
There are, however , some wavel ets for whi ch we do not know how to associ ate
a . I n some cases we know how to pr ove that does not exi st, for exampl e, the
Mor l et wavel et.
Is It Easy to Build a New Wavelet?
Not at the pr esent ti me. Mor e pr eci sel y, for a mi ni mal requi rement on the
wavel et pr oper ti es, i t i s easy but wi thout i nterest. But i f mor e i nteresti ng
properti es (l i ke the exi stence of for exampl e) are needed, then i t i s di ffi cul t.
Very few wavel ets have an expl i ci t anal yti cal expressi on. Notabl e excepti ons
ar e wavel ets that ar e pi ecewi se pol ynomi al s (Haar , Battl e-Lemar i e, see
[Dau92] p. 146), Mor l et, or Mexi can hat.
Wavel ets, even db2, db3 ..., are defi ned by functi onal equati ons. The sol uti on
for constructi ve equati ons i s numer i cal , and i s accompl i shed usi ng a fai rl y
si mpl e al gor i thm.
The basi c pr oper ty i s the exi stence of a l i near rel ati on between the two
functi ons (x/2) and (x). Another rel ati on of the same type l i nks (x/2) to (x).
These are the rel ati ons of the two scal es, the twi n-scal e rel ati on.
I ndeed there are two sequences h and g of coeffi ci ents such that:
and h l
2
Z ( ) g l
2
Z ( ) ,
1
2
---
x
2
---


1
2
------- h
n
x n ( )
n Z

=
1
2
---
x
2
---


1
2
------- g
n
x n ( ).
n Z

=
6 Advanced C oncepts
6-60
By r ewr i ti ng these formul as usi ng Fouri er transforms (expressed usi ng a hat)
we obtai n:
Ther e ar e functi ons for whi ch the h has a fi ni te i mpul se response (FI R):
there i s onl y a fi ni te number of nonzer o h
n
coeffi ci ents. The associ ated wavel ets
wer e bui l t by I . Daubechi es (see [Dau92] i n Chapter 6) and are used extensi vel y
i n the tool box. The r eader can r efer to p. 164 and Chapter 10 of the book
Wavelets and Filter Banks, by Strang and Nguyen.
What Is the Link Between Wavelet and Fourier Analysis?
Wavel et anal ysi s compl ements the Four i er anal ysi s for whi ch there are several
MATLAB functi ons: f f t , s pa, et f e , s pe ct r um.
Four i er anal ysi s uses the basi c functi ons si n(t), cos(t), and exp(it), wi th
bei ng the frequency.
I n the frequency domai n, these functi ons are per fectl y l ocal i zed, si nce thei r
spectr um l oads onl y two poi nts -/2, and /2. The functi ons ar e sui ted to the
anal ysi s and synthesi s of si gnal s wi th a si mpl e spectr um, whi ch i s ver y wel l
l ocal i zed i n frequency, for exampl e si n(
1
t) + 0.5si n(
2
t) - cos(
3
t).
I n the ti me domai n, these functi ons ar e not l ocal i zed. I t i s di ffi cul t for them
to anal yze or synthesi ze compl ex si gnal s presenti ng fast l ocal var i ati ons such
as transi ents or abrupt changes: the Fouri er coeffi ci ents for a frequency
wi l l depend on al l val ues i n the si gnal . To l i mi t the di ffi cul ti es i nvol ved, i t i s
possi bl e to wi ndow the si gnal usi ng a regul ar functi on, whi ch i s zer o or
near l y zero outsi de a ti me segment [-m, m]. We then bui l d a wel l l ocal i zed
sl i ce as I . Daubechi es (see [Dau92] p. 2) cal l s i t. The wi ndowed-Four i er
anal ysi s coeffi ci ents ar e:
The anal ogy of thi s formul a wi th that of the wavel et coeffi ci ents i s obvi ous:
The l arge val ues of a corr espond to smal l val ues of .

2 ( )
1
2
-------h

( )

( ) = 2 ( )
1
2
-------g

( )

( ) =

s t ( , ) s u ( )g t u ( )e
i u
u d
R

=
C a t ( , ) s u ( )
1
a
-------

t u ( )
a
---------------


u d
R

=
Frequently Asked Q uesti ons
6-61
The Fouri er coeffi ci ent depends on the val ues of the si gnal s on the
segment wi th a constant wi dth [t - m, t + m]. I f , l i ke g, i s zero outsi de of
[-m, m], the C(a,t) coeffi ci ents wi l l depend on the val ues of the si gnal s on the
segment of wi dth 2am, whi ch vari es as a functi on of [t - am, t + am]. Thi s sl i ght
di ffer ence sol ves sever al di ffi cul ti es, al l owi ng a ki nd of ti me-wi ndowed anal ysi s
at var i ous scal es a.
The wavel ets stay however competi ti ve, even i n contexts consi dered favor abl e
for the Four i er techni que. I . Daubechi es (see [Dau92] p. 3-7) gi ves an exampl e
of Wi ndowed Four i er processi ng and compl ex Morl et wavel et pr ocessi ng
, of a si gnal composed mai nl y of the sum of two
si nes. The wavel et anal ysi s gi ves good resul ts.
s t ( , )
t ( ) Ce
t
2

e
i t
e

2

2
4
( ) =
6 Advanced C oncepts
6-62
Wavelet Families: Additional Discussion
Ther e are di ffer ent types of wavel et fami l i es whose qual i ti es vary accor di ng to
sever al cr i teri a. The mai n cr i teri a ar e:
The suppor t of , and , : the speed of convergence at i nfi ni ty to 0 of these
functi ons when the ti me or the frequency goes to i nfi ni ty, whi ch quanti fi es
both ti me and frequency l ocal i zati ons.
The symmetr y, whi ch i s useful i n avoi di ng dephasi ng i n i mage pr ocessi ng.
The number of vani shi ng moments for or for (i f i t exi sts), whi ch i s useful
for compressi on purpose.
The r egul ari ty, whi ch i s useful for getti ng ni ce features, l i ke smoothness of
the reconstr ucted si gnal or i mage.
These ar e associ ated wi th two pr oper ti es that al l ow fast al gor i thm and
space-savi ng codi ng:
The exi stence of a scal i ng functi on .
The or thogonal i ty or the bi or thogonal i ty of the resul ti ng anal ysi s,
and perhaps l ess i mportant ones:
The exi stence of an expl i ci t expressi on.
The ease of tabul ati ng.
The fami l i ari ty wi th use.
Typi ng wave i nf o i n command l i ne mode di spl ays a survey of the mai n
pr oper ti es of al l wavel et fami l i es avai l abl e i n the tool box.
Let us menti on that the and functi ons can be computed usi ng wav ef un; the
fi l ter s are gener ated usi ng wf i l t e r s . We pr ovi de defi ni ti on equati ons for
sever al wavel ets. Some are gi ven expl i ci tl y by thei r ti me defi ni ti on, other s by
thei r frequency defi ni ti on, and sti l l other s by thei r fi l ter .

W avelet Fami li es: Addi ti onal Di scussi on


6-63
The tabl e bel ow outl i nes the wavel et fami l i es i ncl uded i n the tool box.
Daubechies Wavelets: dbN
I n dbN, N i s the order. Some author s use 2N i nstead of N. Mor e about thi s fami l y
can be found i n [Dau92] p. 115, 132, 194, 242. By typi ng wav ei nf o( ' db) , at the
MATLAB command pr ompt, you can obtai n a survey of the mai n properti es of
thi s fami l y.
Figure 6-16: Daubechies wavelets db4 and db8
Wavelets in the toolbox
mor l Morl et
me xh Mexi can hat
me yr Meyer
haar Haar
dbN Daubechi es
s y mN Syml ets
coi f N Coi fl ets
bi or Nr . Nd Spl i nes bi or thogonal wavel ets
0 2 4 6
1
0.5
0
0.5
1
Scaling function phi
0 2 4 6
1
0.5
0
0.5
1
Wavelet function psi
0 1 2 3 4 5 6 7
0.5
0
0.5
Decomposition lowpass filter
0 1 2 3 4 5 6 7
0.5
0
0.5
Reconstruction lowpass filter
0 1 2 3 4 5 6 7
0.5
0
0.5
Decomposition highpass filter
0 1 2 3 4 5 6 7
0.5
0
0.5
Reconstruction highpass filter
0 5 10
1
0.5
0
0.5
1
Scaling function phi
0 5 10
1
0.5
0
0.5
1
Wavelet function psi
0 2 4 6 8 10 12 14
0.5
0
0.5
Decomposition lowpass filter
0 2 4 6 8 10 12 14
0.5
0
0.5
Reconstruction lowpass filter
0 2 4 6 8 10 12 14
0.5
0
0.5
Decomposition highpass filter
0 2 4 6 8 10 12 14
0.5
0
0.5
Reconstruction highpass filter
6 Advanced C oncepts
6-64
Thi s fami l y i ncl udes the Haar wavel et, wr i tten db1, the si mpl est wavel et
i magi nabl e and cer tai nl y the ear l i est. Usi ng wave i nf o( ' haar ' ) , you can obtai n
a survey of the mai n properti es of thi s wavel et.
Haar
dbN
These wavel ets have no expl i ci t expressi on except for db1, whi ch i s the Haar
wavel et. However , the square modul us of the transfer functi on of h i s expl i ci t
and fai r l y si mpl e.
Let , where denotes the bi nomi al
coeffi ci ents. Then:
wher e:
The support l ength of and i s 2N - 1. The number of vani shi ng moments
of i s N.
Most dbN are not symmetr i cal . For some, the asymmetry i s ver y pronounced.
The r egul ari ty i ncreases wi th the or der . When N becomes ver y l ar ge, and
bel ong to C
N
, si nce i s appr oxi matel y equal to 0.2. For sur e, thi s
asymptoti c val ue i s too pessi mi sti c for smal l order N. Note that the functi ons
are more regul ar at cer tai n poi nts than at others.
The anal ysi s i s orthogonal .
i f
i f
i f
i f
i f
x ( ) 1 = , 0 x
1
2
-- - <
x ( ) 1, =
1
2
--- x 1 <
x ( ) 0, = x 0 1 , [ ]
x ( ) 1 = x 0 1 , [ ]
x ( ) 0 = x 0 1 , [ ]
P y ( ) C
k
N 1 k +
y
k
k 0 =
N 1

= C
k
N 1 k +
m
0
( )
2
cos
2
2
----


N
P sin
2
2
--- -




=
m
0
( )
1
2
------- h
k
e
i k
k 0 =
2N 1

W avelet Fami li es: Addi ti onal Di scussi on


6-65
Symlet Wavelets: symN
I n symN, N i s the or der . Some author s use 2N i nstead of N. Syml ets are onl y near
symmetri c; consequentl y some author s do not cal l them syml ets. Mor e about
syml ets can be found i n [Dau92], p. 194, 254-257. By typi ng wave i nf o( ' s ym' )
at the MATLAB command pr ompt, you can obtai n a survey of the mai n
properti es of thi s fami l y.
Figure 6-17: Symlets sym4 and sym8
Daubechi es pr oposes modi fi cati ons of her wavel ets such that thei r symmetry
can be i ncr eased whi l e retai ni ng great si mpl i ci ty.
The i dea consi sts of r eusi ng the functi on m
0
i ntr oduced i n the dbN, consi der i ng
the as a functi on W of z = e
i
. Then we can factor W i n several di fferent
ways i n the form of . The roots of W wi th modul us not equal
to 1 go i n pai r s. I f one i s z
1
, i s al so a root.
By sel ecti ng U such that the modul us of al l i ts r oots i s stri ctl y l ess than 1, we
bui l d Daubechi es wavel ets dbN. The U fi l ter i s a mi ni mum phase fi l ter .
By maki ng another choi ce, we obtai n mor e symmetri cal fi l ters; these ar e
syml ets.
The syml ets have other properti es si mi l ar to those of the dbNs.
0 2 4 6
1
0.5
0
0.5
1
1.5
Scaling function phi
0 2 4 6
1
0.5
0
0.5
1
1.5
Wavelet function psi
0 1 2 3 4 5 6 7
0.5
0
0.5
Decomposition lowpass filter
0 1 2 3 4 5 6 7
0.5
0
0.5
Reconstruction lowpass filter
0 1 2 3 4 5 6 7
0.5
0
0.5
Decomposition highpass filter
0 1 2 3 4 5 6 7
0.5
0
0.5
Reconstruction highpass filter
0 5 10
0.5
0
0.5
1
Scaling function phi
0 5 10
0.5
0
0.5
1
Wavelet function psi
0 2 4 6 8 10 12 14
0.5
0
0.5
Decomposition lowpass filter
0 2 4 6 8 10 12 14
0.5
0
0.5
Reconstruction lowpass filter
0 2 4 6 8 10 12 14
0.5
0
0.5
Decomposition highpass filter
0 2 4 6 8 10 12 14
0.5
0
0.5
Reconstruction highpass filter
m
0
( )
2
W z ( ) U z ( )U
1
z
---


=
1
z
1
------
6 Advanced C oncepts
6-66
Coiflet Wavelets: coifN
I n coifN, N i s the order. Some author s use 2N i nstead of N. For the coi fl et
constr ucti on, see [Dau92] p. 258-259. By typi ng wave i nf o( ' c oi f ' ) at the
MATLAB command pr ompt, you can obtai n a survey of the mai n proper ti es of
thi s fami l y.
Figure 6-18: Coiflets coif3 and coif5.
Bui l t by Daubechi es at the request of Coi fman, the functi on has 2N moments
equal to 0 and, what i s more or i gi nal , the functi on has 2N-1 moments equal
to 0. The two functi ons have a support of l ength 6N-1.
The coifN and ar e much mor e symmetri cal than the dbNs. Wi th respect to
the suppor t l ength, coifN has to be compared to db3N or sym3N; wi th r espect to
the number of vani shi ng moments of , coifN has to be compar ed to db2N or
sym2N.
I f s i s a smooth conti nuous ti me si gnal , for l arge j: the coeffi ci ent
(see the Mathemati cal Conventi ons secti on at the
begi nni ng of thi s chapter). I f s i s a pol ynomi al of degr ee d, d N -1 the
appr oxi mati on becomes an equal i ty. Thi s pr oper ty i s used, connected wi th
sampl i ng probl ems, when cal cul ati ng the di ffer ence between an expansi on over
the of a gi ven si gnal and i ts sampl ed ver si on.
0 5 10 15 20 25
0.5
0
0.5
1
Scaling function phi
0 5 10 15 20 25
0.5
0
0.5
1
Wavelet function psi
0 2 4 6 8 10121416182022242628
0.5
0
0.5
Decomposition lowpass filter
0 2 4 6 8 10121416182022242628
0.5
0
0.5
Reconstruction lowpass filter
0 2 4 6 8 10121416182022242628
0.5
0
0.5
Decomposition highpass filter
0 2 4 6 8 10121416182022242628
0.5
0
0.5
Reconstruction highpass filter
0 5 10 15
0.5
0
0.5
1
1.5
Scaling function phi
0 5 10 15
0.5
0
0.5
1
1.5
Wavelet function psi
0 2 4 6 8 10 12 14 16
0.5
0
0.5
Decomposition lowpass filter
0 2 4 6 8 10 12 14 16
0.5
0
0.5
Reconstruction lowpass filter
0 2 4 6 8 10 12 14 16
0.5
0
0.5
Decomposition highpass filter
0 2 4 6 8 10 12 14 16
0.5
0
0.5
Reconstruction highpass filter

s
j k ,
, 2
j 2
s 2
j
k ( )

j k ,
W avelet Fami li es: Addi ti onal Di scussi on
6-67
Biorthogonal Wavelet Pairs: biorNr.Nd
Mor e about bi or thogonal wavel ets can be found i n [Dau92] p. 259, 269-285 and
[Coh92]. By typi ng wav e i nf o( ' bi or ' ) at the MATLAB command prompt, you
can obtai n a sur vey of the mai n pr operti es of thi s fami l y, as wel l as i nformati on
about Nr and Nd orders and associ ated fi l ter l engths.
Figure 6-19: Biorthogonal wavelets bior2.4 and bior4.4
0 2 4 6 8
1
0
1
2
Decomposition scaling function phi
0 2 4 6 8
0.5
0
0.5
1
1.5
Reconstruction scaling function phi
0 2 4 6 8
1
0
1
2
Decomposition wavelet function psi
0 2 4 6 8
0.5
0
0.5
1
1.5
Reconstruction wavelet function psi
0 1 2 3 4 5 6 7 8 9
0.5
0
0.5
Decomposition lowpass filter
0 1 2 3 4 5 6 7 8 9
0.5
0
0.5
Reconstruction lowpass filter
0 1 2 3 4 5 6 7 8 9
0.5
0
0.5
Decomposition highpass filter
0 1 2 3 4 5 6 7 8 9
0.5
0
0.5
Reconstruction highpass filter
0 2 4 6 8
1
0
1
Decomposition scaling function phi
0 2 4 6 8
0.5
0
0.5
1
1.5
Reconstruction scaling function phi
0 2 4 6 8
1
0
1
Decomposition wavelet function psi
0 2 4 6 8
0.5
0
0.5
1
1.5
Reconstruction wavelet function psi
0 1 2 3 4 5 6 7 8 9
0.5
0
0.5
Decomposition lowpass filter
0 1 2 3 4 5 6 7 8 9
0.5
0
0.5
Reconstruction lowpass filter
0 1 2 3 4 5 6 7 8 9
0.5
0
0.5
Decomposition highpass filter
0 1 2 3 4 5 6 7 8 9
0.5
0
0.5
Reconstruction highpass filter
6 Advanced C oncepts
6-68
The new fami l y extends the wavel et fami l y. I t i s wel l known i n the subband
fi l ter i ng communi ty that symmetry and exact reconstr ucti on ar e i ncompati bl e,
i f the same FI R fi l ter s are used for r econstructi on and decomposi ti on. Two
wavel ets, i nstead of just one, ar e i ntr oduced:
One, , i s used i n the anal ysi s, and the coeffi ci ents of a si gnal s ar e
The other, , i s used i n the synthesi s .
I n addi ti on, the wavel ets are rel ated by dual i ty i n the fol l owi ng sense:
as soon as or and even
as soon as .
I t becomes apparent, as Cohen poi nted out i n hi s thesi s (see [Coh92] p. 110),
that the useful pr oper ti es for anal ysi s (e.g., osci l l ati ons, zero moments) can be
concentrated on the functi on whereas the i nteresti ng properti es for
synthesi s (regul ar i ty) are assi gned to the functi on. The separati on of these
two tasks pr oves very useful .
, can have ver y di fferent regul ar i ty properti es, bei ng more r egul ar than
(see [Dau92] p. 269).
The , , and functi ons are zer o outsi de of a segment.
The cal cul ati on al gor i thms are mai ntai ned and thus very si mpl e.
The fi l ters associ ated to m
0
and can be symmetr i cal . The functi ons used i n
the cal cul ati ons are easi er to bui l d numeri cal l y than those used i n the usual
wavel ets.

j k ,
s x ( )

j k ,
x ( ) x d

=
s c

j k ,

j k ,
j k ,

j k ,
x ( )
j k ,
x ( ) x d

0 = j j k k

0 k ,
x ( )
0 k ,
x ( ) x d

0 = k k

0
W avelet Fami li es: Addi ti onal Di scussi on
6-69
Meyer Wavelet: meyr
Both and are defi ned i n the fr equency domai n, starti ng wi th an auxi l i ary
functi on (see [Dau92] p.117, 119, 137, 152). By typi ng wav e i nf o( ' me yr ' ) at
the MATLAB command pr ompt, you can obtai n a survey of the mai n pr oper ti es
of thi s wavel et.
Figure 6-20: The Meyer wavelet
The Meyer wavel et and scal i ng functi on are defi ned i n the frequency domai n
by:

and
wher e

5 0 5
0.5
0
0.5
1
Meyer scaling function
5 0 5
0.5
0
0.5
1
Meyer wavelet function
( ) 2 ( )
1 2
e
i 2
2
---
3
2
------ 1




sin = if
2
3
------
4
3
------
( ) 2 ( )
1 2
e
i 2
2
---
3
4
------ 1




cos = if
4
3
------
8
3
------
( ) 0 if =
2
3
------
8
3
------ [ , ]
a ( ) a
4
35 84a 70a
2
20a
3
+ ( ), = a 0 1 [ , ]

( ) 2 ( )
1 2
= if
2
3
------

( ) 2 ( )
1 2
=

2
---
3
2
------ 1




cos if
2
3
------
4
3
------

( ) 0 = if
4
3
------ >
6 Advanced C oncepts
6-70
By changi ng the auxi l i ar y functi on, one gets a fami l y of di fferent wavel ets. For
the r equi r ed properti es of the auxi l i ar y functi on , see the l i st of r efer ences.
Thi s wavel et ensures orthogonal anal ysi s.
The functi on does not have fi ni te suppor t, but decr eases to 0 when ,
faster than any i nverse pol ynomi al :
such that .
Thi s pr oper ty hol ds al so for the deri vati ves:
The wavel et i s i nfi ni tel y di fferenti abl e.
Battle-Lemarie Wavelets
See [Dau92] p. 146-148, 151.
These wavel ets ar e not i ncl uded i n the tool box, but we use the spl i ne functi ons
i n the bi or thogonal fami l y.
Ther e ar e two forms of the wavel et; one does not ensure the anal ysi s to be an
orthogonal one, whi l e the other does. For N=1, the scal i ng functi ons are l i near
spl i nes. For N=2, the scal i ng functi ons are quadr ati c B-spl i ne wi th fi ni te
suppor t. Mor e general l y, for an N-degree B-spl i nes:
wi th k = 0 i f N i s odd, k = 1 i f N i s even. Thi s for mul a can be used to bui l d the
fi l ter s.
The twi n scal e rel ati on i s:
x
n C
n
, x ( ) C
n
1 x
2
+ ( )
n

k N n N C
k n ,
, such that
k ( )
x C
k n ,
1 x
2
+ ( )
n
. , ,

( ) 2 ( )
1 2
e
i 2 2 ( ) sin
2
-----------------------
N 1 +
=
x ( ) 2
2M
C
j
2M 1 +
2x M 1 j + ( )
j 0 =
2M 1 +

= if N 2M =
x ( ) 2
2M 1
C
j
2M 2 +
2x M 1 j + ( )
j 0 =
2M 2 +

= if N 2M 1 + =
W avelet Fami li es: Addi ti onal Di scussi on
6-71
For an even N, i s symmetr i cal ar ound, x = 1/2; i s anti -symmetr i cal ar ound
x = 1/2. For an odd N, i s symmetr i cal around x = 0; i s symmetri cal ar ound
x = 1/2.
The anal ysi s becomes or thogonal i f we tr ansfor m the functi ons and
somewhat. For N=1, for i nstance, l et:
The suppor ts of and are not fi ni te, but the decr ease of the functi ons
and to 0 i s exponenti al . See [Dau92] p. 151.
The functi ons have der i vati ves up to order N-1.
Mexican Hat Wavelet: mexh
See [Dau92] p. 75.
By typi ng wav ei nf o( ' me xh' ) at the MATLAB command pr ompt, you can obtai n
a sur vey of the mai n pr operti es of thi s wavel et.
Figure 6-21: The Mexican hat

( ) 3
1 2
2 ( )
1 2 4sin
2
2 ( )

2
1 2cos
2
2 ( ) + [ ]
1 2
----------------------------------------------------------- =

5 0 5
0.2
0
0.2
0.4
0.6
0.8
Mexican hat wavelet function
6 Advanced C oncepts
6-72
Thi s functi on i s pr opor ti onal to the second der i vati ve functi on of the Gaussi an
pr obabi l i ty densi ty functi on.
As the functi on does not exi st, the anal ysi s i s not orthogonal .
Morlet Wavelet: morl
See [Dau92] p. 76.
By typi ng wave i nf o( ' mor l ' ) at the MATLAB command pr ompt you can obtai n
a survey of the mai n properti es of thi s wavel et.
Figure 6-22: The Morlet wavelet
The C constant i s used for normal i zati on i n vi ew of reconstr ucti on.
As the functi on does not exi st, the anal ysi s i s not orthogonal .
x ( )
2
3
-------
1 4


1 x
2
( )e
x
2
2
=
4 2 0 2
0.5
0
0.5
Morlet wavelet function
x ( ) Ce
x
2
2
cos 5x ( ) =
Summary of Wavelet Fami li es and Associ ated Properti es
6-73
Summary of Wavelet Families and Associated Properties
morl mexh meyr haar dbN symN coifN biorNr.Nd
Crude
I nfi ni tel y regul ar
Compactl y supported
orthogonal

Compactl y supported
bi othogonal

Symmetr y
Asymmetr y
Near symmetr y
Arbi trar y number of
vani shi ng moments

Vani shi ng moments for
Arbi trar y regul ar i ty
Exi stence of
Or thogonal anal ysi s
Bi orthogonal anal ysi s
Exact reconstr ucti on
FI R fi l ter s
Conti nuous transform
Di screte tr ansfor m
Fast al gor i thm
Expl i ci t expressi on for spl i nes
6 Advanced C oncepts
6-74
Wavelet Applications: More Detail
Chapters 3 and 4 i l l ustrate wavel et appl i cati ons wi th exampl es and case
studi es. Thi s secti on r e-exami nes some of the appl i cati ons wi th addi ti onal
theor y and more detai l .
Suppressing Signals
As shown i n Chapter 3, ''Suppr essi ng Si gnal s, by suppr essi ng a part of a si gnal
the r emai nder may be hi ghl i ghted.
Let be a wavel et wi th at l east k+1 vani shi ng moments (for j = 0, ..., k,
).
I f the si gnal s i s a pol ynomi al of degr ee k, then the coeffi ci ents C(a,b) = 0 for al l
a and al l b. Such wavel ets automati cal l y suppress the pol ynomi al s. The degr ee
of s can vary wi th ti me, pr ovi ded that i t remai ns l ess than k.
I f s i s now a pol ynomi al of degr ee k on segment , then C(a,b) = 0 as l ong
as the suppor t of the functi on i s i ncl uded i n . The suppressi on i s
l ocal . Effects wi l l appear on the edges of the segment.
Li kewi se, l et us suppose that, on to whi ch 0 bel ongs, we have the
expansi on . The s and g
si gnal s then have the same wavel et coeffi ci ents. Thi s i s the techni cal meani ng
of the phrase: ''the wavel et suppresses a pol ynomi al part of si gnal s. The
si gnal g i s the i rr egul ar par t of the si gnal s. The wavel et systemati cal l y
suppresses the r egul ar part and anal yzes the i r regul ar par t. Thi s effect i s
easi l y seen i n Fi gur e 4-2 up to detai l D
4
; the wavel et suppresses the sl ow si ne
wave whi ch i s l ocal l y assi mi l ated to a pol ynomi al .
Another way of suppr essi ng a component of the si gnal consi sts of forci ng
cer tai n coeffi ci ents C(a,b) to be equal to 0. Havi ng sel ected a set E of i ndi ces, we
sti pul ate that , C(a,b) = 0. We then synthesi ze the si gnal usi ng the
modi fi ed coeffi ci ents.

x
j
x ( ) x d
R

0 =
[ , ]
1
a
-------
x b
a
-----------


[ , ]
[ , ]
s x ( ) s 0 ( ) xs 0 ( ) x
2
s
2 ( )
0 ( ) x
k
s
k ( )
0 ( ) g x ( ) + + + + + =

a b ( , ) E
W avelet Appli cati ons: M ore Detai l
6-75
Let us i l l ustrate wi th the fol l owi ng M-fi l e, some features of wavel et processi ng
usi ng coeffi ci ents (resul ti ng pl ots can be found i n Fi gure 6-23).
% Load or i gi nal 1- D s i gnal .
l oad s ums i n; s = s ums i n;
% Set t he wave l e t name and pe r f or m t he dec ompos i t i on
% of s at l e ve l 4, us i ng coi f 3.
w = ' coi f 3' ; max l e v = 4;
[ c, l ] = wave de c( s , max l e v, w) ;
newc = c ;
% For ce t o z er o t he de t ai l coef f i ci e nt s at l ev e l s 3 and 4.
newc = wt hcoef ( ' d' , c, l , [ 3, 4] ) ;
% For ce t he de t ai l c oe f f i ci ent s at l ev el 1 t o z er o on
% or i gi nal t i me i nt e r v al [ 400: 600] and s hr i nk ot her wi s e .
% det er mi ne f i r s t and l as t i nde x of
% l ev el 1 c oef f i ci ent s .
k = max l ev +1;
f i r s t = s um( l ( 1: k- 1) ) +1; l as t = f i r s t +l ( k) - 1;
i ndd1 = f i r s t : l as t ;
% s hr i nk by di vi di ng by 3.
newc( i ndd1) = c( i ndd1) /3;
% f i nd at l e ve l 1 i ndi c es of coef f i c i e nt s
% i n t he i nt er val [ 400: 600] ,
% not e t hat t i me t i n or i gi nal gr i d cor r es ponds t o t i me
% t /2^k on t he gr i d at l e ve l k. Her e k=1.
i ndd1 = f i r s t +400/2: f i r s t +600/2;
% f or ce i t t o z e r o.
newc( i ndd1) = z e r os ( s i z e( i ndd1) ) ;
% Set t o 4 a c oe f f i c i e nt at l ev el 2 cor r es pondi ng r oughl y
% t o or i gi nal t i me t = 500.
k = max l ev ; f i r s t = s um( l ( 1: k- 1) ) +1;
newc( f i r s t +500/2^2) = 4;
% Synt hes i z e modi f i e d dec ompos i t i on s t r uct ur e.
s ynt h = wave r e c( ne wc, l , w) ;
6 Advanced C oncepts
6-76
A si mpl e pr ocedur e to sel ect E, cal l ed the threshol di ng procedure, i s car ri ed out
usi ng the wt hr es h functi on. The i nterface mode i ncl udes such procedures,
whi ch are al so used for de-noi si ng and compr essi on.
Figure 6-23: Suppress or modify signal components, acting on coefficients
0 200 400 600 800 1000
3
2
1
0
1
2
3
Original signal
0 200 400 600 800 1000
3
2
1
0
1
2
3
Original detail cfs from level 4 to level 1
0 200 400 600 800 1000
3
2
1
0
1
2
3
Modified detail cfs from level 4 to level 1
0 200 400 600 800 1000
3
2
1
0
1
2
3
Synthesized signal
W avelet Appli cati ons: M ore Detai l
6-77
Splitting Signal Components
Wavel et anal ysi s i s a l i near techni que: the wavel et coeffi ci ents of the l i near
combi nati on of two si gnal s ar e equal to the l i near combi nati on of
thei r wavel et coeffi ci ents . The same hol ds tr ue for the
cor respondi ng approxi mati ons and detai l s, for exampl e and
.
Noise Processing
Let us fi rst anal yze noi se as an ordi nary si gnal . Then the pr obabi l i ty
character i sti cs: corr el ati on functi on, spectrum, and di str i buti on need to be
studi ed.
I n gener al , for a one-di mensi onal di scr ete-ti me si gnal , the hi gh frequenci es
i nfl uence the detai l s of the fi r st l evel s, whi l e the l ow frequenci es i nfl uence the
deepest l evel s and the associ ated appr oxi mati ons.
I f a si gnal compr i sed onl y of whi te noi se i s anal yzed, (see for exampl e, Fi gur e
4-3, the detai l s at the vari ous l evel s decrease i n ampl i tude as the l evel
i ncreases. The vari ance of the detai l s al so decreases as the l evel i ncreases. The
detai l s and approxi mati ons are not whi te noi se anymor e, as col or i s i ntroduced
by the fi l ter s.
On the coeffi ci ents C(j,k), wher e j stands for the scal e and k for the ti me, we can
add often-sati sfi ed properti es for di screte ti me si gnal s:
I f the anal yzed si gnal s i s stati onar y, zero mean, whi te noi se, the coeffi ci ents
are uncorr el ated.
I f fur ther mor e s i s Gaussi an, the coeffi ci ents are i ndependent and Gaussi an.
I f s i s a col ored, stati onar y, zer o mean Gaussi an sequence, the coeffi ci ents
r emai n Gaussi an. For each scal e l evel j, the sequence of coeffi ci ents i s a
col ored stati onary sequence. I t coul d be i nteresti ng to know how to choose
the wavel et that woul d de-corr el ate the coeffi ci ents. Thi s probl em has not yet
been r esol ved. What i s mor e, the wavel et (i f i ndeed i t exi sts) most pr obabl y
depends on the col or of the si gnal . I n or der for the wavel et to be cal cul ated,
the col or must be known. I n most i nstances, thi s i s beyond our r each.
s
1 ( )
s
2 ( )
+
C
j k ,
1 ( )
C
j k ,
2 ( )
+
A
j
1 ( )
A
j
2 ( )
+
D
j
1 ( )
D
j
2 ( )
+
6 Advanced C oncepts
6-78
I f s i s a zer o mean ARMA model stati onary for each scal e j, then
i s al so a stati onar y, zer o mean ARMA pr ocess whose characteri sti cs depend
on j.
I f s i s a noi se whose:
- corr el ati on functi on i s known, we know how to cal cul ate the corr el ati ons
of C(j,k) and C(j,k).
- spectr um i s known, we know how to cal cul ate the spectrum of C(j,k),
and the cr oss spectrum of two di ffer ent l evel s j and j.
These resul ts ar e easi l y establ i shed, si nce they can be deduced fr om the fact
that the C(a,b) coeffi ci ents ar e cal cul ated pr i mar i l y by convol vi ng and s, and
usi ng conventi onal formul as. The quanti ty that comes i nto pl ay i s the
sel f-r epr oducti on functi on U(a,b), whi ch i s obtai ned by anal yzi ng the wavel et
as i f i t was a si gnal :
.
From the resul ts for coeffi ci ents we deduce the pr oper ti es of the detai l s (and of
the appr oxi mati ons), by usi ng the for mul a:
,
where the C(j,k) coeffi ci ents are random vari abl es and the functi ons are
not. I f the suppor t of i s fi ni te, onl y a fi ni te number of ter ms wi l l be summed.
C j k ( , ) k Z ,

k Z

U a b ( , )
1
a
-------
x b
a
-----------


x ( ) x d
R

=
D
j
n ( ) C j k ( , )
j k ,
n ( )
k Z

j k ,

W avelet Appli cati ons: M ore Detai l


6-79
De-Noising
Thi s secti on di scusses the pr obl em of si gnal recover y from noi sy data. Thi s
probl em i s easy to under stand l ooki ng at the fol l owi ng si mpl e exampl e, where
a sl ow si ne i s cor rupted by a whi te noi se.
Figure 6-24: What is de-noising?
100 200 300 400 500 600 700 800 900 1000
5
0
5
Original signal
100 200 300 400 500 600 700 800 900 1000
5
0
5
Noisy signal
100 200 300 400 500 600 700 800 900 1000
5
0
5
Denoised signal
6 Advanced C oncepts
6-80
The Basic One-Dimensional Model
The under l yi ng model for the noi sy si gnal i s basi cal l y of the fol l owi ng form:
where ti me n i s equal l y spaced.
I n the si mpl est model we suppose that e(n) i s a Gaussi an whi te noi se N(0,1) and
the noi se l evel s i s supposed to be equal to 1.
The de-noi si ng objecti ve i s to suppr ess the noi se part of the si gnal s and to
r ecover f. From a stati sti cal vi ewpoi nt, the model i s a r egr essi on model over
ti me and the method can be vi ewed as a nonparametr i c esti mati on of the
functi on f usi ng orthogonal basi s.
De-Noising Procedure Principles
The de-noi si ng pr ocedur e pr oceeds i n thr ee steps:
1 Decompose
Choose a wavel et, choose a l evel N. Compute the wavel et decomposi ti on of
the si gnal s at l evel N.
2 Threshol d detai l coeffi ci ents
For each l evel fr om 1 to N, sel ect a threshol d and appl y soft threshol di ng to
the detai l coeffi ci ents.
3 Reconstruct
Compute wavel et reconstr ucti on based on the ori gi nal approxi mati on
coeffi ci ents of l evel N and the modi fi ed detai l coeffi ci ents of l evel s fr om
1 to N.
Two poi nts must be addr essed: how to choose the thr eshol d and how to perform
the threshol di ng.
s n ( ) f n ( ) e n ( ) + =
W avelet Appli cati ons: M ore Detai l
6-81
Soft or Hard Thresholding?
Thr eshol di ng can be done usi ng the functi on:
y t = wt hr es h( y , s or h, t hr )
whi ch r etur ns soft or har d threshol di ng of i nput y , dependi ng on the s or h
opti on. Har d threshol di ng i s the si mpl est method. Soft thr eshol di ng has ni ce
mathemati cal pr oper ti es and the cor respondi ng theor eti cal r esul ts are
avai l abl e.
Let us gi ve a si mpl e exampl e.
y = l i ns pac e ( - 1, 1, 100) ;
t hr = 0. 28;
y t har d = wt hr e s h( y , ' h' , t hr ) ;
y t s of t = wt hr e s h( y , ' s ' , t hr ) ;
Figure 6-25: Hard and soft thresholding of the signal s = x
Comment: Let t denote the thr eshol d. The hard thr eshol d si gnal i s x i f | x| > t,
and i s 0 i f | x| t. The soft threshol d si gnal i s si gn(x)(| x| - t) i f | x| > t and i s 0
i f | x| t.
Hard thr eshol di ng can be descr i bed as the usual process of setti ng to zer o the
el ements whose absol ute val ues are l ower than the thr eshol d. Soft
threshol di ng i s an extensi on of hard thr eshol di ng, fi r st setti ng to zer o the
el ements whose absol ute val ues are l ower than the thr eshol d, then shri nki ng
1 0 1
1
0.5
0
0.5
1
Original signal
1 0 1
1
0.5
0
0.5
1
Hard thresholded signal
1 0 1
1
0.5
0
0.5
1
Soft thresholded signal
6 Advanced C oncepts
6-82
the nonzero coeffi ci ents towar ds 0 (see Fi gur e 6-25). As can be seen i n the
comment of Fi gure 6-25, the hard pr ocedur e creates di sconti nui ti es at x = t,
whi l e the soft pr ocedur e does not.
Threshold Selection Rules
Accordi ng to the basi c noi se model , four thr eshol d sel ecti on r ul es ar e
i mpl emented i n the M-fi l e t hs e l e ct . Each r ul e corr esponds to a t pt r opti on i n
the command:
t hr = t hs e l e ct ( y , t pt r )
whi ch returns the thr eshol d val ue.
Opti on t pt r = ' r i gr s ur e' uses for the soft threshol d esti mator a thr eshol d
sel ecti on r ul e based on Stei ns Unbi ased Esti mate of Ri sk (quadr ati c l oss
functi on). You get an esti mate of the r i sk for a par ti cul ar threshol d val ue t.
Mi ni mi zi ng the r i sks i n t gi ves a sel ecti on of the thr eshol d val ue.
Opti on t pt r = ' s qt wol og' uses a fi xed form thr eshol d yi el di ng mi ni max
per formance mul ti pl i ed by a smal l factor proporti onal to log(length(s)).
Opti on t pt r = ' he ur s ur e ' i s a mi xture of the two previ ous opti ons. As a
resul t, i f the si gnal -to-noi se r ati o i s very smal l , the SURE esti mate i s ver y
noi sy. So i f such a si tuati on i s detected, the fi xed for m threshol d i s used.
Opti on t pt r = ' mi ni maxi ' uses a fi xed thr eshol d chosen to yi el d mi ni max
per formance for mean square err or agai nst an i deal procedure. The mi ni max
pri nci pl e i s used i n stati sti cs i n order to desi gn esti mators. Si nce the
de-noi sed si gnal can be assi mi l ated to the esti mator of the unknown
regr essi on functi on, the mi ni max esti mator i s the opti on that r eal i zes the
mi ni mum of the maxi mum mean square er ror obtai ned for the wor st
functi on i n a gi ven set.
Option Threshold selection rule
' r i gr s ur e ' Sel ecti on usi ng pri nci pl e of Stei ns Unbi ased Ri sk
Esti mate (SURE)
' s qt wol og' Fi xed form thr eshol d equal to sqrt(2log(length(s)))
' heur s ur e ' Sel ecti on usi ng a mi xture of the fi rst two opti ons
' mi ni maxi ' Sel ecti on usi ng mi ni max pr i nci pl e
W avelet Appli cati ons: M ore Detai l
6-83
Typi cal l y i t i s i nteresti ng to show how t hs el ec t wor ks i f y i s a Gaussi an whi te
noi se N(0,1) si gnal .
y = r andn( 1, 1000) ; t hr = t hs e l e ct ( y , ' r i gr s ur e' )
t hr =
2. 0735
t hr = t hs el e ct ( y , ' s qt wol og' )
t hr =
3. 7169
t hr = t hs el e ct ( y , ' he ur s ur e' )
t hr =
3. 7169
t hr = t hs el e ct ( y , ' mi ni max i ' )
t hr =
2. 2163
Because y i s a standard Gaussi an whi te noi se, we expect that each method ki l l s
roughl y al l the coeffi ci ents. For Stei ns Unbi ased Ri sk Esti mate and mi ni max
threshol ds, roughl y 3% of coeffi ci ents ar e saved. For other sel ecti on rul es, al l
the coeffi ci ents are set to 0.
We know that the detai l coeffi ci ents vector i s the superposi ti on of the
coeffi ci ents of f and the coeffi ci ents of e, and that the decomposi ti on of e l eads
to detai l coeffi ci ents, whi ch are standard Gaussi an whi te noi ses.
So mi ni max and SURE threshol d sel ecti on r ul es ar e more conservati ve and
woul d be more conveni ent when smal l detai l s of functi on f l i e i n the noi se
range. The two other r ul es r emove the noi se more effi ci entl y. The opti on
' he ur s ur e ' i s a compromi se. I n thi s exampl e, the fi xed form threshol d wi ns.
Recal l i ng step 2 of the de-noi se procedure, the functi on t hs e l e ct per for ms a
threshol d sel ecti on and then each l evel i s thr eshol ded. Thi s second step can be
done usi ng wt hc oe f , di rectl y handl i ng the wavel et decomposi ti on structure of
the ori gi nal si gnal s.
6 Advanced C oncepts
6-84
Dealing with Unscaled Noise and Non-White Noise
I t i s cl ear that i n pr acti ce the basi c model cannot be used di r ectl y. We exami ne
her e the opti ons avai l abl e i n the mai n de-noi si ng functi on wden, i n order to deal
wi th model devi ati ons.
The si mpl est use of wden i s:
s d = wde n( s , t pt r , s or h, s cal , n, wav )
whi ch returns the de-noi sed versi on s d of the ori gi nal si gnal s obtai ned usi ng
the t pt r threshol d sel ecti on rul e. Other parameter s needed ar e s or h,
threshol di ng of detai l s coeffi ci ents of the decomposi ti on at l evel n of s by the
wavel et cal l ed wav. The r emai ni ng parameter s cal i s to be speci fi ed. I t
cor responds to threshol ds rescal i ng methods.
Opti on s cal = ' one' corr esponds to the basi c model .
I n gener al you can i gnor e the noi se l evel that must be esti mated. The detai l
coeffi ci ents cD
1
(the fi nest scal e) are essenti al l y noi se coeffi ci ents wi th
standard devi ati on equal to . The medi an absol ute devi ati on of the
coeffi ci ents i s a r obust esti mate of . The use of a robust esti mate i s cr uci al
for two r easons. The fi rst one i s that i f l evel 1 coeffi ci ents contai n f detai l s,
these detai l s ar e concentrated i n few coeffi ci ents i f the functi on f i s
suffi ci entl y r egul ar. The second r eason i s to avoi d si gnal end effects, whi ch
are pur e ar ti facts due to computati ons on the edges.
Opti on s c al = ' s l n' handl es thr eshol d r escal i ng usi ng a si ngl e esti mati on
of l evel noi se based on the fi rst l evel coeffi ci ents.
When you suspect a nonwhi te noi se e, thr eshol ds must be r escal ed by a
l evel -dependent esti mati on of the l evel noi se. The same ki nd of str ategy i s
used by esti mati ng
lev
l evel by l evel . Thi s esti mati on i s i mpl emented i n
M-fi l e wnoi s e s t , di rectl y handl i ng the wavel et decomposi ti on structure of
the ori gi nal si gnal s.
Opti on s cal = ' ml n' handl es threshol d r escal i ng usi ng a l evel -dependent
esti mati on of the l evel noi se.
Option Corresponding model
' one ' Basi c model
' s l n' Basi c model wi th unscal ed noi se
' ml n' Basi c model wi th non-whi te noi se
W avelet Appli cati ons: M ore Detai l
6-85
A more general pr ocedur e wdencmp per for ms wavel et coeffi ci ents thr eshol di ng
for both de-noi si ng and compressi on pur poses di r ectl y handl i ng
one-di mensi onal and two-di mensi onal si gnal s. I t al l ows you to defi ne your own
threshol di ng str ategy sel ecti ng i n:
xd = wde nc mp( opt , x, wav , n, t hr , s or h, kee papp) ;
opt = ' gbl ' and t hr i s a posi ti ve r eal number for uni form threshol d
opt = ' l vd' and t hr i s a vector for l evel dependent threshol d.
ke epapp = 1 to keep appr oxi mati on coeffi ci ents, as previ ousl y and
ke epapp = 0 to al l ow approxi mati on coeffi ci ents threshol di ng.
x i s the si gnal to be de-noi sed and wav, n, s or h are the same as above.
De-Noising in Action
We begi n wi th exampl es of one-di mensi onal de-noi si ng methods wi th the fi rst
exampl e cr edi ted to Donoho and Johnstone. For the fi rst test functi on avai l abl e
usi ng wnoi s e, use the fol l owi ng M-fi l e.
% Set s i gnal t o noi s e r at i o and s et r and s ee d.
s nr = 4; i ni t = 2055615866;
% Gener at e or i gi nal s i gnal xr ef and a noi s y ve r s i on x addi ng
% a s t andar d Gaus s i an whi t e noi s e .
[ xr ef , x ] = wnoi s e( 1, 11, s nr , i ni t ) ;
% De- noi s e noi s y s i gnal us i ng s of t heur i s t i c SURE t hr es hol di ng
% and s cal e d noi s e opt i on, on det ai l c oe f f i c i e nt s obt ai ne d
% f r om t he dec ompos i t i on of x , at l e ve l 3 by s y m8 wav el et .
x d = wden( x , ' heur s ur e' , ' s ' , ' one ' , 3, ' s y m8' ) ;
6 Advanced C oncepts
6-86
Figure 6-26: Blocks de-noising
So despi te the fact that onl y a smal l number of l ar ge coeffi ci ents char acteri ze
the ori gi nal si gnal , the method performs ver y wel l (see Fi gure 6-26). I f you
want to see more about how the thr eshol di ng works, use the GUI .
As a second exampl e, l et us try the method on the hi ghl y per tur bed par t of the
el ectri cal si gnal studi ed above.
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
10
0
10
20
Original signal
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
10
0
10
20
Noisy signal
Signal to noise ratio = 4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
10
0
10
20
Denoised signal
W avelet Appli cati ons: M ore Detai l
6-87
Accordi ng to thi s previ ous anal ysi s, l et us use db3 wavel et and decompose at
l evel 3. I n order to deal wi th the composi te noi se natur e, l et us tr y a
l evel -dependent noi se si ze esti mati on.
%Load e l e ct r i c al s i gnal and s el ec t par t of i t .
l oad l e l e cc um; i ndx = 2000: 3450;
x = l el ec cum( i ndx) ;
% Fi nd f i r s t v al ue i n or der t o av oi d e dge ef f e c t s .
deb = x ( 1) ;
% De- noi s e s i gnal us i ng s of t f i xe d f or m t hr e s hol di ng
% and unknown noi s e opt i on.
x d = wden( x - de b, ' s qt wol og' , ' s ' , ' ml n' , 3, ' db3' ) +deb;
Figure 6-27: Electrical signal de-noising
The resul t i s qui te good i n spi te of the ti me heterogenei ty of the natur e of the
noi se after and before the begi nni ng of the sensor fai l ur e ar ound ti me 2450.
2000 2500 3000 3500
100
200
300
400
500
600
Original electrical Signal
2000 2500 3000 3500
100
200
300
400
500
600
Denoised Signal
6 Advanced C oncepts
6-88
Extension to Image De-Noising
The de-noi si ng method descri bed for the one-di mensi onal case appl i es al so to
i mages and appl i es wel l to geometr i cal i mages. A di rect tr ansl ati on of the
one-di mensi onal model i s:
s(i,j) = f(i,j) + e(i,j), i,j = 0, ..., m-1
where e i s a whi te Gaussi an noi se wi th uni t vari ance.
The two-di mensi onal de-noi si ng procedure has the same thr ee steps and uses
two-di mensi onal wavel et tool s i nstead of one-di mensi onal ones. For the
threshol d sel ecti on m
2
i s used i nstead of n i f the fi xed form threshol d i s used.
Note that except for the automati c one-di mensi onal de-noi si ng case,
de-noi si ng and compr essi on ar e perfor med usi ng wde ncmp. As an exampl e, you
can use the fol l owi ng M-fi l e i l l ustrati ng the de-noi si ng of a syntheti c i mage.
%Load or i gi nal i mage.
l oad s i ns i n
% Gener at e noi s y i mage.
i ni t =2055615866; r andn( ' s ee d' , i ni t ) ;
x = X + 18*r andn( s i z e ( X) ) ;
% Fi nd def aul t v al ues us i ng ddencmp.
% I n t hi s cas e f i x e d f or m t hr e s hol d i s us ed
% wi t h e s t i mat i on of l e ve l noi s e , t hr e s hol di ng
% mode i s s of t and t he appr ox i mat i on c oe f f i ci ent s
% ar e ke pt .
[ t hr , s or h, ke epapp] = ddencmp( ' de n' , ' wv ' , x ) ;
% t hr i s r oughl y e qual t o 18*s qr t ( l og( pr od( s i z e ( x ) ) ) )
t hr
t hr =
80. 6881
% De- noi s e i mage us i ng gl obal t hr e s hol di ng opt i on.
x d = wde nc mp( ' gbl ' , x, ' s ym4' , 2, t hr , s or h, ke epapp) ;
W avelet Appli cati ons: M ore Detai l
6-89
The resul t shown bel ow i s acceptabl e.
Figure 6-28: Image de-noising
More About De-Noising
Recentl y, new de-noi si ng methods based on wavel et decomposi ti on appear
mai nl y i ni ti ated by Donoho and Johnstone i n the USA, and Ker kyachar i an and
Pi car d i n Fr ance. Meyer consi der s that thi s topi c i s one of the most si gni fi cant
appl i cati ons of wavel ets (cf. [Mey93] p. 173). Thi s chapter and the
cor respondi ng M-fi l es fol l ow the work of the above menti oned researchers.
Mor e detai l s can be found i n the bi bl i ogr aphy by Donoho.
Original Image
20 40 60 80 100 120
20
40
60
80
100
120
Noisy Image
20 40 60 80 100 120
20
40
60
80
100
120
Denoised Image
20 40 60 80 100 120
20
40
60
80
100
120
6 Advanced C oncepts
6-90
Data Compression
The compressi on featur es of a gi ven wavel et basi s ar e pr i mari l y l i nked to the
r el ati ve scarceness of the wavel et domai n representati on for the si gnal . The
noti on behi nd compr essi on i s based on the concept that the r egul ar si gnal
component can be accur atel y appr oxi mated usi ng the fol l owi ng el ements: a
smal l number of approxi mati on coeffi ci ents (at a sui tabl y chosen l evel ) and
some of the detai l coeffi ci ents.
Li ke de-noi si ng, the compressi on pr ocedur e contai ns three steps:
1 Decompose
2 Threshol d detai l coeffi ci ents
For each l evel fr om 1 to N, a threshol d i s sel ected and hard threshol di ng i s
appl i ed to the detai l coeffi ci ents.
3 Reconstruct
The di fference wi th the de-noi si ng procedur e i s found i n step 2. Ther e ar e two
compr essi on appr oaches avai l abl e. The fi r st consi sts of taki ng the wavel et
expansi on of the si gnal and keepi ng the l argest absol ute val ue coeffi ci ents. I n
thi s case you can set a gl obal threshol d, a compressi on per for mance, or a
r el ati ve square norm r ecovery per for mance. Thus onl y a si ngl e par ameter
needs to be sel ected. The second approach consi sts of appl yi ng vi sual l y
determi ned l evel -dependent threshol ds.
Let us exami ne two r eal -l i fe exampl es of compressi on usi ng gl obal
threshol di ng, for a gi ven and unopti mi zed wavel et choi ce, to pr oduce a nearl y
compl ete squar e nor m recovery for a si gnal (see Fi gur e 6-29) and for an i mage
(see Fi gur e 6-30).
% Load e l e ct r i cal s i gnal and s el ec t a par t .
l oad l e l ec cum; i ndx = 2600: 3100;
x = l el e cc um( i ndx) ;
% Per f or m wave l e t dec ompos i t i on of t he s i gnal .
n = 3; w = ' db3' ;
[ c, l ] = wave de c( x, n, w) ;
% Compr e s s us i ng a f i xe d t hr e s hol d.
t hr = 35;
[ xd, c xd, l x d, pe r f 0, per f l 2] = wdencmp( ' gbl ' , c , l , w, n, t hr , ' h' , 1) ;
W avelet Appli cati ons: M ore Detai l
6-91
Figure 6-29: Signal compression
% Load or i gi nal i mage.
l oad woman; x = X( 100: 200, 100: 200) ;
nbc = s i z e( map, 1) ;
% Wav el et de compos i t i on of x.
n = 5; w = ' s y m2' ; [ c, l ] = wave de c2( x, n, w) ;
% Wav el et c oef f i ci ent s t hr e s hol di ng.
t hr = 20;
[ xd, c xd, l xd, pe r f 0, pe r f l 2] = wde nc mp( ' gbl ' , c, l , w, n, t hr , ' h' , 1) ;
2600 2650 2700 2750 2800 2850 2900 2950 3000 3050 3100
150
200
250
300
350
400
450
Original signal
2600 2650 2700 2750 2800 2850 2900 2950 3000 3050 3100
150
200
250
300
350
400
450
Compressed signal
2norm rec.: 99.95 % zero cfs: 85.08
6 Advanced C oncepts
6-92
Figure 6-30: Image compression
I f the wavel et r epr esentati on i s too dense, si mi l ar strategi es can be used i n the
wavel et packet framewor k i n or der to obtai n a spar ser r epresentati on. You can
then deter mi ne the best decomposi ti on wi th r espect to a sui tabl y sel ected
entropy-l i ke cr i teri on, whi ch cor responds to the sel ected pur pose (de-noi si ng or
compr essi on).
Original image
20 40 60 80 100
20
40
60
80
100
2norm rec.: 99.14 % nul cfs : 79.51
threshold = 20
20 40 60 80 100
20
40
60
80
100
W avelet Appli cati ons: M ore Detai l
6-93
Default Values for De-Noising and Compression
De-noising.
Automatic mode.
Wavelet 1-D or 2-D:
The gl obal thr eshol d i s deri ved from Donoho-Johnstone fi xed form thr eshol d
str ategy for an unscal ed whi te noi se.
Manual mode.
Wavelet 1-D:
The l evel -dependent threshol ds are deri ved fr om Bi rge-Massart strategy wi th
= 3.
Wavelet 2-D:
The gl obal thr eshol d i s deri ved from Donoho-Johnstone fi xed form thr eshol d
str ategy for an unscal ed whi te noi se.
Compression.
Automatic mode.
Wavelet 1-D or 2-D and Wavelet Packet 1-D:
The gl obal thr eshol d i s der i ved from an equal bal ance between the percentages
of r etai ned energy and number of zeros.
Wavelet Packet 2-D:
The gl obal threshol d i s the squar e root of the threshol d val ue deri ved from an
equal bal ance between the percentages of retai ned energy and number of zeros.
6 Advanced C oncepts
6-94
Manual mode.
Wavelet 1-D:
The l evel -dependent threshol ds ar e der i ved from Bi r ge-Massart strategy wi th
= 1.5.
Wavelet 2-D:
The gl obal threshol d i s based on the anal ysi s of the l evel -one detai l coeffi ci ents
c d1 and i s equal to t = medi an( abs ( c d1) ) or 0. 005*max ( abs ( c d1) ) i f t i s zer o.
About the Birge-Massart Strategy
The Bi rge-Massart str ategy i s based on r esul ts on adapti ve functi onal
esti mati on i n r egressi on or densi ty contexts (mor e detai l s can be found i n the
r efer ence [Bi rM95] at the end of thi s Chapter).
Fortunatel y, thi s sophi sti cated esti mate can be i mpl emented i n a ver y si mpl e
way, l i ke the pr evi ousl y descr i bed pr ocedur es for de-noi si ng or compr essi on.
I t uses l evel -dependent threshol ds obtai ned by the fol l owi ng wavel et
coeffi ci ents sel ecti on rul e.
Let j
0
be the decomposi ti on l evel , m be the l ength of coarsest appr oxi mati on
coeffi ci ents over 2 and be a r eal greater than 1.
The numbers j
0
, m and defi ne the str ategy:
at l evel j
0
+1 (and coar ser l evel s), ever ythi ng i s kept.
for l evel j from 1 to j
0
, the kj l arger coeffi ci ents i n absol ute val ue, ar e kept
wi th:
Typi cal l y the parameter i s equal to 1.5 for compr essi on and i s equal to 3 for
de-noi si ng.
kj m j
0
1 j + ( )

=
W avelet Packets
6-95
Wavelet Packets
The wavel et packet method i s a general i zati on of wavel et decomposi ti on that
offer s a r i cher si gnal anal ysi s.
Wavel et packet atoms are wavefor ms i ndexed by thr ee natur al l y i nterpr eted
parameter s: posi ti on and scal e (as i n wavel et decomposi ti on and frequency).
For a gi ven orthogonal wavel et functi on, we generate a l i br ary of wavel et
packet bases. Each of these bases offer s a parti cul ar way of codi ng si gnal s,
preser vi ng gl obal energy and reconstr ucti ng exact features. The wavel et
packets can then be used for numer ous expansi ons of a gi ven si gnal . We then
sel ect the most sui tabl e decomposi ti on of a gi ven si gnal wi th respect to an
entr opy-based cr i teri on.
There exi st si mpl e and effi ci ent al gori thms for both wavel et packet
decomposi ti on and opti mal decomposi ti on sel ecti on. We can then pr oduce
adapti ve fi l teri ng al gor i thms wi th di r ect appl i cati ons i n opti mal si gnal codi ng
and data compr essi on.
From Wavelets to Wavelet Packets: Decomposing
the Details
I n the or thogonal wavel et decomposi ti on procedure, the generi c step spl i ts the
approxi mati on coeffi ci ents i nto two parts. After spl i tti ng we obtai n a vector of
approxi mati on coeffi ci ents and a vector of detai l coeffi ci ents, both at a coarser
scal e. The i nfor mati on l ost between two successi ve approxi mati ons i s captur ed
i n the detai l coeffi ci ents. Then next step consi sts of spl i tti ng the new
approxi mati on coeffi ci ent vector ; successi ve detai l s ar e never re-anal yzed.
I n the corr espondi ng wavel et packet si tuati on, each detai l coeffi ci ent vector i s
al so decomposed i nto two par ts usi ng the same appr oach as i n appr oxi mati on
vector spl i tti ng. Thi s offer s the ri chest anal ysi s: the compl ete bi nary tr ee i s
produced as shown i n Fi gur e 6-31.
6 Advanced C oncepts
6-96
Figure 6-31: Wavelet packet decomposition tree at level 3
The i dea of thi s decomposi ti on i s to start from a scal e-or i ented decomposi ti on
and then to anal yze the obtai ned si gnal s on fr equency subbands.
Wavelet Packets in Action: An Introduction
The fol l owi ng si mpl e exampl es i l l ustrate cer tai n di fferences between wavel et
anal ysi s and wavel et packet anal ysi s.
Example 1: Analyzing a Sine Function
The si gnal to be anal yzed i s a sampl ed si ne functi on of peri od 8. I n order to
si mpl i fy the presentati on, the l ength i s 8192 and the haar wavel et i s used. Onl y
a porti on of the si gnal i s di spl ayed. Fi gure 6-32 contai ns the ti me-fr equency
pl ot (x-axi s i s ti me and y-axi s i s frequency, hi gh to l ow fr om the top to the
bottom) for the wavel et decomposi ti on (on the l eft) and for the wavel et packet
decomposi ti on (on the r i ght), both cor respondi ng to a decomposi ti on at l evel 6.
Wavel et decomposi ti on l ocal i zes the peri od of the si ne wi thi n the i nter val
[8,16]. Wavel et packets provi de a more preci se esti mati on of the actual per i od.
Signal s = A(0)
A(1)
DD(2)
AD(2) DA(2) AA(2)
DDD(3) ADD(3) DAD(3) AAD(3)
DDA(3) ADA(3) DAA(3) AAA(3)
D(1)
W avelet Packets
6-97
Figure 6-32: Wavelets (left) versus wavelet packets (right): a sine function
Example 2: Analyzing a Chirp Signal
The si gnal to be anal yzed i s a chi r p: an osci l l atory si gnal wi th i ncr easi ng
modul ati on si n(250t
2
) sampl ed 512 ti mes on [0, 1]. For thi s l i near chi rp, the
deri vati ve of the phase i s l i near . On the l eft of Fi gure 6-33, a wavel et anal ysi s
does not easi l y detect thi s ti me-fr equency property of the si gnal . But on the
ri ght of Fi gure 6-33, the l i near sl ope for the greatest wavel et packet coeffi ci ents
i n absol ute val ue i s obvi ous. The same experi ment can be done wi th a
quadrati c chi r p of the form si n(kt
3
) i n whi ch the gr eatest wavel et packet
coeffi ci ents exhi bi t a quadrati c ti me frequency pattern.
6 Advanced C oncepts
6-98
Figure 6-33: Wavelets (left) versus wavelet packets (right):
damped oscillations.
Building Wavelet Packets
The computati on scheme for wavel et packets generati on, i s easy when usi ng an
orthogonal wavel et. We star t wi th the two fi l ter s of l ength 2N, denoted h(n) and
g(n), cor respondi ng to the wavel et. They ar e, r especti vel y, the r eversed versi ons
of the l ow-pass decomposi ti on fi l ter and the hi gh-pass decomposi ti on fi l ter
di vi ded by . 2
W avelet Packets
6-99
Now by i nducti on l et us defi ne the fol l owi ng sequence of functi ons
(W
n
(x), n = 0, 1, 2, ...) by:
where W
0
(x) = (x) i s the scal i ng functi on and W
1
(x) = (x) i s the wavel et
functi on.
For exampl e for the Haar wavel et we have:
and .
The equati ons become:
and .
W
0
(x) = (x) i s the Haar scal i ng functi on and W
1
(x) = (x) i s the Haar wavel et,
both suppor ted i n [0, 1]. Then we can obtai n W
2n
by addi ng two 1/2-scal ed
ver si ons of W
n
wi th di sti nct supports [0,1/2] and [1/2,1] and obtai n W
2n+1
by
subtracti ng the same versi ons of W
n
.
W
2n
x ( ) 2 h k ( )W
n
2x k ( )
k 0 =
2N 1

=
W
2n 1 +
x ( ) 2 g k ( )W
n
2x k ( )
k 0 =
2N 1

=
N 1 h 0 ( ) , h 1 ( ) 1 2 = = = g 0 ( ) g 1 ( ) 1 2 = =
W
2n
x ( ) W
n
2x ( ) W
n
2x 1 ( ) + = W
2n 1 +
x ( ) W
n
2x ( ) W
n
2x 1 ( ) =
6 Advanced C oncepts
6-100
For n = 0 to 7, we have the W-functi ons shown bel ow.
Figure 6-34: The Haar wavelet packets
Thi s can be obtai ned usi ng the fol l owi ng command:
[ wf un, x gr i d] = wpf un( ' db1' , 7, 5) ;
whi ch returns i n wf un the approxi mate val ues of W
n
for n = 0 to 7, computed on
a 1/2
5
gri d of the support xgr i d.
0 0.5 1
0
0.5
1
W0
0 0.5 1
1.5
1
0.5
0
0.5
1
1.5
W1
0 0.5 1
1.5
1
0.5
0
0.5
1
1.5
W2
0 0.5 1
1.5
1
0.5
0
0.5
1
1.5
W3
0 0.5 1
1.5
1
0.5
0
0.5
1
1.5
W4
0 0.5 1
1.5
1
0.5
0
0.5
1
1.5
W5
0 0.5 1
1.5
1
0.5
0
0.5
1
1.5
W6
0 0.5 1
1.5
1
0.5
0
0.5
1
1.5
W7
W avelet Packets
6-101
Star ti ng fr om more regul ar ori gi nal wavel ets and usi ng a si mi l ar constructi on,
we obtai n smoothed ver si ons of thi s system of W-functi ons, al l wi th support i n
the i nterval [0, 2N-1]. Fi gur e 6-35 presents the system of W-functi ons for the
ori gi nal db2 wavel et.
Figure 6-35: The db2 wavelet packets
Wavelet Packet Atoms
Star ti ng fr om the functi ons and fol l owi ng the same l i ne l eadi ng
to or thogonal wavel ets, we consi der the three-i ndexed fami l y of anal yzi ng
functi ons (the waveforms):
wher e and .
0 2 4
0.5
0
0.5
1
1.5
W0
0 2 4
2
1
0
1
2
W1
0 2 4
2
1
0
1
2
3
W2
0 2 4
2
1
0
1
2
3
W3
0 2 4
2
1
0
1
2
3
W4
0 2 4
2
1
0
1
2
3
W5
0 2 4
2
1
0
1
2
3
W6
0 2 4
2
1
0
1
2
3
W7
W
n
x ( ) n N , ( )
W
j n k , ,
x ( ) 2
j 2
W
n
2
j
x k ( ) = n N j k ( , ) Z
2

6 Advanced C oncepts
6-102
As i n the wavel et framewor k, k can be i nterpreted as a ti me-l ocal i zati on
par ameter and j as a scal e par ameter. So what i s the i nter pretati on of n?
As can be seen i n the previ ous fi gur es, W
n
(x) osci l l ates approxi matel y n ti mes.
So for fi xed val ues of j and k, W
j,n,k
anal yzes the fl uctuati ons of the si gnal
r oughl y around the posi ti on , at the scal e and at vari ous frequenci es
for the di fferent admi ssi bl e val ues of the l ast par ameter n.
I n fact exami ni ng car eful l y the wavel et packets di spl ayed i n Fi gure 6-34 and
Fi gure 6-35, the natur al l y order ed W
n
for n = 0, 1, ..., 7, ... does not match exactl y
the pr oper ty that W
m
osci l l ates more than W
m
i f m > m. Mor e pr eci sel y,
counti ng the number of zer o-crossi ng for the db1 wavel et packets, we have:
So i n order to restor e the pr oper ty that the mai n frequency i ncr eases
monotoni cal l y wi th the or der , i t i s conveni ent to defi ne the frequency or der
obtai ned fr om the natur al one r ecursi vel y.
To anal yze a si gnal (the chi r p of exampl e 2 for i nstance), i t i s better to pl ot the
wavel et packet coeffi ci ents fol l owi ng the frequency order (on the r i ght of the
Fi gure 6-36) fr om the l ow frequenci es at the bottom to the hi gh frequenci es at
the top, r ather than natural l y or der ed coeffi ci ents (on the l eft of Fi gur e 6-36).
Natur al or der n 0 1 2 3 4 5 6 7
Number of zer o-crossi ng for
db1 W
n
2 3 5 4 9 8 6 7
Natural order n 0 1 2 3 4 5 6 7
Frequency or der (n) 0 1 3 2 6 7 5 4
2
j
k 2
j
W avelet Packets
6-103
Figure 6-36: Natural and frequency ordered wavelet packets coefficients
The two opti ons are avai l abl e when the GUI tool s ar e used, si nce the packets
ar e organi zed fol l owi ng the natural order (see bel ow) i n or der to preser ve
consi stency.
6 Advanced C oncepts
6-104
Organizing the Wavelet Packets
The set of functi ons: W
j,n
= (W
j,n,k
(x), ) i s the (j,n) wavel et packet. For
posi ti ve val ues of i nteger s j and n, wavel et packets ar e or gani zed i n tr ees. The
tr ee i n Fi gure 6-37 i s created i n or der to gi ve a maxi mum l evel decomposi ti on
equal to 3. For each scal e j, the possi bl e val ues of parameter n are: 0, 1, ..., 2j -1.
Figure 6-37: Wavelet packets organized in a tree, scale j defines depth and
frequency n defines position in the tree
The notati on W
j,n
, wher e j denotes scal e parameter and n the frequency
par ameter, i s consi stent wi th the usual depth-posi ti on tr ee l abel i ng.
We have , and .
I t turns out that the l i br ary of wavel et packet bases contai ns the wavel et basi s.
Mor e pr eci sel y i f V
0
denotes the space (spanned by the fami l y W
0,0
) i n whi ch the
si gnal to be anal yzed l i es then (W
d,1
; d 1) i s an orthogonal basi s of V
0
.
For every stri ctl y posi ti ve i nteger D, (W
D,0
, (W
d,1
; 1 d D)) i s an or thogonal
basi s of V
0
.
We al so know that {(W
j+1,2n
),(W
j+1,2n+1
)} i s an orthogonal basi s of the space
spanned by W
j,n
.
k Z
W
0,0
W
3,4
W
2,2
W
1,1
W
3,3
W
3,2
W
3,1
W
3,0
W
2,1
W
2,0
W
1,0
W
3,5
W
2,3
W
3,7
W
3,6
W
0 0 ,
x k ( ) k Z , ( ) = W
1 1 ,
x k ( ) k Z ) , ( =
W avelet Packets
6-105
Thi s l ast pr oper ty gi ves a pr eci se i nter pretati on of spl i tti ng i n the wavel et
packet or gani zati on tree, because al l the devel oped nodes ar e of the form shown
i n the fi gure bel ow.
Figure 6-38: Wavelet packet tree: split and merge
I t fol l ows that the l eaves of every connected bi nary subtr ee of the wavel et
packet tree corr espond to an or thogonal basi s of the i ni ti al space. For a fi ni te
energy si gnal , any wavel et packet basi s wi l l pr ovi de exact reconstr ucti on and
offer a speci fi c way of codi ng the si gnal , usi ng i nfor mati on al l ocati on i n
frequency scal e subbands.
Choosing the Optimal Decomposition
Based on the or gani zati on of the wavel et packet l i br ary, i t i s natur al to count
the decomposi ti ons i ssued from a gi ven or thogonal wavel et. As a r esul t, a
si gnal of l ength N = 2
L
can be expanded i n at most 2
N
di ffer ent ways, the
number of bi nary subtr ees of a compl ete bi nar y subtree of depth L. As thi s
number may be very l ar ge, and si nce expl i ci t enumer ati on i s general l y
unmanageabl e, i t i s i nteresti ng to fi nd an opti mal decomposi ti on wi th respect
to a conveni ent cri ter i on, computabl e by an effi ci ent al gori thm. We are l ooki ng
for a mi ni mum of the cri teri on.
Functi onal s veri fyi ng an addi ti vi ty-type property ar e wel l sui ted for effi ci ent
sear chi ng of bi nar y-tr ee str uctur es and the fundamental spl i tti ng. Cl assi cal
entr opy-based cr i teri a match these condi ti ons and descri be
i nfor mati on-r el ated pr oper ti es for an accurate r epresentati on of a gi ven si gnal .
Entropy i s a common concept i n many fi el ds, mai nl y i n si gnal pr ocessi ng. Let
us l i st four di fferent entropy cri teri a (see [Coi W92]), many other s are avai l abl e
and can be easi l y i ntegr ated (type he l p we nt r opy). I n the fol l owi ng expr essi ons
s i s the si gnal and (s
i
)
i
the coeffi ci ents of s i n an orthonor mal basi s.
W
j,n
W
j+1,2n W
j+1,2n+1
6 Advanced C oncepts
6-106
The entr opy E must be an addi ti ve cost functi on such that E(0) = 0 and
.
The (non-nor mal i zed) Shannon entr opy.
so
wi th the conventi on 0l og(0) = 0.
The concentr ati on i n l
p
nor m wi th 1 p < 2.
so .
The l ogari thm of the ener gy entropy.
so
wi th the conventi on l og(0) = 0.
The threshol d entropy.
i f and 0 el sewher e so {such that } i s the
number of ti me i nstants when the si gnal i s greater than a thr eshol d .
These entr opy functi ons ar e avai l abl e usi ng the went r opy M-fi l e.
E s ( ) E s
i
( )
i

=
E1 s
i
( ) s
i
2
s
i
2
( ) log = E1 s ( ) s
i
2
s
i
2
( ) log
i

=
E2 s
i
( ) s
i
p
= E2 s ( ) s
i
p
s
p
p
=
i

=
E3 s
i
( ) s
i
2
( ) log = E3 s ( ) s
i
2
( ) log
i

=
E4 s
i
( ) 1 = s
i
> E4 s ( ) # = s
i
>
W avelet Packets
6-107
Example 1: Compute Various Entropies.
1 Generate a si gnal of ener gy equal to 1.
s = ones ( 1, 16) *0. 25;
2 Compute Shannon entr opy of s.
e 1 = we nt r opy( s , ' s hannon' )
e 1 = 2. 7726
3 Compute l
1.5
entr opy of s, equi val ent to nor m( s , 1. 5)
1.5
.
e 2 = we nt r opy( s , ' nor m' , 1. 5)
e 2 = 2
4 Compute the l og ener gy entropy of s.
e 3 = we nt r opy( s , ' l og e ner gy ' )
e 3 = - 44. 3614
5 Compute threshol d entropy of s, usi ng a threshol d val ue of 0.24.
e 4 = we nt r opy( s , ' t hr es hol d' , 0. 24)
e 4 = 16
6 Advanced C oncepts
6-108
Example 2: Minimum-Entropy Decomposition.
Thi s si mpl e exampl e i l l ustrates the use of entr opy to deter mi ne whether a new
spl i tti ng i s of i nter est i n order to obtai n a mi ni mum-entr opy decomposi ti on.
1 We star t wi th a constant ori gi nal si gnal . Two pi eces of i nformati on are
suffi ci ent to defi ne and to r ecover the si gnal (i .e., l ength and constant val ue).
w00 = ones ( 1, 16) *0. 25;
2 Compute entropy of or i gi nal si gnal .
e 00 = we nt r opy ( w00, ' s hannon' )
e 00 = 2. 7726
3 Then spl i t w00 usi ng the haar wavel et.
[ w10, w11] = dwt ( w00, ' db1' ) ;
4 Compute entropy of appr oxi mati on at l evel 1
e 10 = we nt r opy ( w10, ' s hannon' )
e 10 = 2. 0794
The detai l of l evel 1, w11, i s zero; the entr opy e11 i s zer o. Due to the addi ti vi ty
pr oper ty the entr opy of decomposi ti on i s gi ven by e10+e11=2. 0794. Thi s has to
be compared to the i ni ti al entr opy e 00=2. 7726. We have e10 + e 11 < e 00, so
the spl i tti ng i s i nter esti ng.
5 Now spl i t w10 and not w11 si mpl y because the spl i tti ng of a nul l vector i s
wi thout i nter est, the entropy bei ng zer o.
[ w20, w21] = dwt ( w10, ' db1' ) ;
6 We have w20=0. 5*one s ( 1, 4) and w21 i s zer o. The entropy of approxi mati on
l evel 2 i s:
e 20 = we nt r opy ( w20, ' s hannon' )
e 20 = 1. 3863
Agai n we have e 20 + 0 < e10, so spl i tti ng makes the entropy decr ease.
W avelet Packets
6-109
7 Then:
[ w30, w31] = dwt ( w20, ' db1' ) ;
e 30 = went r opy ( w30, ' s hannon' )
e 30 = 0. 6931
[ w40, w41] = dwt ( w30, ' db1' )
w40 = 1. 0000
w41 = 0
e 40 = went r opy ( w40, ' s hannon' )
e 40 = 0
I n the l ast spl i tti ng oper ati on we fi nd that onl y one pi ece of i nformati on i s
needed to r econstruct the ori gi nal si gnal . The wavel et basi s at l evel 4 i s a
best basi s accordi ng to shannon entr opy (wi th nul l opti mal entr opy si nce
e 40+e 41+e31+e21+e11 = 0).
8 Al l thi s work can be performed si mpl y usi ng:
s = one s ( 1, 16) *0. 25;
9 Perform wavel et packets decomposi ti on.
[ t , d] = wpde c( s, 4, ' haar ' , ' s hannon' ) ;
The wavel et packet tree bel ow shows the nodes l abel ed wi th ori gi nal entr opy
numbers.
Figure 6-39: Entropy values
6 Advanced C oncepts
6-110
10 Now compute the best tree.
[ bt , bd] = be s t t r ee ( t , d) ;
The best tree i s di spl ayed i n the fi gure bel ow. I n thi s case, the best tree
cor responds to the wavel et tree. The nodes are l abel ed wi th opti mal entr opy.
Figure 6-40: Optimal entropy values
W avelet Packets
6-111
Wavelet Packets 1-D Decomposition Structure
Usi ng wavel et packets r equi r es tree-rel ated acti ons and l abel i ng. The
i mpl ementati on of the user i nter face i s bui l t ar ound thi s consi der ati on. See the
Refer ence Secti on for mor e i nformati on on the techni cal detai l s.
The compl ete bi nar y tree of depth D corr espondi ng to a wavel et packet
decomposi ti on tr ee (WPT) devel oped at l evel D, is shown bel ow:
Figure 6-41: Binary tree of depth 3
We have the fol l owi ng r el ati onshi ps:
Decomposition tree Subtree such that the set of leaves is a basis
Wavel et packets
decomposi ti on tr ee
Compl ete bi nary tr ee: WPT of depth D
Wavel et packets opti mal
decomposi ti on tr ee
Bi nar y subtree of WPT
Wavel et packets best-l evel
tr ee
Compl ete bi nary subtr ee of WPT
Wavel et decomposi ti on tree Left uni l ateral bi nar y subtree of WPT of
depth D
Wavel et best-basi s tr ee Left uni l ateral bi nar y subtree of WPT
6 Advanced C oncepts
6-112
We deduce the fol l owi ng defi ni ti ons of opti mal decomposi ti ons, wi th respect to
an entropy cr i ter i on E.
For any nonter mi nal node i n a compl ete bi nar y tree of depth D corr espondi ng
to a wavel et packet decomposi ti on tree, we use the fol l owi ng basi c step i n or der
to fi nd the opti mal subtree wi th r espect to a gi ven entr opy cri teri on E (where
Eopt denotes the opti mal entropy val ue):
wi th the natur al i ni ti al condi ti on on the r efer ence tr ee, Eopt(t) = E(t) for each
ter mi nal node t.
Decompositions Optimal
decomposition
Best-level
decomposition
Wavel et packet
decomposi ti ons
Search among 2
D
tr ees Search among D trees
Wavel et decomposi ti ons Search among D tr ees Search among D tr ees
Entropy condition Action on tree and on entropy labelling


E node ( ) Eopt c ( )
c child of node

If node root ( ), merge and set Eopt node ( ) E node ( ) =


E node ( ) Eopt c ( )
c child of node

> Split and set Eopt node ( ) Eopt c ( )


c child of node

=
W avelet Packets
6-113
Wavelet Packets 2-D Decomposition Structure
Exactl y as i n the wavel et decomposi ti on case, the pr ecedi ng one-di mensi onal
framewor k can be extended to i mage anal ysi s. Mi nor di rect modi fi cati ons l ead
to quaternar y tr ee rel ated defi ni ti ons. An exampl e i s shown bel ow for depth 2.
Figure 6-42: Quaternary tree of depth 2
Wavelet Packets for Compression and De-Noising
I n the wavel et packet fr amework, compr essi on and de-noi si ng i deas ar e
i denti cal as those devel oped i n the wavel et fr amework. The onl y new feature i s
a mor e compl ex anal ysi s that pr ovi des i ncreased fl exi bi l i ty. A si ngl e
decomposi ti on usi ng wavel et packets generates a l ar ge number of bases. You
can then l ook for the best repr esentati on wi th r espect to a desi gn objecti ve,
usi ng the functi on be s t t r ee wi th an entropy functi on. See Chapter 5 for detai l .
6 Advanced C oncepts
6-114
References
[AntO95] Antoni adi s, A., G. Oppenhei m, Eds.(1995), ''Wavel ets and
stati sti cs'', Lectur e Notes i n Stati sti cs 103, Spri nger Verl ag.
[BirM95] Bi r g, L., P. Massart, Pr epri nt Uni v. Par i s Sud, Fr ance 95.41 p.
1-32(1995), To appear i n Festschei ft i n honor of Le Cam (D. Pol l ard, E.
Torger sen,G. Young Eds., Spri nger Verl ag.
[Chu92a] Chui , C.K. (1992a), Wavel ets: a tutor i al i n theory and appl i cati ons'',
Academi c Press.
[Chu92b] Chui , C.K. (1992b), An i ntroducti on to wavel ets'', Academi c Pr ess.
[Coh92] Cohen, A. (1992) Ondel ettes, anal yses mul ti rsol uti on et trai tement
numri que du si gnal '', Ph. D. Thesis, Uni ver si ty of Pari s I X, Dauphi ne.
[CohDF92] Cohen, A., I . Daubechi es, J.C. Feauveau (1992) Bi orthogonal
basi s of compactl y suppor ted wavel ets'', Comm. Pure Appli. Math. , vol . 45, pp
485-560.
[CohDJ V93] Cohen, A., I . Daubechi es , B. Jawerth, P. Vi al (1993)
Mul ti resol uti on anal ysi s, wavel ets and fast wavel et transform on an i nter val ,
CRAS Par i s, Ser . A, t. 316, p. 417-421.
[CoiMW92] Coi fman, R.R., Y. Meyer, M.V. Wi cker hauser (1992), Wavel et
anal ysi s and si gnal processi ng'', i n Wavelets and their applications, M.B. Ruskai et
al . (Eds.), pp. 153-178, Jones and Bartl ett.
[CoiW92] Coi fman, R.R., M.V Wi ckerhauser , (1992), Entr opy-based
al gori thms for best basi s sel ecti on'', IEEE Trans. on Inf. Theory, vol . 38, 2, pp.
713-718.
[Dau92] Daubechi es, I . (1992), Ten l ectur es on wavel ets'', SI AM.
[DevJ L92] DeVore, R.A., B. Jawerth, B.J. Luci er (1992), I mage compressi on
through wavel et transform codi ng, I EEE Tr ans. on I nf. Theor y, vol . 38, 2, pp.
719-746.
[Don93] Donoho, D.L. (1993), Progress i n wavel et anal ysi s and WVD: a ten
mi nute tour '', i n Progr ess i n wavel et anal ysi s and appl i cati ons, Y. Meyer, S.
Roques, pp. 109-128. Fronti r es Ed.
[Don95] Donoho, D.L. (1995), De-Noi si ng by soft-threshol di ng, I EEE Trans.
on I nf. Theory, vol . 41, 3, pp. 613-627.
References
6-115
[DonJ 94a] Donoho, D.L., I .M. Johnstone(1994),I deal spati al adaptati on by
wavel et shr i nkage'', Biometrika, vol 81, pp. 425-455.
[DonJ 94b] Donoho, D.L., I .M. Johnstone(1994),I deal de-noi si ng i n an
orthonormal basi s chosen from a l i brar y of bases'', CRAS Pari s, t. 319, Ser I ,
pp. 1317-1322.
[DonJ KP95a] Donoho, D.L., I .M. Johnstone, G. Ker kyachari an, D. Pi car d
(1995), Wavel et shr i nkage: asymptopi a'', J our. Roy. Stat. Soc., ser i es B, vol . 57
no. 2, pp. 301-369.
[DonJ KP95b] Donoho, D.L., I .M. Johnstone, G. Kerkyachar i an, D. Pi card
(1995), Densi ty esti mati on by wavel et theshol di ng'', submi tted for publ i cati on
to the Annals of Stat.
[KahL95] Kahane, J.P., P.G Lemari (1995), Four i er seri es and wavel ets'',
Gor don and Research Publ i shers, Studi es i n the Devel opment of Modern
Mathemati cs, vol 3.
[Kai94] Kai ser , G. (1994), A fr i endl y gui de to wavel ets'', Bi r khauser.
[Lem90] Lemar i , P.G., Ed, (1990), Les ondel ettes en 1989'', Lecture Notes in
Mathematics, Spr i nger Verl ag.
[Mal89] Mal l at, S. (1989), ''A theor y for mul ti r esol uti on si gnal decomposi ti on:
the wavel et r epr esentati on'', I EEE Pattern Anal . and Machi ne I ntel l ., vol . 11,
no. 7, pp 674-693.
[Mey90] Meyer , Y. (1990), ''Ondel ettes et oprateurs'', Tome 1, Her mann Ed.
(Engl i sh tr ansl ati on: Wavel ets and operator s, Cambri dge Uni v. Press. 1993.)
[Mey93] Meyer, Y. (1993), ''Les ondel ettes. Al gor i thmes et appl i cati ons'', Col i n
Ed., Pari s, 2nd edi ti on. (Engl i sh transl ati on: ''Wavel ets: al gor i thms and
appl i cati ons'', SI AM).
[MeyR93] Meyer, Y., S. Roques, Eds. (1993), ''Pr ogress i n wavel et anal ysi s
and appl i cati ons'', Fronti r es Ed.
[MisMOP93a] Mi si ti , M., Y. Mi si ti , G. Oppenhei m, J.M. Poggi (1993a),
''Anal yse de si gnaux cl assi ques par dcomposi ti on en ondel ettes'', Revue de
Statistique Applique, vol . XLI , no. 4, pp 5-32.
[MisMOP93b] Mi si ti , M., Y. Mi si ti , G. Oppenhei m, J.M. Poggi (1993b),
''Ondel ettes en stati sti que et trai tement du si gnal '', Revue de Statistique
Applique, vol . XLI , no. 4, pp 33-43.
6 Advanced C oncepts
6-116
[MisMOP94] Mi si ti , M., Y. Mi si ti , G. Oppenhei m, J.M. Poggi (1994),
''Dcomposi on en ondel ettes et mthodes compar ati ves: tude d'une cour be de
char ge l ectri que'', Revue de Statistique Applique, vol . XLI I , no. 2, pp 57-77.
[StrN96] Str ang, G., T. Nguyen (1996), ''Wavel ets and fi l ter banks'',
Wel l esl ey-Cambri dge Press.
[Wic91] Wi cker hauser, M.V., (1991) ''I NRI A l ectures on wavel et packet
al gori thms'', Proceedings ondelettes et paquets d'ondes, 17-21 june,
Rocquencour t Fr ance, pp 31-99.
[Wic94] Wi cker hauser , M.V., (1994) ''Adapted wavel et anal ysi s from theory to
software al gor i thms'', A.K. Peters.

7
Addi ng Your Own
Wavel ets
7-3 Preparing to Add a New Wavelet Family
7-3 Choose the Wavel et Fami l y Ful l Name
7-3 Choose the Wavel et Fami l y Shor t Name
7-4 Determi ne the Wavel et Type
7-4 Defi ne the Or der s of Wavel ets Wi thi n the Gi ven Fami l y
7-5 Bui l d a MAT-Fi l e or M-Fi l e
7-7 Defi ne the Effecti ve Suppor t
7-8 How to Add a New Wavelet Family
7-16 After Adding a New Wavelet Family
7 Addi ng Your O wn W avelets
7-2
The Wavel et Tool box contai ns a l ot of wavel et fami l i es, but by usi ng the
wav emngr functi on, you can add new wavel ets to the exi sti ng ones i n or der to
i mpl ement your favor i te or tr y out a wavel et of your own desi gn. The tool box
al l ows you to defi ne new wavel ets for use wi th both the command l i ne functi ons
and the graphi cal tool s.
Caution: Thi s capabi l i ty must be used careful l y, because the tool box does not
check that your wavel et meets al l the mathemati cal requi si tes.
The wave mngr functi on affords extensi ve wavel et management. However, thi s
chapter focuses onl y on the addi ti on of a wavel et fami l y. For mor e compl ete
i nfor mati on, see the wav e mngr r efer ence entr y i n Chapter 8.
Thi s chapter di scusses:
Prepari ng to Add a New Wavel et Fami l y
How to Add a New Wavel et Fami l y
After Addi ng a New Wavel et Fami l y
Prepari ng to Add a N ew Wavelet Fami ly
7-3
Preparing to Add a New Wavelet Family
The wav emngr command per mi ts you to add new wavel ets and wavel et fami l i es
to the pr edefi ned ones. However, befor e you can use the wave mngr command to
add a new wavel et, you must:
1 Choose the ful l name of the wavel et fami l y (f n).
2 Choose the short name of the wavel et fami l y (f s n).
3 Deter mi ne the wavel et type (wt ).
4 Defi ne the or der s of wavel ets wi thi n the gi ven fami l y (nums ).
5 Bui l d a MAT-fi l e or a M-fi l e (f i l e ).
6 For wavelets without FI R filters: Defi ne the effecti ve support.
The remai nder of thi s secti on descri bes each of these steps.
Choose the Wavelet Family Full Name
The ful l name of the wavel et fami l y, f n, must be a stri ng. Pr edefi ned wavel et
fami l y names ar e: Haar , Daubec hi e s , Bi or Spl i nes , Coi f l et s , Sy ml e t s , Mor l e t ,
Me x i c an_hat , and Mey er .
Choose the Wavelet Family Short Name
The shor t name of the wavel et fami l y, f s n, must be a str i ng of four char acter s
or l ess. Pr edefi ned wavel et fami l y shor t names are: haar , db, bi or , c oi f , s y m,
mor l , mex h, and me yr .
7 Addi ng Your O wn W avelets
7-4
Determine the Wavelet Type
We di sti ngui sh four types of wavel ets:
Or thogonal wavel ets wi th FI R fi l ters
These wavel ets can be defi ned through the scal i ng fi l ter w. Predefi ned
fami l i es of such wavel ets i ncl ude: Haar , Daube chi e s , Coi f l et s , and Sy ml e t s .
Bi orthogonal wavel ets wi th FI R fi l ter s
These wavel ets can be defi ned thr ough the two scal i ng fi l ter s wr and wd, for
reconstr ucti on and decomposi ti on r especti vel y. The Bi or Spl i nes wavel et
fami l y i s a predefi ned fami l y of thi s type.
Or thogonal wavel ets wi thout FI R fi l ter but wi th scal e functi on
These wavel ets can be defi ned thr ough the defi ni ti on of the wavel et functi on
and the scal i ng functi on. The Mey er wavel et fami l y i s a pr edefi ned fami l y of
thi s type.
Wavel ets wi thout FI R fi l ter and wi thout scal e functi on
These wavel ets can be defi ned through the defi ni ti on of the wavel et functi on.
Predefi ned fami l i es of such wavel ets i ncl ude: Mor l e t , and Me xi can_hat .
Define the Orders of Wavelets
Within the Given Family
I f a fami l y contai ns many wavel ets, the short name and the order ar e appended
i n or der to form the wavel et name. Argument nums i s a str i ng contai ni ng the
order s separ ated wi th bl anks. Thi s argument i s not used for wavel ets of type 3
or 4, nor i s i t used for a fami l y that onl y has a si ngl e wavel et.
For exampl e, for the fi rst Daubechi es wavel ets,
f s n = ' db'
nums = ' 1 2 3'
yi el d the three wavel ets db1, db2 and db3.
For the fi rst Bi or Spl i nes wavel ets,
f s n = ' bi or '
nums = ' 1. 1 1. 3 1. 5 2. 2'
yi el d the four wavel ets bi or 1. 1, bi or 1. 3, bi or 1. 5, and bi or 2. 2.
Prepari ng to Add a N ew Wavelet Fami ly
7-5
Build a MAT-File or M-File
The wav emngr command r equi res a f i l e argument, whi ch i s a stri ng contai ni ng
a MAT-fi l e or M-fi l e name.
I f a family contains many wavelets, a M-fi l e must be defi ned and must be of a
speci fi c for m that depends on the wavel et type. The speci fi c M-fi l e for mats ar e
descr i bed i n the remai nder of thi s secti on.
I f a family contains a single wavelet, then a MAT-fi l e can be defi ned for
wavel ets of type 1. I t must have the wavel et fami l y short name (f s n) argument
as i ts name and must contai n a si ngl e vari abl e whose name i s f s n and whose
val ue i s the scal i ng fi l ter . An M-fi l e can al so be defi ned as di scussed bel ow.
Type 1 (Orthogonal with FIR Filter)
The syntax of the fi r st l i ne i n the M-fi l e must be:
f unct i on w = f i l e( wname )
where the i nput ar gument wname i s a str i ng contai ni ng the wavel et name, and
the output argument w i s the correspondi ng scal i ng fi l ter.
The fi l ter w must be of even l ength other wi se i t i s zero-padded by the tool box.
For pr edefi ned wavel ets, the scal i ng fi l ter i s of sum 1. For a new wavel et, the
nor mal i zati on i s fr ee (except 0 of course) si nce the tool box uses a sui tabl y
nor mal i zed versi on of thi s fi l ter .
Exampl es of such M-fi l es for pr edefi ned wavel ets are: dbwavf . m for
Daubechi es, c oi f wav f . m for Coi fl ets, and s y mwav f . m for Syml ets.
Type 2 (Biorthogonal with FIR Filter)
The syntax of the fi r st l i ne i n the M-fi l e must be:
f unct i on [ wr , wd] = f i l e ( wname )
where the i nput ar gument wname i s a stri ng contai ni ng the wavel et name and
the output arguments wr and wd are the cor respondi ng reconstr ucti on and
decomposi ti on scal i ng fi l ters, respecti vel y.
The fi l ters wr and wd must be of the same even l ength. I n general , i ni ti al
bi orthogonal fi l ter s do not meet these requi rements, so they ar e zero-padded by
the tool box.
7 Addi ng Your O wn W avelets
7-6
For predefi ned wavel ets, the scal i ng fi l ter s are of sum 1. For a new wavel et, the
nor mal i zati on i s fr ee (except 0 of cour se) si nce the tool box uses a sui tabl y
nor mal i zed versi on of these fi l ter s.
The M-fi l e bi or wavf . m (for Bi or Spl i ne s ) i s an exampl e of an M-fi l e for a type-2
pr edefi ned wavel et fami l y.
Type 3 (Orthogonal with Scale Function)
The syntax of the fi r st l i ne i n the M-fi l e must be:
f unct i on [ phi , ps i , t ] = f i l e ( l b, ub, n)
whi ch r etur ns val ues of the scal i ng functi on phi and of the wavel et functi on ps i
on a regul ar n-poi nt gr i d wi th i nter val s of l ength t and bounded by [ l b ub] .
The M-fi l e me ye r . m i s an exampl e of an M-fi l e for a type-3 pr edefi ned wavel et
fami l y.
Type 4 (No FIR Filter; No Scale Function)
The syntax of the fi r st l i ne i n the M-fi l e must be:
f unct i on [ ps i , t ] = f i l e ( l b, ub, n)
whi ch r etur ns val ues of the wavel et functi on ps i on a regul ar n-poi nt gri d wi th
i nterval s of l ength t and bounded by [ l b ub] .
Exampl es of type-4 M-fi l es for pr edefi ned wavel et fami l i es are me xi hat . m (for
Mex i c an_hat ) and mor l et . m (for Mor l e t ).
Prepari ng to Add a N ew Wavelet Fami ly
7-7
Define the Effective Support
Thi s defi ni ti on i s r equi red onl y for wavel ets of type 3 or 4, si nce they are not
compactl y suppor ted.
Defi ni ng the effecti ve suppor t means speci fyi ng an upper and l ower bound. For
predefi ned wavel et fami l i es, we have:
Family Lower Bound (l b) Upper Bound (ub)
Me y er 8 8
Me x i c an_hat 5 5
Mor l e t 4 4
7 Addi ng Your O wn W avelets
7-8
How to Add a New Wavelet Family
To add a new wavel et, use the wav emngr command i n one of two for ms:
wav emngr ( ' add' , f n, f s n, wt , nums , f i l e )
or
wav emngr ( ' add' , f n, f s n, wt , nums , f i l e , b) .
Here are a few exampl es to i l l ustrate how you woul d use wav emngr to add some
of the pr edefi ned wavel et fami l i es:
Example 1
Let us take the exampl e of Bi nl et s proposed by Strang and Nguyen i n the book
Wavelets and Filter Banks (See pp. 216-217).
Note: The M-fi l es used i n thi s exampl e can be found i n the wav ede mo
di r ectory.
The ful l fami l y name i s: Bi nl et s .
The shor t name of the wavel et fami l y i s: bi nl .
The wavel et type i s: 2 (Bi orthogonal wi th FI R fi l ter s).
Type Syntax
1 wave mngr ( ' add' , ' Ndaubec hi e s ' , ' ndb' , 1, ' 1 2 3 4
5' , ' dbwavf ' ) ;
1 wave mngr ( ' add' , ' Ndaubec hi e s ' , ' ndb' , 1, ' 1 2 3 4 5
**' , ' dbwav f ' ) ;
2 wave mngr ( ' add' , ' Nbi or wav f ' , ' nbi o' , 2, ' 1. 1
1. 3' , ' bi or wav f ' ) ;
3 wave mngr ( ' add' , ' Nme ye r ' , ' nme y' , 3, ' ' , ' me ye r ' , [ - 8, 8] ) ;
4 wave mngr ( ' add' , ' Nmor l et ' , ' nmor ' , 4, ' ' , ' mor l e t ' , [ - 4, 4] ) .
How to Add a N ew Wavelet Fami ly
7-9
The or der of the wavel et wi thi n the fami l y i s: 7. 9 (we just use one i n thi s
exampl e).
The M-fi l e used to gener ate the fi l ters i s bi nl wav f . m
Then to add the new wavel et, type:
% Add new f ami l y of bi or t hogonal wav el et s .
wave mngr ( add , Bi nl et s , bi nl , 2, 7. 9 , bi nl wav f )
% Li s t wave l et s f ami l i e s .
wave mngr ( r ead )
ans =
===================================
Haar haar
Daube chi e s db
Bi or Spl i nes bi or
Coi f l et s c oi f
Syml e t s s ym
Mor l e t mor l
Mex i c an_hat mex h
Mey er mey r
Bi nl e t s bi nl
===================================
7 Addi ng Your O wn W avelets
7-10
I f you want to get onl i ne i nformati on on thi s new fami l y, you can bui l d an
associ ated hel p fi l e whi ch woul d l ook l i ke:
f unct i on bi nl i nf o
%BI NLI NFO I nf or mat i on on bi or t hogonal wav el et s ( bi nl et s ) .
%
% Bi or t hogonal Wave l e t s ( Bi nl e t s )
%
% Fami l y Bi nl et s
% Shor t name bi nl
% Or de r Nr , Nd Nr = 7 , Nd = 9
%
% Or t hogonal no
% Bi or t hogonal ye s
% Compac t s uppor t ye s
% DWT pos s i bl e
% CWT pos s i bl e
%
% bi nl Nr . Nd l d l r
% ef f ec t i ve l e ngt h e f f ec t i v e l e ngt h
% of LoF_D of Hi F_D
% bi nl 7. 9 7 9
The associ ated M-fi l e to gener ate the fi l ters (bi nl wav f . m) i s:
f unct i on [ Rf , Df ] = bi nl wavf ( wname)
%BI NLWAVF Bi or t hogonal wave l e t f i l t e r s ( Bi nl e t s ) .
% [ RF, DF] = BI NLWAVF( W) r e t ur ns t wo s cal i ng f i l t er s
% as s oci at ed wi t h t he bi or t hogonal wave l e t s pe ci f i ed
% by t he s t r i ng W.
% W= ' bi nl Nr . Nd' whe r e pos s i bl e v al ues f or Nr and Nd ar e :
Nr = 7 Nd = 9
% The out put ar gume nt s ar e f i l t e r s :
% RF i s t he r ec ons t r uc t i on f i l t er
% DF i s t he dec ompos i t i on f i l t e r
% Che ck ar gume nt s .
i f er r ar gn( ' bi nl wav f ' , nar gi n, [ 0 1] , nar gout , [ 0: 2] ) , e r r or ( ' *' ) ;
e nd
How to Add a N ew Wavelet Fami ly
7-11
% s uppr es s t he f ol l owi ng l i ne f or e x t e ns i on
Nr = 7; Nd = 9;
% f or pos s i bl e e xt ens i on
% mor e wave l et s i n ' Bi nl e t s ' f ami l y
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
i f nar gi n==0
Nr = 7; Nd = 9;
e l s ei f i s e mpt y( wname)
Nr = 7; Nd = 9;
e l s e
i f i s s t r ( wname )
l w = l e ngt h( wname ) ;
ab = abs ( wname) ;
i nd = f i nd( ab==46 | 47<ab | ab<58) ;
l i = l e ngt h( i nd) ;
er r = 0;
i f l i ==0
e r r = 1;
el s e i f i nd( 1) ~=i nd( l i ) - l i +1
e r r = 1;
end
i f e r r ==0 ,
wname = s t r 2num( wname( i nd) ) ;
i f i s empt y( wname ) , er r = 1; end
end
e nd
i f e r r ==0
Nr = f i x( wname) ; Nd = 10*( wname - Nr ) ;
e l s e
Nr = 0; Nd = 0;
e nd
e nd
7 Addi ng Your O wn W avelets
7-12
% s uppr e s s t he f ol l owi ng l i ne s f or e xt ens i on
% and add a t e s t f or er r or s .
%- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
i f Nr ~=7 , Nr = 7; end
i f Nd~=9 , Nd = 9; end
i f Nr == 7
i f Nd == 9
Rf = [ - 1 0 9 16 9 0 - 1] /32;
Df = [ 1 0 - 8 16 46 16 - 8 0 1] /64;
end
e nd
Example 2
I n the fol l owi ng exampl e, new compactl y supported orthogonal wavel ets ar e
added to the tool box. These wavel ets, whi ch ar e a sl i ght gener al i zati on of the
Daubechi es wavel ets, ar e based on the use of Ber nstei n pol ynomi al s and are
due to Kateb and Lemari i n an unpubl i shed work.
Note: The M-fi l es used i n thi s exampl e can be found i n the wav ede mo
di r ectory.
% Li s t i ni t i al wav e l e t s f ami l i es .
wav e mngr ( ' r e ad' )
ans =
===================================
Haar haar
Daube chi es db
Bi or Spl i ne s bi or
Coi f l et s c oi f
Syml e t s s ym
Mor l e t mor l
Mex i c an_hat mex h
Mey er mey r
===================================
How to Add a N ew Wavelet Fami ly
7-13
% Li s t al l wav el et s .
wav emngr ( ' r e ad' , 1)
ans =
===================================
Haar haar
===================================
Daube chi e s db
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
db1 db2 db3 db4
db5 db6 db7 db8
db9 db10 dbxx
===================================
Bi or Spl i nes bi or
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bi or 1. 1 bi or 1. 3 bi or 1. 5 bi or 2. 2
bi or 2. 4 bi or 2. 6 bi or 2. 8 bi or 3. 1
bi or 3. 3 bi or 3. 5 bi or 3. 7 bi or 3. 9
bi or 4. 4 bi or 5. 5 bi or 6. 8
===================================
Coi f l et s coi f
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c oi f 1 c oi f 2 coi f 3 c oi f 4
c oi f 5
===================================
Syml e t s s y m
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
s ym2 s ym3 s y m4 s ym5
s ym6 s ym7 s y m8
===================================
Mor l e t mor l
===================================
Mex i c an_hat me xh
===================================
Mey er me yr
===================================
7 Addi ng Your O wn W avelets
7-14
% Add ne w f ami l y of or t hogonal wav el et s .
% You mus t def i ne:
%
% Fami l y Name: Le mar i e
% Fami l y Shor t Name : l e m
% Ty pe of wave l et : 1 ( or t h)
% Wave l e t s number s : 1 2 3 4 5
% Fi l e dr i ve r : l e mwav f
%
% Add ne w f ami l y of or t hogonal wav el et s .
% You mus t def i ne:
%
% Fami l y Name: Le mar i e
% Fami l y Shor t Name : l e m
% Ty pe of wave l et : 1 ( or t h)
% Wave l e t s number s : 1 2 3 4 5
% Fi l e dr i ve r : l e mwav f
%
% and t he f unc t i on l e mwav f . m mus t be as f ol l ow:
% f unc t i on w = l e mwav f ( wname )
% wher e t he i nput ar gument wname i s a s t r i ng:
% wname = ' l em1' or ' l e m2' . . . i . e .
% wname = s h. name + numbe r
% and w t he cor r e s pondi ng s c al i ng f i l t e r
% t he n addi t i on i s obt ai ned us i ng:
wav e mngr ( ' add' , ' Lemar i e ' , ' l e m' , 1, ' 1 2 3 4 5' , ' l e mwav f ' ) ;
% The as ci i f i l e ' wav el et s . as c ' i s s av ed as
% ' wave l et s . pr v' t hen i t i s modi f i ed and
% t he mat f i l e ' wav el et s . i nf ' i s gener at e d.
How to Add a N ew Wavelet Fami ly
7-15
% Li s t wave l et s f ami l i e s .
wav emngr ( ' r e ad' )
ans =
===================================
Haar haar
Daube chi e s db
Bi or Spl i nes bi or
Coi f l et s coi f
Syml e t s s y m
Mor l e t mor l
Mex i c an_hat me xh
Mey er me yr
Lemar i e l e m
===================================
7 Addi ng Your O wn W avelets
7-16
After Adding a New Wavelet Family
When you use the wave mngr command to add a new wavel et, the tool box cr eates
three wavel et extensi on fi l es i n the curr ent di rectory: the two ASCI I fi l es
wav el et s . as c and wav el e t s . pr v , and the MAT-fi l e wave l e t s . i nf .
I f you want to use your own extended wavel et fami l i es wi th the Wavel et
Tool box, you shoul d:
1 Cr eate a new di rector y speci fi cal l y to hol d the wavel et extensi on fi l es.
2 Move the pr evi ousl y menti oned fi l es i nto thi s new di rectory.
3 Pr epend thi s di rectory to the MATLABs di r ector y search path (see the
r efer ence entry for the pat h command).
4 Use thi s same di rector y for subsequent modi fi cati ons. Al l owi ng many
wavel et extensi on fi l es to pr ol i fer ate i n di ffer ent di rectori es may l ead to
unpr edi ctabl e r esul ts.
5 Defi ne an M-fi l e cal l ed <f sn>i nf o. m (For exampl e, see dbi nf o. m or
mor l i nf o. m).
Thi s fi l e wi l l be associ ated automati cal l y wi th the Wavelet Family button i n
the Wavel et Di spl ay opti on of the graphi cal tool s.

8
Reference
8 Reference
8-2
Commands Grouped by Function
Graphical User Interface Tools
wave menu Star t gr aphi cal user i nterface tool s.
Wavelets: General
bi or f i l t Bi orthogonal wavel et fi l ter set.
dy addown Dyadi c downsampl i ng.
dy adup Dyadi c upsampl i ng.
i nt wave I ntegrate wavel et functi on psi .
or t hf i l t Or thogonal wavel et fi l ter set.
qmf Quadratur e mi r ror fi l ter.
wave f un Wavel et and scal i ng functi ons.
wf i l t er s Wavel et fi l ter s.
wave mngr Wavel et manager.
wmax l ev Maxi mum wavel et decomposi ti on l evel .
Wavelet Families
bi or wav f Bi orthogonal spl i ne wavel et fi l ters.
coi f wav f Coi fl ets wavel et fi l ter s.
dbaux Daubechi es wavel et fi l ters computati on.
dbwav f Daubechi es wavel et fi l ters.
me xi hat Mexi can hat wavel et.
me ye r Meyer wavel et.
me ye r aux Meyer wavel et auxi l i ary functi on.
mor l e t Morl et wavel et.
s y mwavf Syml ets wavel et fi l ters.
C ommands G rouped by Functi on
8-3
Continuous Wavelet: One-Dimensional
cwt Conti nuous wavel et coeffi ci ents 1-D.
Discrete Wavelets: One-Dimensional
appc oe f Extr act 1-D appr oxi mati on coeffi ci ents.
de t c oe f Extr act 1-D detai l coeffi ci ents.
dwt Si ngl e-l evel di scr ete 1-D wavel et transform.
dwt per Si ngl e-l evel di scr ete 1-D wavel et transform (per i -
odi zed).
dwt mode Di screte wavel et tr ansfor m extensi on mode.
i dwt Si ngl e-l evel i nver se di scr ete 1-D wavel et transform.
i dwt pe r Si ngl e-l evel i nver se di scr ete 1-D wavel et transform
(per i odi zed).
upcoef Di r ect reconstr ucti on from 1-D wavel et coeffi ci ents.
upwl ev Si ngl e-l evel r econstructi on of wavel et decomposi ti on
1-D.
wave de c Mul ti -l evel wavel et decomposi ti on 1-D.
wave r e c Mul ti -l evel wavel et reconstr ucti on 1-D.
wr coef Reconstruct si ngl e branch from 1-D wavel et coeffi -
ci ents.
8 Reference
8-4
Discrete Wavelets: Two-Dimensional
appc oef 2 Extr act 2-D appr oxi mati on coeffi ci ents.
de t c oef 2 Extr act 2-D detai l coeffi ci ents.
dwt 2 Si ngl e-l evel di scr ete 2-D wavel et transform.
dwt pe r 2 Si ngl e-l evel di scr ete 2-D wavel et transform (peri -
odi zed).
dwt mode Di scr ete wavel et transform extensi on mode.
i dwt 2 Si ngl e-l evel i nver se di scr ete 2-D wavel et transform.
i dwt per 2 Si ngl e-l evel i nver se di scr ete 2-D wavel et transform
(per i odi zed).
upcoe f 2 Di r ect reconstr ucti on from 2-D wavel et coeffi ci ents.
upwl e v2 Si ngl e-l evel reconstr ucti on of wavel et decomposi ti on
2-D.
wave dec 2 Mul ti -l evel wavel et decomposi ti on 2-D.
wave r ec 2 Mul ti -l evel wavel et reconstructi on 2-D.
wr coe f 2 Reconstruct si ngl e br anch fr om 2-D wavel et coeffi -
ci ents.
C ommands G rouped by Functi on
8-5
Wavelet Packet Algorithms
be s t t r ee Best tree (wavel et packet).
be s t l e vt Best l evel tree (wavel et packet).
ent r upd Entr opy update (wavel et packet).
we nt r opy Entr opy (wavel et packet).
wp2wt r ee Extr act wavel et tree fr om wavel et packet tr ee.
wpcoef Wavel et packet coeffi ci ents.
wpcut r ee Cut wavel et packets tr ee.
wpde c Wavel et packet decomposi ti on 1-D.
wpdec2 Wavel et packet decomposi ti on 2-D.
wpf un Wavel et packet functi ons.
wpj oi n Recompose wavel et packet.
wpr c oe f Reconstruct wavel et packet coeffi ci ents.
wpr e c Wavel et packet reconstr ucti on 1-D
wpr e c2 Wavel et packet reconstr ucti on 2-D.
wps pl t Spl i t (decompose) wavel et packet.
De-Noising and Compression for Signals and Images
ddencmp Defaul t val ues for de-noi si ng or compressi on.
t hs e l e ct Threshol d sel ecti on for de-noi si ng.
wden Automati c 1-D de-noi si ng usi ng wavel ets.
wdencmp De-noi si ng or compressi on usi ng wavel ets.
wnoi s e Gener ate noi sy wavel et test data.
wnoi s e s t Esti mate noi se of wavel et coeffi ci ents 1-D.
wpde nc mp De-noi si ng or compressi on usi ng wavel et packets.
wpt hcoef Wavel et packet coeffi ci ents thr eshol di ng.
wt hc oe f Wavel et coeffi ci ents threshol di ng 1-D.
wt hc oe f 2 Wavel et coeffi ci ents threshol di ng 2-D.
wt hr es h Perform soft or har d threshol di ng.
8 Reference
8-6
Tree Management Utilities
al l node s Tree nodes.
de po2i nd Node depth-posi ti on to node i ndex.
i nd2depo Node i ndex to node depth-posi ti on.
i s node True for exi sti ng node.
i s t node True for termi nal nodes.
make t r e e Make tree.
node as c Node ascendants.
node des c Node descendants.
node j oi n Recompose node.
node par Node parent.
node s pl t Spl i t (decompose) node.
nt node Number of termi nal nodes.
pl ot t r e e Pl ot tree.
t node s Ter mi nal nodes.
t r ee dpt h Tree depth.
t r ee or d Tree or der.
wdat amgr Manager for data str uctur e.
wt r e e mgr Manager for tr ee str uctur e.
General Utilities
de bl ankl Conver t str i ng to l owercase wi thout bl anks.
er r ar gn Check functi on ar guments number.
er r ar gt Check functi on ar guments type.
num2ms t r Conver t number to stri ng i n maxi mum pr eci si on.
wc ode mat Extended pseudocol or matri x scal i ng.
wc ommon Fi nd common el ements.
wkee p Keep part of a vector or a matri x.
wr ev Fl i p vector.
C ommands G rouped by Functi on
8-7
Other
i ns t df f t I nver se nonstandar d 1-D fast Fouri er transform.
ns t df f t Nonstandard 1-D fast Fouri er tr ansform.
Wavelets Information
wave i nf o I nformati on on wavel ets.
Demos
wave de mo Wavel et tool box demos.
allnodes
8-8
al l nodes
Purpose Tree nodes.
Syntax N = al l node s ( T)
N = al l node s ( T, ' deppos' )
Description al l node s i s a tree management uti l i ty that r etur ns one of two node
descr i pti ons: ei ther i ndi ces, or depths and posi ti ons. Tr ee nodes are number ed
from l eft to ri ght and fr om top to bottom. The r oot i ndex i s 0.
N = al l node s ( T) returns i n col umn vector N the i ndi ces of al l the nodes of the
tr ee str uctur e T.
N = al l node s ( T, ' deppos' ) retur ns i n matr i x N the depths and posi ti ons of al l
the nodes. N( i , 1) i s the depth and N( i , 2) the posi ti on of the node i .
Examples % Cr e at e i ni t i al t r e e.
or d = 2;
t = make t r ee ( or d, 3) ; % Bi nar y t r e e of de pt h 3.
t t = nodej oi n( t , 5) ;
t t = nodej oi n( t t , 4) ;
pl ot t r ee ( t t )
Node indices
(1) (2)
(3) (4) (5) (6)
(7) (8) (13) (14)
(0)
allnodes
8-9
% Li s t t t node s ( i ndex ) .
al n_i nd = al l nodes ( t t )
al n_i nd =
0
1
2
3
4
5
6
7
8
13
14
% Li s t t t node s ( dept h- pos i t i on) .
al n_depo = al l node s ( t t , ' deppos ' )
al n_depo =
0 0
1 0
1 1
2 0
2 1
2 2
2 3
3 0
3 1
3 6
3 7
See Also maket r e e
Node depth and position
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,6) (3,7)
(0,0)
appcoef
8-10
appcoef
Purpose Extract 1-D appr oxi mati on coeffi ci ents.
Syntax A = appcoef ( C, L, ' wname' , N)
A = appcoef ( C, L, ' wname' )
A = appcoef ( C, L, Lo_R, Hi _R)
A = appcoef ( C, L, Lo_R, Hi _R, N)
Description appcoef i s a one-di mensi onal wavel et anal ysi s functi on.
appcoef computes the appr oxi mati on coeffi ci ents of a one-di mensi onal si gnal .
A = appc oe f ( C, L, 'wname', N) computes the approxi mati on coeffi ci ents at l evel
N usi ng the wavel et decomposi ti on structure [ C, L] (see wav ede c).
'wname' i s a stri ng contai ni ng the wavel et name. Level N must be an i nteger such
that 0 <= N <= l engt h( L) - 2.
A = appcoef ( C, L, 'wname') extr acts the appr oxi mati on coeffi ci ents at the l ast
l evel l ength( L) - 2.
I nstead of gi vi ng the wavel et name, you can gi ve the fi l ter s. For
A = appcoef ( C, L, Lo_R, Hi _R) or A = appc oe f ( C, L, Lo_R, Hi _R, N) , Lo_R i s the
reconstructi on l ow-pass fi l ter and Hi _R i s the reconstr ucti on hi gh-pass fi l ter .
appcoef
8-11
Examples % Load or i gi nal one- di mens i onal s i gnal .
l oad l e l ec cum; s = l e l e cc um( 1: 3920) ; l s = l engt h( s ) ;
% Per f or m de compos i t i on at l e ve l 3 of s us i ng db1.
[ c, l ] = wave de c( s , 3, ' db1' ) ;
% Ext r act appr ox i mat i on c oe f f i c i e nt s at l e ve l 3, f r om t he
% wav el et de compos i t i on s t r uc t ur e [ c , l ] .
c a3 = appc oe f ( c, l , ' db1' , 3) ;
Algorithm The i nput vectors C and L contai n al l the i nfor mati on about the si gnal
decomposi ti on.
Let NMAX = l e ngt h( L) - 2, then C = [ A( NMAX) D( NMAX) . . . D( 1) ] , wher e A and
the D ar e vectors.
I f N = NMAX a si mpl e extracti on i s done, other wi se appcoef computes i terati vel y
the approxi mati on coeffi ci ents usi ng the i nverse wavel et transform.
See Also de t coef , wave de c
0 500 1000 1500 2000 2500 3000 3500 4000
0
200
400
600
Original signal s.
0 500
0
500
1000
1500
2000
Approx. coef. level 3 : ca3
appcoef2
8-12
appcoef2
Purpose Extract 2-D appr oxi mati on coeffi ci ents.
Syntax A = appcoef 2( C, S, ' wname' , N)
A = appcoef 2( C, S, ' wname' )
A = appcoef 2( C, S, Lo_R, Hi _R)
A = appcoef 2( C, S, Lo_R, Hi _R, N)
Description appcoef 2 i s a two-di mensi onal wavel et anal ysi s functi on.
appcoef 2 computes the approxi mati on coeffi ci ents of a two-di mensi onal si gnal .
A = appc oe f 2( C, S, 'wname', N) computes the appr oxi mati on coeffi ci ents at l evel
N usi ng the wavel et decomposi ti on structure [ C, S] (see wav ede c2).
'wname' i s a stri ng contai ni ng the wavel et name. Level N must be an i nteger such
that 0 <= N <= s i z e( S, 1) - 2.
A = appc oef 2( C, S, 'wname') extr acts the appr oxi mati on coeffi ci ents at the l ast
l evel s i z e ( S, 1) - 2.
I nstead of gi vi ng the wavel et name, you can gi ve the fi l ter s. For
A = appcoef 2( C, S, Lo_R, Hi _R) or A = appcoe f 2( C, S, Lo_R, Hi _R, N) , Lo_R i s
the reconstructi on l ow-pass fi l ter and Hi _R i s the reconstr ucti on hi gh-pass
fi l ter .
Examples % Load or i gi nal i mage.
l oad woman;
% X c ont ai ns t he l oaded i mage .
% Per f or m de compos i t i on at l e ve l 2
% of X us i ng db1.
[ c, s ] = wave de c2( X, 2, ' db1' ) ;
s i z ex = s i z e ( X)
appcoef2
8-13
s i z ex =
256 256
s i z ec = s i z e ( c )
s i z ec =
1 65536
v al _s = s
v al _s =
64 64
64 64
128 128
256 256
% Ext r act appr ox i mat i on c oe f f i c i e nt s
% at l e ve l 2.
c a2 = appc oe f 2( c , s , ' db1' , 2) ;
s i z ec a2 = s i z e ( c a2)
s i z ec a2 =
64 64
% Comput e appr ox i mat i on c oe f f i c i e nt s
% at l e ve l 1.
c a1 = appc oe f 2( c , s , ' db1' , 1) ;
s i z ec a1 = s i z e ( c a1)
s i z ec a1 =
128 128
Algorithm The al gori thm i s bui l t on the same pr i nci pl e as appcoef .
See Also de t coef 2, wav e de c2
bestlevt
8-14
bestl evt
Purpose Best l evel tree (wavel et packet).
Syntax [ T, D] = bes t l e vt ( T, D)
[ T, D, E] = bes t l e vt ( T, D)
Description bes t l ev t i s a one- or two-di mensi onal wavel et packet anal ysi s functi on.
bes t l ev t computes the opti mal compl ete sub-tr ee of an i ni ti al tree wi th respect
to an entr opy type cri ter i on. The resul ti ng compl ete tree may be of smal l er
depth than the i ni ti al one.
[ T, D] = bes t l e vt ( T, D) computes the modi fi ed tree str uctur e T and data
str ucture D, cor respondi ng to the best l evel tree decomposi ti on.
[ T, D, E] = bes t l e vt ( T, D) r etur ns the best tr ee T, data structur e D, and i n
addi ti on, the best entr opy val ue E.
Examples % Load s i gnal .
l oad noi s dopp;
x = noi s dopp;
% Dec ompos e x at dept h 3 wi t h db1 wave l e t pac ke t s , us i ng
% def aul t ent r opy ( s hannon) and de compos e t he pac ke t [ 3 0] .
[ wpt , wpd] = wpde c( x , 3, ' db1' ) ;
[ wpt , wpd] = wps pl t ( wpt , wpd, [ 3 0] ) ;
bestlevt
8-15
% Pl ot wave l et pac ke t t r e e s t r uct ur e wpt .
pl ot t r e e ( wpt )
% Comput e be s t l ev el t r ee .
[ bl t , bl d] = be s t l e v t ( wpt , wpd) ;
% Pl ot be s t l e ve l t r ee s t r uct ur e bl t .
pl ot t r e e ( bl t )
Algorithm See be s t t r ee al gori thm secti on. The onl y di ffer ence i s that the opti mal tr ee i s
sear ched among the compl ete sub-tr ees of the i ni ti al tr ee.
See Also be s t t r e e, maket r e e, went r opy , wpde c, wpdec 2
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)
(4,0) (4,1)
(0,0)
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)
(0,0)
besttree
8-16
besttr ee
Purpose Best tr ee (wavel et packet).
Syntax [ T, D] = bes t t r ee ( T, D)
[ T, D, E] = bes t t r ee ( T, D)
[ T, D, E, N] = be s t t r ee ( T, D)
Description bes t t r e e i s a one- or two-di mensi onal wavel et packet anal ysi s functi on that
computes the opti mal sub-tree of an i ni ti al tr ee wi th r espect to an entr opy type
cr i ter i on. The resul ti ng tree may be much smal l er than the i ni ti al one.
Fol l owi ng the organi zati on of the wavel et packets l i br ary, i t i s natur al to count
the decomposi ti ons i ssued from a gi ven or thogonal wavel et. As a r esul t, a
si gnal of l ength N = 2
L
can be expanded i n at most 2
N
di fferent ways, the
number of bi nar y sub-tr ees of a compl ete bi nar y sub-tr ee of depth L. As thi s
number may be very l ar ge, and si nce expl i ci t enumer ati on i s general l y
i ntractabl e, i t i s i nter esti ng to fi nd an opti mal decomposi ti on wi th respect to a
conveni ent cri ter i on, computabl e by an effi ci ent al gor i thm. We ar e l ooki ng for
a mi ni mum of the cr i teri on.
[ T, D] = bes t t r ee ( T, D) computes the modi fi ed tree str uctur e T and data
str ucture D (see maket r e e), corr espondi ng to the best entr opy val ue.
[ T, D, E] = be s t t r e e( T, D) returns the best tree T, the data structure D, and i n
addi ti on, the best entr opy val ue E.
[ T, D, E, N] = bes t t r ee ( T, D) r etur ns the best tree T, the data structure D, the
best entropy val ue E, and i n addi ti on, the vector N contai ni ng the i ndi ces of the
merged nodes.
besttree
8-17
Examples % Load s i gnal .
l oad noi s dopp; x = noi s dopp;
% Dec ompos e x at dept h 3 wi t h db1 wave l e t packe t s , us i ng
% def aul t e nt r opy ( s hannon) and dec ompos e t he pac ke t [ 3 0] .
[ wpt , wpd] = wpde c( x , 3, ' db1' ) ;
[ wpt , wpd] = wps pl t ( wpt , wpd, [ 3 0] ) ;
% Pl ot wave l et pac ke t t r e e s t r uct ur e wpt .
pl ot t r e e ( wpt )
% Comput e be s t t r e e.
[ bt , bd] = be s t t r ee ( wpt , wpd)
% Pl ot be s t t r ee s t r uc t ur e bt .
pl ot t r e e ( bt )
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)
(4,0) (4,1)
(0,0)
(1,0) (1,1)
(2,0) (2,1)
(3,0) (3,1) (3,2) (3,3)
(4,0) (4,1)
(0,0)
besttree
8-18
Algorithm Consi der the one-di mensi onal case. Starti ng wi th the root node, the best tr ee
i s cal cul ated usi ng the fol l owi ng scheme. A node N i s spl i t i nto two nodes N1
and N2 i f and onl y i f the sum of the entr opy of N1 and N2 i s l ower than the
entr opy of N. Thi s i s a l ocal cri ter i on based onl y on the i nfor mati on avai l abl e
at the node N.
Sever al entr opy type cri ter i a can be used (see went r opy). I f the entr opy
functi on i s an addi ti ve functi on al ong the wavel et packet coeffi ci ents, thi s
Al gor i thm l eads to the best tree.
Starti ng fr om an i ni ti al tr ee T and usi ng the mergi ng si de of thi s al gori thm, we
obtai n the best tree among al l the bi nary sub-tr ees of T.
See Also bestl evt, maketree, wentr opy, wpdec, wpdec 2
References R.R. Coi fman, M.V Wi ckerhauser, (1992), Entropy-based al gori thms for best
basi s sel ecti on, I EEE Trans. on I nf. Theory, vol . 38, 2, pp. 713718.
biorfilt
8-19
bi orfi l t
Purpose Bi orthogonal wavel et fi l ter set.
Syntax [ LO_D, HI _D, LO_R, HI _R] = bi or f i l t ( DF, RF)
[ LO_D1, HI _D1, LO_R1, HI _R1, LO_D2, HI _D2, LO_R2, HI _R2] =
bi or f i l t ( DF, RF, ' 8' )
Description The bi or f i l t command returns ei ther four or ei ght fi l ters associ ated wi th
bi orthogonal wavel ets.
[ LO_D, HI _D, LO_R, HI _R] = bi or f i l t ( DF, RF) computes four fi l ter s associ ated
wi th the bi orthogonal wavel et speci fi ed by decomposi ti on fi l ter DF and
reconstr ucti on fi l ter RF. These fi l ter s are:
[ LO_D1, HI _D1, LO_R1, HI _R1, LO_D2, HI _D2, LO_R2, HI _R2] =
bi or f i l t ( DF, RF, ' 8' ) returns ei ght fi l ter s, the fi r st four associ ated wi th the
decomposi ti on wavel et, and the l ast four associ ated wi th the reconstr ucti on
wavel et.
I t i s wel l known i n the sub-band fi l ter i ng communi ty that i f the same FI R
fi l ters ar e used for r econstr ucti on and decomposi ti on, then symmetr y and exact
reconstr ucti on ar e i ncompati bl e (except wi th the Haar wavel et). Therefore,
wi th bi orthogonal fi l ter s, two wavel ets ar e i ntroduced i nstead of just one:
One wavel et, , i s used i n the anal ysi s, and the coeffi ci ents of a si gnal s ar e
,
The other wavel et, , i s used i n the synthesi s
Fur ther , the two wavel ets are rel ated by dual i ty i n the fol l owi ng sense:
as soon as or and
as soon as .
LO_D Decomposi ti on l ow-pass fi l ter
HI _D Decomposi ti on hi gh-pass fi l ter
LO_R Reconstructi on l ow-pass fi l ter
HI _R Reconstructi on hi gh-pass fi l ter

j k ,
s x ( )

j k ,
x ( ) x d

=
s c

j k ,

j k ,
j k ,

j k ,
x ( )
j k ,
x ( ) x d

0 = j j k k

0 k ,
x ( )
0 k ,
x ( ) x d

0 =
k k
biorfilt
8-20
I t becomes apparent, as A. Cohen poi nted out i n hi s thesi s (p. 110), that the
useful pr oper ti es for anal ysi s (e.g., osci l l ati ons, nul l moments) can be
concentrated i n the functi on whereas the i nteresti ng properti es for
synthesi s (regul ar i ty) are assi gned to the functi on. The separ ati on of these
two tasks pr oves very useful .
and can have ver y di ffer ent regul ari ty properti es, bei ng mor e r egul ar
than (see Daubechi es p. 269).
The , , and functi ons are zer o outsi de a segment.
Examples % Comput e t he f our f i l t er s as s oci at e d wi t h s pl i ne bi or t hogonal
% wav el et 3. 5: bi or 3. 5.
% Fi nd t he t wo s cal i ng f i l t er s as s oc i at e d wi t h bi or 3. 5.
[ Rf , Df ] = bi or wavf ( ' bi or 3. 5' ) ;
% Comput e t he f our f i l t er s ne eded.
[ Lo_D, Hi _D, Lo_R, Hi _R] = bi or f i l t ( Df , Rf ) ;
s ubpl ot ( 221) ; s t em( Lo_D) ;
t i t l e ( ' De c . l ow- pas s f i l t er bi or 3. 5' ) ;
s ubpl ot ( 222) ; s t em( Hi _D) ;
t i t l e ( ' De c . hi gh- pas s f i l t e r bi or 3. 5' ) ;
s ubpl ot ( 223) ; s t em( Lo_R) ;
t i t l e ( ' Re c . l ow- pas s f i l t er bi or 3. 5' ) ;
s ubpl ot ( 224) ; s t em( Hi _R) ;
t i t l e ( ' Re c . hi gh- pas s f i l t e r bi or 3. 5' ) ;

biorfilt
8-21
% Or t hogonal i t y by dyadi c t r ans l at i on i s l os t .
nz e r = [ Lo_D 0 0] *[ 0 0 Lo_D] '
nz e r =
- 0. 6881
nz e r = [ Hi _D 0 0] *[ 0 0 Hi _D] '
nz e r =
0. 1875
% But us i ng dual i t y we have :
z er = [ Lo_D 0 0] *[ 0 0 Lo_R] '
z er =
- 2. 7756e - 17
z er = [ Hi _D 0 0] *[ 0 0 Hi _R] '
z er =
2. 7756e - 17
% But per f e c t r e cons t r uct i on vi a DWT i s pr es er v ed.
x = r andn( 1, 500) ;
[ a, d] = dwt ( x, Lo_D, Hi _D) ;
x r e c = i dwt ( a, d, Lo_R, Hi _R) ;
e r r = nor m( x - x r e c)
e r r =
5. 0218e - 15
0 5 10 15
1
0.5
0
0.5
1
Dec. lowpass filter bior3.5
0 5 10 15
1
0.5
0
0.5
1
Dec. highpass filter bior3.5
0 5 10 15
1
0.5
0
0.5
1
Rec. lowpass filter bior3.5
0 5 10 15
1
0.5
0
0.5
1
Rec. highpass filter bior3.5
biorfilt
8-22
% Hi gh and l ow f r e quenc y i l l us t r at i on.
f f t l d = f f t ( Lo_D) ; f f t hd = f f t ( Hi _D) ;
f r e q = [ 1: l e ngt h( Lo_D) ] /l engt h( Lo_D) ;
s ubpl ot ( 221) ; pl ot ( f r eq, abs ( f f t l d) , f r e q, abs ( f f t hd) ) ;
t i t l e ( ' Tr ans f e r modul us f or de c. f i l t e r s ' )
f f t l r = f f t ( Lo_R) ; f f t hr = f f t ( Hi _R) ;
f r e q = [ 1: l e ngt h( Lo_R) ] /l engt h( Lo_R) ;
s ubpl ot ( 222) ; pl ot ( f r eq, abs ( f f t l r ) , f r e q, abs ( f f t hr ) ) ;
t i t l e ( ' Tr ans f e r modul us f or r e c. f i l t e r s ' )
s ubpl ot ( 223) ; pl ot ( f r eq, abs ( f f t l r . *f f t l d + f f t hd. *f f t hr ) ) ;
t i t l e ( ' One bi or t hogonal i t y condi t i on' )
x l abe l ( ' | f f t ( Lo_R) f f t ( Lo_D) + f f t ( Hi _R) f f t ( Hi _D) | = 2' )
Note: For bi or thogonal wavel ets, the fi l ters for decomposi ti on and
reconstructi on ar e i n general of di fferent odd l engths. Thi s si tuati on occur s,
for exampl e, for spl i nes bi or thogonal wavel ets used i n the tool box, wher e the
four fi l ter s are zero-padded to have the same even l ength.
0.2 0.4 0.6 0.8
0
1
2
3
Transfer modulus for dec. filters
0.2 0.4 0.6 0.8
0
1
2
3
Transfer modulus for rec. filters
0.2 0.4 0.6 0.8
0
2
4
One biorthogonality condition
|fft(Lo_R)fft(Lo_D) + fft(Hi_R)fft(Hi_D)| = 2
biorfilt
8-23
See Also bi or wav f , or t hf i l t
References A. Cohen (1992) Ondel ettes, anal yses mul ti rsol uti on et trai tement
numri que du si gnal , Ph. D. Thesis, Uni ver si ty of Par i s I X, DAUPHI NE.
I . Daubechi es (1992), Ten l ectures on wavel ets, CBMS-NSF confer ence ser i es
i n appl i ed mathemati cs. SI AM Ed.
biorwavf
8-24
bi orwavf
Purpose Bi orthogonal spl i ne wavel et fi l ter s.
Syntax [ RF, DF] = bi or wavf ( W)
Description [ RF, DF] = bi or wavf ( W) returns two scal i ng fi l ter s associ ated wi th
bi or thogonal wavel et speci fi ed by the str i ng W.
W= ' bi or Nr . Nd' wher e possi bl e val ues for Nr and Nd ar e:
The output ar guments ar e fi l ter s:
RF i s the r econstructi on fi l ter.
DF i s the decomposi ti on fi l ter.
Examples % Set s pl i ne bi or t hogonal wav el et name .
wname = ' bi or 2. 2' ;
% Comput e t he t wo cor r e s pondi ng s c al i ng f i l t e r s ,
% r f i s t he r e cons t r uc t i on s c al i ng f i l t e r and
% df i s t he de compos i t i on s cal i ng f i l t er .
[ r f , r d] = bi or wavf ( wname)
r f =
0 0. 2500 0. 5000 0. 2500 0 0
df =
- 0. 1250 0. 2500 0. 7500 0. 2500 - 0. 1250 0
See Also bi or f i l t , wav ei nf o
Nr = 1 Nd = 1 , 3 or 5
Nr = 2 Nd = 2 , 4 , 6 or 8
Nr = 3 Nd = 1 , 3 , 5 , 7 or 9
Nr = 4 Nd = 4
Nr = 5 Nd = 5
Nr = 6 Nd = 8
coifwavf
8-25
coi fwavf
Purpose Coi fl ets wavel ets fi l ters.
Syntax F = c oi f wav f ( W)
Description F = c oi f wav f ( W) returns the scal i ng fi l ter associ ated wi th coi fl et wavel et
speci fi ed by the stri ng W, where W= ' coi f N' . Possi bl e val ues for N are: 1, 2, 3,
4 or 5.
Examples % Set c oi f l e t wave l e t name.
wname = ' c oi f 2' ;
% Comput e t he cor r es pondi ng s cal i ng f i l t er .
f = c oi f wavf ( wname )
f =
Col umns 1 t hr ough 7
0. 0116 - 0. 0293 - 0. 0476 0. 2730 0. 5747 0. 2949 - 0. 0541
Col umns 8 t hr ough 12
- 0. 0420 0. 0167 0. 0040 - 0. 0013 - 0. 0005
See Also wavei nfo
cwt
8-26
cwt
Purpose Conti nuous 1-D wavel et coeffi ci ents.
Syntax c oe f s = c wt ( s , s c al es , ' wname' )
c oe f s = c wt ( s , s c al es , ' wname' , ' pl ot ' )
Description c wt i s a one-di mensi onal wavel et anal ysi s functi on.
c oe f s = cwt ( s , s cal e s , 'wname') computes the conti nuous wavel et coeffi ci ents
of the vector s at r eal , posi ti ve s cal e s , usi ng the wavel et whose name i s 'wname'
(see wav e i nf o).
c oe f s = c wt ( s , s c al es , 'wname', ' pl ot ' ) computes, and i n addi ti on pl ots, the
conti nuous wavel et transform coeffi ci ents.
Let s be the si gnal and the wavel et. Then the wavel et coeffi ci ent of s at scal e
a and posi ti on b i s defi ned by:
si nce s(t) i s a di scr ete si gnal , we use a pi ecewi se constant i nter pol ati on of the
s(k) val ues, k = 1 to l engt h(s).
Then for any stri ctl y posi ti ve scal e a, we compute C
a,b
for b = 1 to l e ngt h(s ).
Output ar gument coef s contai ns the wavel et coeffi ci ents for the scal es wi thi n
the vector s c al es i n the same or der, stored r owwi se.
Exampl es of val i d uses ar e:
c = c wt ( s , 1: 32, ' me yr ' )
c = c wt ( s , [ 64 32 16: - 2: 2] , ' mor l ' )
c = c wt ( s , [ 3 18 12. 9 7 1. 5] , ' db2' )
C
a b ,
s t ( )
1
a
-------
t b
a
----------


t d
R

=
cwt
8-27
Examples Thi s exampl e demonstr ates the di fference between di scr ete and conti nuous
wavel et transforms.
% Load or i gi nal f r ac t al s i gnal .
l oad vonkoch
v onkoch=vonkoc h( 1: 510) ;
l v = l e ngt h( vonkoc h) ;
s ubpl ot ( 311) , pl ot ( vonkoc h) ; t i t l e( ' Anal y z e d s i gnal . ' ) ;
s et ( gca, ' Xl i m' , [ 0 510] )
% Per f or m di s c r e t e wav e l e t t r ans f or m at l e ve l 5 by s y m2.
% Lev el s 1 t o 5 cor r es pond t o s cal e s 2, 4, 8, 16 and 32.
[ c, l ] = wave de c( vonkoch, 5, ' s y m2' ) ;
% Expand di s cr et e wave l et c oe f f i c i e nt s f or pl ot .
% Lev el s 1 t o 5 cor r es pond t o s cal e s 2, 4, 8, 16 and 32.
c f d = z e r os ( 5, l v ) ;
f or k = 1: 5
d = de t c oe f ( c, l , k) ;
d = d( ones ( 1, 2^k) , : ) ;
c f d( k, : ) = wke e p( d( : ) ' , l v ) ;
e nd
c f d = c f d( : ) ;
I = f i nd( abs ( c f d) <s qr t ( eps ) ) ;
c f d( I ) =z er os ( s i z e( I ) ) ;
c f d = r e s hape( cf d, 5, l v) ;
% Pl ot di s c r et e coef f i c i e nt s .
s ubpl ot ( 312) , col or map( pi nk( 64) ) ;
i mg = i mage( f l i pud( wc odemat ( c f d, 64, ' r ow' ) ) ) ;
s et ( get ( i mg, ' par ent ' ) , ' Yt i c kLabe l s ' , [ ] ) ;
t i t l e ( ' Di s cr et e Tr ans f or m, abs ol ut e coef f i c i e nt s . ' )
y l abe l ( ' l e ve l ' )
% Per f or m c ont i nuous wave l e t t r ans f or m by s y m2 at al l i nt e ge r
% s cal e s f r om 1 t o 32.
s ubpl ot ( 313)
c cf s = c wt ( v onkoch, 1: 32, ' s y m2' , ' pl ot ' ) ;
t i t l e ( ' Cont i nuous Tr ans f or m, abs ol ut e coef f i c i e nt s . ' )
c ol or map( pi nk( 64) ) ;
y l abe l ( ' Sc al e' )
cwt
8-28
Algorithm
si nce s(t) = s(k), i f then
0 100 200 300 400 500
0
0.01
0.02
Analyzed signal.
Discrete Transform, absolute coefficients.
l
e
v
e
l
100 200 300 400 500
Continuous Transform, absolute coefficients.
time (or space) b
S
c
a
l
e
100 200 300 400 500
C
a b ,
s t ( )
1
a
-------
t b
a
----------


t d
R

=
C
a b ,
s
k
k 1 +

t ( )
1
a
-------
t b
a
----------


t d
k

=
t k k 1 + , [ ]
C
a b ,
1
a
------- s k ( )
k
k 1 +

t b
a
----------


t d
k

=
C
a b ,
1
a
------- s k ( )
t b
a
----------


t d

k 1 +

t b
a
----------


t d


k

=
cwt
8-29
so at any scal e a, the wavel et coeffi ci ents C
a,b
for b = 1 to l e ngt h(s) can be
obtai ned by convol vi ng the si gnal s and a di l ated and transl ated versi on of the
i ntegral s of the form (gi ven by i nt wav e), and taki ng fi ni te di fference
usi ng di f f .
See Also wav edec , wave f un, wav ei nf o, wcode mat

t ( ) t d
dbaux
8-30
dbaux
Purpose Daubechi es wavel ets fi l ters computati on.
Syntax W= dbaux ( N, SUMW)
W= dbaux ( N)
Description W= dbaux ( N, SUMW) i s the order N Daubechi es scal i ng fi l ter such that
s um( W) = SUMW. Possi bl e val ues for N are: 1, 2, 3, ...
Note: I nstabi l i ty may occur when N i s too l arge.
W= dbaux ( N) i s equi val ent to W= dbaux ( N, 1) .
W= dbaux ( N, 0) i s equi val ent to W= dbaux ( N, 1) .
Examples % P t he Lagr ange a t r ous f i l t er f or N=2 i s ex pl i c i t
% and gi v e n by :
P = [ - 1/16 0 9/16 1 9/16 0 - 1/16]
P =
- 0. 0625 0 0. 5625 1. 0000 0. 5625 0 - 0. 0625
% The db2 Daubec hi es s c al i ng f i l t e r w, i s a
% s ol ut i on of t he equat i on: P = c onv ( wr e v( w) , w) * 2.
%
% Thi s f i l t e r P i s s ymmet r i c, e as y t o ge ne r at e, and w i s
% a mi ni mum phas e s ol ut i on of t he pr ev i ous e quat i on,
% bas ed on t he r oot s of P.
r P = r oot s ( P) ;
% Ret ai ni ng onl y t he r oot i ns i de t he uni t ci r cl e ( her e i t
% i s t he s i x t h v al ue of r P) , and t wo r oot s l ocat e d at - 1,
% we obt ai n t he Daubec hi e s wave l e t of or de r 2:
ww = pol y( [ r P( 6) - 1 - 1] ) ; % f i l t e r cons t r uct i on
ww = ww / s um( ww) % nor mal i z e s um
dbaux
8-31
ww =
0. 3415 0. 5915 0. 1585 - 0. 0915
% Che ck t hat ww i s c or r ec t and equal t o
% t he db2 Daubec hi es s c al i ng f i l t er w.
w = dbaux( 2)
w =
0. 3415 0. 5915 0. 1585 - 0. 0915
Algorithm The al gori thm used i s based on a r esul t obtai ned by Shensa, showi ng a
cor respondence between the Lagr ange a tr ous fi l ter s and the convol uti onal
squares of the Daubechi es wavel et fi l ters.
The computati on of the order N Daubechi es scal i ng fi l ter w pr oceeds i n two
steps: compute a Lagr ange a trous fi l ter P and extr act a squar e root. More
preci sel y:
P the associ ated Lagr ange a tr ous fi l ter i s a symmetri c fi l ter of l ength
4N-1. P i s defi ned by:
P = [a(N) 0 a(N-1) 0 ... 0 a(1) 1 a(1) 0 a(2) 0 ... 0 a(N)]
Then, i f w denotes dbN Daubechi es scal i ng fi l ter of sum , w i s a squar e r oot
of P. More pr eci sel y P = c onv(wr e v (w),w), and w i s a fi l ter of l ength 2N. The
corr espondi ng pol ynomi al has N zeros l ocated at -1 and N-1 zer os l ess than 1
i n modul us.
Note that other methods can be used; see var i ous sol uti ons of the spectral
factor i zati on pr obl em i n Strang-Nguyen p. 157.
where a k ( )
1
2
--- i


i N 1 + =
i k
N

k i ( )
i N 1 + =
i k
N

---------------------------------------for k 1 = , N , =
2
dbaux
8-32
Limitations The computati on of the dbN Daubechi es scal i ng fi l ter requi res the extr acti on of
the r oots of a pol ynomi al of or der 4N. I nstabi l i ty may occur when N i s too l arge.
See Also dbwav f , wf i l t er s
References I . Daubechi es (1992), Ten l ectures on wavel ets, CBMS-NSF confer ence ser i es
i n appl i ed mathemati cs. SI AM Ed.
M.J. Shensa (1992), The di scr ete wavel et transfor m: weddi ng the a tr ous and
Mal l at Al gori thms, I EEE Trans. on Signal Processing, vol . 40, 10, pp
2464-2482.
G. Str ang, T. Nguyen (1996), Wavelets and Filter Banks, Wel l esl ey-Cambri dge
Press.
dbwavf
8-33
dbwavf
Purpose Daubechi es wavel ets fi l ter s.
Syntax F = dbwav f ( W)
Description F = dbwav f ( W) retur ns the scal i ng fi l ter associ ated wi th Daubechi es wavel et
speci fi ed by the stri ng W, where W= ' dbN' . Possi bl e val ues for N are: 1, 2, 3, ...,
50.
Examples % Set Daube c hi es wav el e t name .
wname = ' db4' ;
% Comput e t he cor r es pondi ng s cal i ng f i l t er .
f = dbwavf ( wname )
f =
Col umns 1 t hr ough 7
0. 1629 0. 5055 0. 4461 - 0. 0198 - 0. 1323 0. 0218 0. 0233
Col umn 8
- 0. 0075
See Also dbaux , wave i nf o, wf i l t e r s
ddencmp
8-34
dden cmp
Purpose Defaul t val ues for de-noi si ng or compressi on.
Syntax [ THR, SORH, KEEPAPP, CRI T] = dde nc mp( I N1, I N2, X)
[ THR, SORH, KEEPAPP] = dde ncmp( I N1, ' wv ' , X)
[ THR, SORH, KEEPAPP, CRI T] = dde nc mp( I N1, ' wp' , X)
Description dde nc mp i s a de-noi si ng and compr essi on ori ented functi on.
dde nc mp gi ves defaul t val ues for al l the general pr ocedur es r el ated to
de-noi si ng and compr essi on of one- or two-di mensi onal si gnal s, usi ng wavel ets
or wavel et packets.
[ THR, SORH, KEEPAPP, CRI T] = ddencmp( I N1, I N2, X) r etur ns defaul t val ues for
de-noi si ng or compressi on, usi ng wavel ets or wavel et packets, of an i nput
vector or matri x X, whi ch can be a one- or two-di mensi onal si gnal . THR i s the
threshol d, SORH i s for soft or har d threshol di ng, KEEPAPP al l ows you to keep
approxi mati on coeffi ci ents, and CRI T (used onl y for wavel et packets) i s the
entr opy name (see went r opy).
I N1 i s ' de n' or ' cmp' .
I N2 i s ' wv ' or ' wp' .
For wavel ets (three output ar guments):
[ THR, SORH, KEEPAPP] = dde ncmp( I N1, ' wv ' , X) r etur ns defaul t val ues for
de-noi si ng (i f I N1 = ' den' ) or compr essi on (i f I N1 = ' cmp' ) of X. These val ues
can be used for wde nc mp.
For wavel et packets (four output ar guments):
[ THR, SORH, KEEPAPP, CRI T] = dde nc mp( I N1, ' wp' , X) r eturns defaul t val ues
de-noi si ng (i f I N1 = ' den' ) or compr essi on (i f I N1 = ' cmp' ) of X. These val ues
can be used for wpdencmp.
ddencmp
8-35
Examples % Gener at e Gaus s i an whi t e noi s e .
i ni t = 2055415866; r andn( ' s ee d' , i ni t ) ;
x = r andn( 1, 1000) ;
% Fi nd de f aul t v al ue s f or wav el et s ( 3 out put ar gume nt s ) .
% The s e v al ues c an be us e d f or wdenc mp wi t h opt i on ' gbl ' .
% def aul t f or de - noi s i ng:
% s of t t hr es hol di ng and appr . c f s . kept
% t hr = s qr t ( 2*l og( n) ) * s
% whe r e s i s an es t i mat e of l ev e l noi s e.
[ t hr , s or h, ke epapp] = ddencmp( ' de n' , ' wv ' , x)
t hr =
3. 8593
s or h =
s
kee papp =
1
% def aul t f or compr es s i on:
% har d t hr es hol di ng and appr . c f s . kept
% t hr = me di an( abs ( de t ai l at l e v el 1) ) i f nonz e r o
% e l s e t hr = 0. 05 * max ( abs ( det ai l at l e ve l 1) ) .
[ t hr , s or h, ke epapp] = ddencmp( ' c mp' , ' wv ' , x)
t hr =
0. 7003
s or h =
h
kee papp =
1
% Fi nd de f aul t v al ue s f or wav el et packet s ( 4 out put ar gume nt s ) .
% The s e v al ues c an be us e d f or wpde ncmp.
% def aul t f or de - noi s i ng:
% s of t t hr es hol di ng and appr . c f s . kept
% t hr = s qr t ( 2*l og( n*l og( n) /l og( 2) ) )
% t he noi s e l e ve l i s s uppos ed t o be equal t o 1;
% def aul t ent r opy i s ' s ur e' c r i t er i on.
[ t hr , s or h, ke epapp, c r i t ] = dde nc mp( ' den' , ' wp' , x)
ddencmp
8-36
t hr =
4. 2911
s or h =
h
kee papp =
1
c r i t =
s ur e
% def aul t f or compr es s i on.
% har d t hr es hol di ng and appr . cf s . kept
% t hr = me di an( abs ( de t ai l at l ev el 1) )
% def aul t ent r opy i s ' t hr es hol d' c r i t e r i on.
[ t hr , s or h, ke epapp, c r i t ] = dde ncmp( ' c mp' , ' wp' , x)
t hr =
0. 7003
s or h =
h
kee papp =
1
c r i t =
t hr es hol d
See Also wde nc mp, we nt r opy, wpde nc mp
References D.L. Donoho (1995), De-noi si ng by soft-threshol di ng, I EEE, Trans. on I nf.
Theory, 41, 3, pp. 613627.
D.L. Donoho, I .M. Johnstone (1994), I deal spati al adaptati on by wavel et
shri nkage, Biometrika, vol 81, pp. 425455.
D.L. Donoho, I .M. Johnstone, I deal de-noi si ng i n an orthonormal basi s chosen
from a l i brary of bases, C.R.A.S. Paris, t. 319, Ser. I , pp. 13171322.
deblankl
8-37
debl ankl
Purpose Conver t str i ng to l owercase wi thout bl anks.
Syntax S = debl ankl ( X)
Description de bl ankl i s a general uti l i ty.
Thi s functi on gi ves fl exi bi l i ty when usi ng str i ngs.
S = debl ankl ( X) i s the str i ng X conver ted to l owercase wi thout bl anks.
Examples x = ' AB1 C %9'
x =
AB1 C %9
y = debl ankl ( x )
y =
ab1c%9
depo2ind
8-38
depo2i nd
Purpose Node depth-posi ti on to node i ndex.
Syntax N = depo2i nd( O, [ D P] )
Description depo2i nd i s a tree management uti l i ty.
For a tree of or der O, N = de po2i nd( O, [ D P] ) computes the i ndi ces N of the
nodes whose depths and posi ti ons ar e encoded wi thi n [ D, P] .
D, P and N ar e col umn vectors. The val ues of D, P and N ar e constrai ned by:
D = depths, 0 D dmax
P = posi ti ons at depth D, 0 P order
D-1

N = i ndi ces, 0 N < (order
(dmax+1)
-1)/(order-1)
Note that for a col umn vector X, we have de po2i nd( O, X) = X.
Examples % Cr e at e i ni t i al t r e e.
or d = 2;
t = make t r ee ( or d, 3) ; % bi nar y t r ee of dept h 3.
t t = nodej oi n( t , 5) ;
t t = nodej oi n( t t , 4) ;
pl ot t r ee ( t t )
% Li s t t t node s ( dept h- pos i t i on) .
al n_de po = al l node s ( t t , ' deppos ' )
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,6) (3,7)
(0,0)
depo2ind
8-39
al n_depo =
0 0
1 0
1 1
2 0
2 1
2 2
2 3
3 0
3 1
3 6
3 7
% Swi t c h f r om de pt h- pos i t i on t o i nde x.
al n_i nd = de po2i nd( or d, al n_de po)
al n_i nd =
0
1
2
3
4
5
6
7
8
13
14
See Also i nd2depo, maket r e e, wt r ee mgr
detcoef
8-40
detcoef
Purpose Extract 1-D detai l coeffi ci ents.
Syntax D = det coef ( C, L, N)
D = det coef ( C, L)
Description det coef i s a one-di mensi onal wavel et anal ysi s functi on.
D = de t c oe f ( C, L, N) extr acts the detai l coeffi ci ents at l evel N fr om the wavel et
decomposi ti on str uctur e [ C, L] (see wav e de c). Level N must be an i nteger such
that 1 <= N <= l engt h( L) - 2.
D = det coef ( C, L) extracts the detai l coeffi ci ents at l ast l evel
n=l engt h( L) - 2.
Examples % Load or i gi nal one- di mens i onal s i gnal .
l oad l el ec cum;
s = l e l e cc um( 1: 3920) ;
l s = l engt h( s ) ;
% Per f or m de compos i t i on at l e ve l 3 of s us i ng db1.
[ c, l ] = wave de c( s , 3, ' db1' ) ;
detcoef
8-41
% Ext r act de t ai l c oe f f i ci ent s at l e v el s
% 1, 2 and 3, f r om wav e l e t de compos i t i on
% s t r uc t ur e [ c , l ] .
c d3 = de t c oe f ( c, l , 3) ;
c d2 = de t c oe f ( c, l , 2) ;
c d1 = de t c oe f ( c, l , 1) ;
See Also appcoef , wave de c
500 1000 1500 2000 2500 3000 3500
0
500
1000
Original signal s
0 500
100
0
100
Detail coef. level 3 : cd3
0 500 1000
50
0
50
Detail coef. level 2 : cd2
0 1000 2000
50
0
50
Detail coef. level 1 : cd1
detcoef2
8-42
detcoef2
Purpose Extract 2-D detai l coeffi ci ents.
Syntax D = det coef 2( O, C, S, N)
Description det coef 2 i s a two-di mensi onal wavel et anal ysi s functi on.
D = det coef 2( O, C, S, N) extr acts fr om the wavel et decomposi ti on structure
[ C, S] (see wav edec 2), the hor i zontal , verti cal , or di agonal detai l coeffi ci ents for
O = ' h' (or ' v ' or ' d' , r especti vel y), at l evel N.
Level N must be an i nteger such that 1 <= N <= s i z e( S, 1) - 2.
Examples % Load or i gi nal i mage.
l oad woman;
% X c ont ai ns t he l oaded i mage .
% Per f or m de compos i t i on at l e ve l 2
% of X us i ng db1.
[ c, s ] = wave de c2( X, 2, ' db1' ) ;
s i z ex = s i z e ( X)
s i z ex =
256 256
s i z ec = s i z e ( c )
s i z ec =
1 65536
v al _s = s
v al _s =
64 64
64 64
128 128
256 256
detcoef2
8-43
% Ext r act de t ai l s coef f i c i e nt s at l e ve l 2
% i n each or i e nt at i on, f r om wav el et de compos i t i on
% s t r uc t ur e [ c , s ] .
c hd2 = det coef 2( ' h' , c , s , 2) ;
c vd2 = det coef 2( ' v ' , c , s , 2) ;
c dd2 = det coef 2( ' d' , c , s , 2) ;
s i z ec d2 = s i z e ( c hd2)
s i z ec d2 =
64 64
% Ext r act de t ai l s coef f i c i e nt s at l e ve l 1
% i n each or i e nt at i on, f r om wav el et de compos i t i on
% s t r uc t ur e [ c , s ] .
c hd1 = det coef 2( ' h' , c , s , 1) ;
c vd1 = det coef 2( ' v ' , c , s , 1) ;
c dd1 = det coef 2( ' d' , c , s , 1) ;
s i z ec d1 = s i z e ( c hd1)
s i z ec d1 =
128 128
See Also appcoef 2, wav edec 2
dwt
8-44
dwt
Purpose Si ngl e-l evel di screte 1-D wavel et transfor m.
Syntax [ cA, c D] = dwt ( X, ' wname' )
[ cA, c D] = dwt ( X, Lo_D, Hi _D)
Description The dwt command perfor ms a si ngl e-l evel one-di mensi onal wavel et
decomposi ti on wi th r espect to ei ther a parti cul ar wavel et ('wname', see
wf i l t er s ) or parti cul ar wavel et decomposi ti on fi l ters (Lo_D and Hi _D) you
speci fy.
[ cA, c D] = dwt ( X, 'wname') computes the appr oxi mati on coeffi ci ents vector c A
and detai l coeffi ci ents vector cD, obtai ned by wavel et decomposi ti on of the
vector X.
[ cA, c D] = dwt ( X, Lo_D, Hi _D) computes the wavel et decomposi ti on as above,
gi ven these fi l ters as i nput:
Lo_D i s the decomposi ti on l ow-pass fi l ter and
Hi _D i s the decomposi ti on hi gh-pass fi l ter .
Lo_D and Hi _D must be the same l ength.
I f l x i s the l ength of X and l f i s the l ength of the fi l ters Lo_D and Hi _D, then
l engt h( cA) = l engt h( cD) = f l oor ( ( l x +l f - 1) /2) .
For the di ffer ent si gnal extensi on modes, see dwt mode.
Examples % Cons t r uc t el ement ar y or i gi nal one- di me ns i onal s i gnal .
r andn( ' s ee d' , 531316785)
s = 2 + kr on( one s ( 1, 8) , [ 1 - 1] ) + . . .
( ( 1: 16) . ^2) /32 + 0. 2*r andn( 1, 16) ;
% Per f or m s i ngl e - l ev el di s c r e t e wave l e t t r ans f or m of s by haar .
[ ca1, c d1] = dwt ( s , ' haar ' ) ;
s ubpl ot ( 311) ; pl ot ( s ) ; t i t l e( ' Or i gi nal s i gnal ' ) ;
s ubpl ot ( 323) ; pl ot ( ca1) ; t i t l e ( ' Appr ox . c oe f . f or haar ' ) ;
s ubpl ot ( 324) ; pl ot ( cd1) ; t i t l e ( ' De t ai l c oef . f or haar ' ) ;
dwt
8-45
% For a gi v e n wave l e t , comput e t he t wo as s oc i at ed dec ompos i t i on
% f i l t e r s and comput e appr oxi mat i on and de t ai l coef f i ci ent s
% us i ng di r e ct l y t he f i l t er s .
[ Lo_D, Hi _D] = wf i l t er s ( ' haar ' , ' d' ) ;
[ ca1, cd1] = dwt ( s , Lo_D, Hi _D) ;
% Per f or m s i ngl e - l ev el di s c r e t e wav e l e t t r ans f or m of s by db2
% and obs er v e edge e f f e ct s f or l as t coef f i ci ent s .
% The s e e xt r a coef f i ci e nt s ar e onl y us ed t o ens ur e ex ac t
% gl obal r e c ons t r uct i on.
[ ca2, cd2] = dwt ( s , ' db2' ) ;
s ubpl ot ( 325) ; pl ot ( ca2) ; t i t l e( ' Appr ox . coe f . f or db2' ) ;
s ubpl ot ( 326) ; pl ot ( cd2) ; t i t l e( ' De t ai l c oe f . f or db2' ) ;
Algorithm Star ti ng from a si gnal s, two sets of coeffi ci ents ar e computed: approxi mati on
coeffi ci ents CA
1
and detai l coeffi ci ents CD
1
. These vectors ar e obtai ned by
convol vi ng s wi th the l ow-pass fi l ter Lo_D for appr oxi mati on, and wi th the
hi gh-pass fi l ter Hi _D for detai l , fol l owed by dyadi c deci mati on.
2 4 6 8 10 12 14 16
0
5
10
Original signal
2 4 6 8
0
10
20
Approx. coef. for haar
2 4 6 8
0
1
2
Detail coef. for haar
2 4 6 8
0
10
20
Approx. coef. for db2
2 4 6 8
5
0
5
Detail coef. for db2
dwt
8-46
Mor e preci sel y, the fi rst step i s:
The l ength of each fi l ter i s equal to 2N. I f n = l engt h(s), the si gnal s F and G are
of l ength n + 2N - 1 and then the coeffi ci ents CA
1
and CD
1
ar e of l ength
.
Note: I n or der to deal wi th si gnal -end effects i nvol ved by convol uti on based
al gor i thm, a gl obal var i abl e managed by dwt mode i s used. The possi bl e opti ons
ar e: zer o-paddi ng (used i n the previ ous exampl e, thi s mode i s the defaul t),
symmetri c extensi on, and smooth extensi on. I t shoul d be noted that dwt has
the same si ngl e i nver se functi on i dwt for the thr ee extensi on modes.
Limitations Peri odi zed wavel et tr ansfor m i s handl ed separ atel y (see dwt per and i dwt pe r ).
See Also dwt mode , dwt per , i dwt , wave de c, wav ei nf o
References I . Daubechi es (1992), Ten l ectures on wavel ets, CBMS-NSF confer ence ser i es
i n appl i ed mathemati cs. SI AM Ed.
S. Mal l at (1989), A theory for mul ti resol uti on si gnal decomposi ti on: the
wavel et r epresentati on, I EEE Pattern Anal. and Machine I ntell., vol . 11, no.
7, pp 674693.
Y. Meyer (1990), Ondel ettes et opr ateur s, Tome 1, Her mann Ed. (Engl i sh
tr ansl ati on: Wavel ets and oper ator s, Cambr i dge Uni v. Pr ess. 1993.)
2
s
Lo_D
Hi_D
high-pass
F
G
downsample
downsample approximation coefs
cA
1
cD
1
2
detail coefs
low-pass
2
Where:
X
Convolve with filter X
Keep the even indexed elements
(We call this operation downsampling)
floor
n 1
2
----------- -


N +
dwt2
8-47
dwt2
Purpose Si ngl e-l evel di scr ete 2-D wavel et transform.
Syntax [ c A, c H, cV, c D] = dwt 2( X, ' wname' )
[ c A, c H, cV, c D] = dwt 2( X, Lo_D, Hi _D)
Description The dwt 2 command per forms a si ngl e-l evel two-di mensi onal wavel et
decomposi ti on wi th respect to ei ther a par ti cul ar wavel et ('wname', see
wf i l t er s ) or parti cul ar wavel et decomposi ti on fi l ters (Lo_D and Hi _D) you
speci fy.
[ c A, c H, cV, c D] = dwt 2( X, 'wname') computes the appr oxi mati on coeffi ci ents
matr i x cA and the detai l s coeffi ci ents matr i ces cH, c V, and c D (hor i zontal ,
ver ti cal , and di agonal ), obtai ned by wavel et decomposi ti on of the i nput
matr i x X.
[ c A, c H, cV, c D] = dwt 2( X, Lo_D, Hi _D) computes the two-di mensi onal wavel et
decomposi ti on as above, based on wavel et decomposi ti on fi l ter s you speci fy:
Lo_D i s the decomposi ti on l ow-pass fi l ter and
Hi _D i s the decomposi ti on hi gh-pass fi l ter .
Lo_D and Hi _D must be the same l ength. I f s x = s i z e( X) and l f i s the l ength
of fi l ter s, then s i z e ( c A) = s i z e ( c H) = s i z e ( c V) = s i z e ( c D) =
f l oor ( ( s x +l f - 1) /2) .
For i nformati on about the di fferent di screte wavel et transform extensi on
modes, see dwt mode.
Examples % Load or i gi nal i mage.
l oad woman;
% X c ont ai ns t he l oaded i mage .
% map c ont ai ns t he l oaded c ol or map.
nbc ol = s i z e ( map, 1) ;
% Per f or m s i ngl e - l ev el de compos i t i on
% of X us i ng db1.
[ cA1, cH1, c V1, c D1] = dwt 2( X, ' db1' ) ;
dwt2
8-48
% I mage s c odi ng.
c od_X = wc odemat ( X, nbcol ) ;
c od_c A1 = wc odemat ( cA1, nbcol ) ;
c od_c H1 = wc odemat ( cH1, nbcol ) ;
c od_c V1 = wc odemat ( cV1, nbcol ) ;
c od_c D1 = wc odemat ( cD1, nbcol ) ;
dec 2d = [ . . .
cod_cA1, cod_cH1; . . .
cod_cV1, cod_cD1 . . .
] ;
Algorithm For i mages, an al gor i thm si mi l ar to the one-di mensi onal case i s possi bl e for
two-di mensi onal wavel ets and scal i ng functi ons obtai ned fr om
one-di mensi onal ones by tensor i al product.
Thi s ki nd of two-di mensi onal DWT l eads to a decomposi ti on of appr oxi mati on
coeffi ci ents at l evel j i n four components: the approxi mati on at l evel j + 1 and
the detai l s i n three ori entati ons (hor i zontal , ver ti cal , and di agonal ).
Original image X.
50 100 150 200 250
50
100
150
200
250
One step decomposition
50 100 150 200 250
50
100
150
200
250
dwt2
8-49
The fol l owi ng char t descr i bes the basi c decomposi ti on steps for i mages:
Note: I n or der to deal wi th si gnal -end effects i nvol ved by convol uti on based
al gor i thm, a gl obal var i abl e managed by dwt mode i s used. The possi bl e opti ons
ar e: zer o-paddi ng (used i n the previ ous exampl e, thi s mode i s the defaul t),
symmetri c extensi on, and smooth extensi on. I t shoul d be noted that dwt 2 has
the same si ngl e i nver se functi on i dwt 2 for the three extensi on modes.
Limitations Per i odi zed wavel et transform i s handl ed separatel y (see dwt per 2 and
i dwt per 2).
Two-Dimensional DWT
Decomposition step
rows
Lo_D
Hi_D
rows
CA
j
2 1
columns
Initialization
Downsample columns: keep the even indexed columns
Downsample rows: keep the even indexed rows
Convolve with filter X the rows of the entry
Convolve with filter X the columns of the entry
CA
0
= s for the decomposition initialization
Where:
2 1
2 1
2 1
2 1
2 1
2 1
2 1
X
columns
Hi_D
Lo_D
X
columns
columns
Hi_D
Lo_D
CA
j+1
CD
j+1
CD
j+1
CD
j+1
(h)
(v)
(d)
horizontal
vertical
diagonal
columns
rows
dwt2
8-50
See Also dwt mode , dwt per 2, i dwt 2, wave de c 2, wav ei nf o
References I . Daubechi es (1992), Ten l ectures on wavel ets, CBMS-NSF confer ence ser i es
i n appl i ed mathemati cs. SI AM Ed.
S. Mal l at (1989),A theor y for mul ti r esol uti on si gnal decomposi ti on: the
wavel et r epresentati on, I EEE Pattern Anal. and Machine I ntell., vol . 11, no.
7, pp 674693.
Y. Meyer (1990),Ondel ettes et oprateurs, Tome 1, Hermann Ed. (Engl i sh
tr ansl ati on: Wavel ets and oper ator s, Cambr i dge Uni v. Pr ess. 1993.)
dwtmode
8-51
dwtmode
Purpose Di scr ete wavel et transform extensi on mode.
Syntax dwt mode
dwt mode ( ' mode' ) Where ' mode' can be ' z pd' , ' s y m' , or ' s pd'
Description The dwt mode command sets the si gnal or i mage extensi on mode for di scr ete
wavel et and wavel et packet transforms. The extensi on modes repr esent
di ffer ent ways of handl i ng the pr obl em of bor der di stor ti on i n si gnal and i mage
anal ysi s. For mor e i nformati on, see Deal i ng wi th Bor der Di stor ti on i n
Chapter 6.
dwt mode or dwt mode ( ' s t at us ' ) di spl ays the curr ent mode.
dwt mode ( ' mode' ) sets the DWT extensi on mode accordi ng to the val ue of 'mode':
I f dwt mode i s cal l ed wi th two i nput ar guments, the second one i s dummy and
no text (status or war ni ng) i s di spl ayed i n the MATLAB command wi ndow.
The dwt mode functi on updates a gl obal var i abl e al l owi ng thr ee ways of si gnal
extensi on. Onl y dwt and dwt 2 use the gl obal var i abl e.
Examples % I f t he DWT e xt ens i on mode gl obal v ar i abl e doe s not
% e xi s t , de f aul t i s z e r o- paddi ng.
c l e ar gl obal
dwt mode
**************************************
** DWT Ex t e ns i on Mode: Ze r o- paddi ng **
**************************************
' mode' DWT Extension Mode
' z pd' Zero-paddi ng (defaul t)
' s ym' Symmetr i zati on (boundar y val ue r epl i cati on)
' s pd' Smooth paddi ng (fi r st der i vati ve i nter pol ati on at the edges)
dwtmode
8-52
% Di s pl ay cur r ent DWT s i gnal ex t e ns i on mode.
dwt mode
**************************************
** DWT Ex t ens i on Mode: Ze r o- Paddi ng **
**************************************
% Change t o s y mmet r i z at i on ex t e ns i on mode.
dwt mode ( ' s ym' )
! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
! WARNI NG: Change DWT Ext ens i on Mode !
! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !
****************************************
** DWT Ex t ens i on Mode: Sy mmet r i z at i on **
****************************************
% Di s pl ay cur r ent DWT s i gnal ex t e ns i on mode.
dwt mode
****************************************
** DWT Ex t ens i on Mode: Sy mmet r i z at i on **
****************************************
Note: You shoul d change the extensi on mode onl y by usi ng dwt mode ; avoi d
changi ng the gl obal vari abl e di r ectl y.
Limitations Peri odi zed wavel et transfor m i s handl ed separatel y (see dwt per , dwt pe r 2,
i dwt per , i dwt per 2).
See Also dwt , dwt 2
dwtper
8-53
dwtper
Purpose Si ngl e-l evel di scr ete 1-D wavel et transform (peri odi zed).
Syntax [ c A, c D] = dwt pe r ( X, ' wname' )
[ c A, c D] = dwt pe r ( X, Lo_D, Hi _D)
Description dwt pe r i s a one-di mensi onal wavel et anal ysi s functi on.
[ c A, c D] = dwt pe r ( X, 'wname') computes the approxi mati on coeffi ci ents vector
cA and detai l coeffi ci ents vector c D, obtai ned by per i odi zed wavel et
decomposi ti on of the vector X.
'wname' i s a stri ng contai ni ng the wavel et name (see wf i l t e r s ).
I nstead of gi vi ng the wavel et name, you can gi ve the fi l ter s. When used wi th
three ar guments: [ c A, cD] = dwt pe r ( X, Lo_D, Hi _D) , Lo_D i s the decomposi ti on
l ow-pass fi l ter and Hi _D i s the decomposi ti on hi gh-pass fi l ter .
I f l x = l engt h( X) then l engt h( cA) = l engt h( cD) = c ei l ( l x /2) .
Examples % Set i ni t i al s i gnal and ge t f i l t er s .
x = s i n( 0. 3*[ 1: 300] ) ; l x = l e ngt h( x )
l x =
300
w = ' db9' ;
[ Lo_D, Hi _D, Lo_R, Hi _R] = wf i l t er s ( w) ;
% DWT wi t h z er o- paddi ng s i gnal ex t e ns i on.
[ caz p, c dz p] = dwt ( x, w) ;
% The t r ans f or m us es s ome e xt r a c oe f f i ci ent s ,
% at mos t 2 i f l x i s odd.
l xt z p = 2*l e ngt h( c az p)
l xt z p =
316
dwtper
8-54
% Rec ons t r uc t i on.
x z p = i dwt ( c az p, cdz p, w, l x ) ;
% Er r or wi t h z er o- paddi ng.
e r r z p = max( abs ( x- xz p) )
e r r z p =
7. 3231e- 12
% Per i odi z ed DWT.
[ cap, cdp] = dwt per ( x , w) ;
% The t r ans f or m us es a mi ni mum of ex t r a coef f i c i e nt s .
l xt p = 2*l engt h( cap)
l xt p =
300
% Rec ons t r uc t i on.
x p = i dwt per ( c ap, c dp, w, l x ) ;
% Er r or wi t h per i odi z e d DWT.
e r r p = max ( abs ( x - x p) )
e r r p =
1. 4588e- 11
Algorithm The al gor i thm i s the same as i n dwt but the si gnal X i s extended assumi ng
peri odi ci ty. More pr eci sel y, i f l x = l engt h( X) i s even, the extended si gnal i s
e xt X = [ X( l x- l f +1: l x) X X( 1: l f ) ] where l f i s the l ength of the fi l ter. Then,
usual convol uti on and downsampl i ng oper ati ons ar e done, fol l owed by keepi ng
the central par t of l ength l x /2.
See Also dwt , i dwt pe r
dwtper2
8-55
dwtper2
Purpose Si ngl e-l evel di scr ete 2-D wavel et transform (peri odi zed).
Syntax [ c A, c H, cV, c D] = dwt per 2( X, ' wname' )
[ c A, c H, cV, c D] = dwt per 2( X, Lo_D, Hi _D)
Description dwt pe r 2 i s a two-di mensi onal wavel et anal ysi s functi on.
[ c A, c H, cV, c D] = dwt per 2( X, 'wname') computes the approxi mati on
coeffi ci ents matr i x c A and detai l s coeffi ci ents matri ces cH, c V, and c D, obtai ned
by peri odi zed wavel et decomposi ti on of the i nput matri x X.
'wname' i s a stri ng contai ni ng the wavel et name (see wf i l t e r s ).
I nstead of gi vi ng the wavel et name, you can gi ve the fi l ter s. When used wi th
three ar guments: [ c A, cH, c V, c D] = dwt per 2( X, Lo_D, Hi _D) , Lo_D i s the
decomposi ti on l ow-pass fi l ter and Hi _D i s the decomposi ti on hi gh-pass fi l ter.
I f s x = s i z e( X) then s i z e( cA) = s i z e ( cH) = s i z e ( cV) = s i z e ( cD) =
ce i l ( s x /2) .
Examples % Set i ni t i al s i gnal and ge t f i l t er s .
l oad t i r e
% X c ont ai ns t he l oaded i mage .
s x = s i z e( X)
s x =
205 232
w = ' db9' ;
[ Lo_D, Hi _D, Lo_R, Hi _R] = wf i l t er s ( w) ;
% DWT wi t h z er o- paddi ng i mage e xt ens i on.
[ ca0, ch0, cv 0, c d0] = dwt 2( X, w) ;
% The t r ans f or m us es s ome e xt r a c oe f f i ci ent s .
s xt z p = 2*s i z e ( c a0)
s xt z p =
222 248
dwtper2
8-56
% Rec ons t r uc t i on
x 0 = i dwt 2( c a0, c h0, c v0, cd0, w, s x ) ;
% Er r or wi t h z er o- paddi ng.
e r r 0 = max ( max ( abs ( X- x 0) ) )
e r r 0 =
6. 3292e- 09
% Per i odi z ed DWT
[ cap, chp, c vp, c dp] = dwt pe r 2( X, w) ;
% The t r ans f or m us es a mi ni mum of ex t r a coef f i c i e nt s .
l xt p = 2*s i z e( cap)
l xt p =
206 232
% Rec ons t r uc t i on.
x p = i dwt per 2( cap, chp, c vp, c dp, w, s x ) ;
% Er r or wi t h per i odi z e d DWT.
e r r p = max ( max ( abs ( X- x p) ) )
e r r p =
6. 7353e- 09
Algorithm See the dwt per al gori thm secti on.
See Also dwt 2, i dwt per 2
dyaddown
8-57
dyaddown
Purpose Dyadi c downsampl i ng.
Syntax Y = dyaddown( X, e ve nodd)
Y = dyaddown( X)
Y = dyaddown( X, e ve nodd, ' t ype' )
Y = dyaddown( X, ' t ype' , ev enodd)
Description Y = dy addown( X, ev enodd) , where X i s a vector, r etur ns a ver si on of X that has
been downsampl ed by 2. Whether Y contai ns the even- or odd-i ndexed sampl es
of X depends on the val ue of posi ti ve i nteger ev enodd:
I f e ve nodd i s even, then Y( k) = X( 2k) .
I f e ve nodd i s odd, then Y( k) = X( 2k+1) .
I f you omi t the e ve nodd argument, dy addown( X) defaul ts to e ve nodd = 0
(even-i ndexed sampl es).
Y = dy addown( X, ev enodd,'t ype') or Y = dyaddown( X, 't ype',e ve nodd) , where X
i s a matrix, retur n a versi on of X obtai ned by suppressi ng:
I f you omi t the e ve nodd or 't ype' ar guments, dy addown defaul ts to
ev e nodd = 0 (even-i ndexed sampl es) and ' t ype' = ' c ' (col umns).
Examples % For a v ec t or .
s = 1: 10
s =
1 2 3 4 5 6 7 8 9 10
ds e = dyaddown( s ) % Downs ampl e el e me nt s wi t h ev en i ndi c e s .
ds e =
2 4 6 8 10
Columns of X If ' t ype' = ' c '
Rows of X If ' t ype' = ' r '
Rows and columns of X) If ' t ype' = ' m'
dyaddown
8-58
% or equi v al ent l y
ds e = dyaddown( s , 0)
ds e =
2 4 6 8 10
ds o = dyaddown( s , 1) % Downs ampl e e l e me nt s wi t h odd i ndi c es .
ds o =
1 3 5 7 9
% For a mat r i x .
s = ( 1: 3) ' *[ 1: 4]
s =
1 2 3 4
2 4 6 8
3 6 9 12
dec = dyaddown( s , 0, ' c' ) % Downs ampl e c ol umns wi t h e ve n i ndi c es .
dec =
2 4
4 8
6 12
der = dyaddown( s , 1, ' r ' ) % Downs ampl e r ows wi t h odd i ndi c es .
der =
1 2 3 4
3 6 9 12
See Also dyadup
References G. Str ang, T. Nguyen (1996), Wavelets and Filter Banks, Wel l esl ey-Cambri dge
Press.
dyadup
8-59
dyadup
Purpose Dyadi c upsampl i ng.
Syntax Y = dyadup( X, ev e nodd)
Y = dyadup( X)
Y = dyadup( X, ev e nodd, ' t ype' )
Y = dyadup( X, ' t ype' , ev enodd)
Description dy adup i mpl ements a si mpl e zer o-paddi ng scheme very useful i n the wavel et
reconstr ucti on al gor i thm.
Y = dyadup( X, e ve nodd) , wher e X i s a vector, r etur ns an extended copy of vector
X obtai ned by i nserti ng zer os. Whether the zer os are i nser ted as even- or
odd-i ndexed el ements of Y depends on the val ue of posi ti ve i nteger e ve nodd:
I f e ve nodd i s even, then Y( 2k1) = X( k) , Y( 2k) = 0.
I f e ve nodd i s odd, then Y( 2k1) = 0, Y( 2k) = X( k) .
I f you omi t the ev enodd argument, dy adup( X) defaul ts to e ve nodd = 1 (zeros i n
odd-i ndexed posi ti ons).
Y = dyadup( X, e ve nodd,'t ype') or Y = dy adup( X, 't ype',e ve nodd) , where X i s a
matrix, return extended copi es of X obtai ned by i nserti ng:
I f you omi t the e ve nodd or 't ype' ar guments, dy adup defaul ts to e v enodd = 1
(zeros i n odd-i ndexed posi ti ons) and 't ype' = ' c ' (i nser t col umns).
Columns in X If ' t ype' = ' c '
Rows in X If ' t ype' = ' r '
Rows and columns in X If ' t ype' = ' m'
dyadup
8-60
Examples % For a v e ct or .
s = 1: 5
s =
1 2 3 4 5
ds e = dy adup( s ) % Ups ampl e el e me nt s at odd i ndi ce s .
ds e =
0 1 0 2 0 3 0 4 0 5 0
% or e qui v al ent l y
ds e = dy adup( s , 1)
ds e =
0 1 0 2 0 3 0 4 0 5 0
ds o = dy adup( s , 0) % Ups ampl e e l e me nt s at ev en i ndi c e s .
ds o =
1 0 2 0 3 0 4 0 5
% For a mat r i x .
s = ( 1: 2) ' *[ 1: 3]
s =
1 2 3
2 4 6
der = dy adup( s , 1, ' r ' ) % Ups ampl e r ows at ev en i ndi c e s .
der =
0 0 0
1 2 3
0 0 0
2 4 6
0 0 0
doc = dy adup( s , 0, ' c ' ) % Ups ampl e c ol umns at odd i ndi ce s .
doc =
1 0 2 0 3
2 0 4 0 6
dyadup
8-61
% Us i ng def aul t val ues f or dy adup and dy addown, we have :
% dyaddown( dyadup( s ) ) = s .
s = 1: 5
s =
1 2 3 4 5
uds = dy addown( dyadup( s ) )
uds =
1 2 3 4 5
% I n ge ner al r ev er s ed i de nt i t y i s f al s e.
See Also dy addown
References G. Str ang, T. Nguyen (1996), Wavelets and Filter Banks, Wel l esl ey-Cambr i dge
Press
entrupd
8-62
entru pd
Purpose Entropy update (wavel et packet).
Syntax NDATA = e nt r upd( TREE, DATA, ENT)
NDATA = e nt r upd( TREE, DATA, ENT, PAR)
Description e nt r upd i s a one- or two-di mensi onal wavel et packets uti l i ty.
NDATA = e nt r upd( TREE, DATA, ENT) or
NDATA = e nt r upd( TREE, DATA, ENT, PAR) r eturns for a gi ven wavel et packet
decomposi ti on structure [ TREE, DATA] (see make t r e e), the updated data
str ucture NDATA corr espondi ng to entr opy functi on ENT wi th opti onal par ameter
PAR (see we nt r opy ).
[ TREE, NDATA] i s the r esul ti ng decomposi ti on structure.
Examples % Load s i gnal .
l oad noi s dopp; x = noi s dopp;
% Dec ompos e x at dept h 2 wi t h db1 wave l e t pac ke t s
% us i ng s hannon ent r opy .
[ t , d] = wpde c( x, 2, ' db1' , ' s hannon' ) ;
% Read ent r opy of al l t he nodes .
nodes = al l nodes ( t ) ;
e nt = wdat amgr ( ' r e ad_ent ' , d, node s )
e nt =
1. 0e+04 *
- 5. 8615 - 6. 8204 - 0. 0350 - 7. 7901 - 0. 0497 - 0. 0205 - 0. 0138
% Updat e nodes e nt r opy wi t hout changi ng t r ee
% and dat a s t r uc t ur e s .
d = e nt r upd( t , d, ' t hr e s hol d' , 0. 5) ;
nent = wdat amgr ( ' r e ad_e nt ' , d, nodes )
nent =
937 488 320 241 175 170 163
See Also went r opy, wpdec , wpde c2
errargn
8-63
er rar gn
Purpose Check functi on arguments number .
Syntax er r = e r r ar gn( ' f unct i on' , numar gi n, ar gi n, numar gout , ar gout )
Description er r ar gn i s a gener al uti l i ty.
er r = e r r ar gn( 'f unct i on', numar gi n, ar gi n, numar gout , ar gout ) i s equal to 1
i f ei ther the number of i nput (ar gi n) or output (ar gout ) ar guments of the
speci fi ed f unct i on does not bel ong to the vector of al l owed val ues (numar gi n
and
numar gout , respecti vel y). Otherwi se e r r = 0.
I f e r r = 1, er r ar gn di spl ays an err or message i n the command wi ndow. The
header of thi s err or message contai ns the str i ng ' f unct i on' .
Examples I n thi s exampl e, er r ar gn r epor ts an i mpr oper cal l to functi on l i ne :
e r r = e r r ar gn( ' l i ne' , 4, [ 2 3] , 0, [ 0 1] ) ;

****************************************
ERROR . . .
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
l i ne - - - > i nv al i d number of ar gume nt s
****************************************
Her e, s ur f i s passed the pr oper number of arguments, so no error message
resul ts:
e r r = e r r ar gn( ' s ur f ' , 4, [ 3 4] , 0, [ 0 1] ) ;
See Also er r ar gt
errargt
8-64
er rar gt
Purpose Check functi on arguments type.
Syntax ERR = e r r ar gt ( NDFCT, VAR, TYPE)
ERR = e r r ar gt ( NDFCT, VAR, ' ms g' )
Description e r r ar gn i s a general uti l i ty.
ERR = e r r ar gt ( NDFCT, VAR, TYPE) i s equal to 1 i f any el ement of i nput vector
or matr i x VAR (dependi ng on TYPE choi ce l i sted bel ow) i s not of type prescri bed
by i nput str i ng TYPE. Other wi se ERR = 0.
I f ERR = 1, an er ror message i s di spl ayed i n the command wi ndow. I n the header
message, the str i ng NDFCT i s di spl ayed. Thi s str i ng contai ns the name of a
functi on.
Avai l abl e opti ons for TYPE ar e:
' i nt ' Stri ctl y posi ti ve i nteger s (excl udi ng zero)
' i n0' Posi ti ve i ntegers (i ncl udi ng zero)
' r e l ' I nteger s
' r e p' Stri ctl y posi ti ve real s (excl udi ng zer o)
' r e 0' Posi ti ve r eal s (i ncl udi ng zero)
' s t r ' Stri ng
' ve c' Vector
' r ow' Row vector
' col ' Col umn vector
' dat ' Dates AAAAMMJ J HHMNSS wi th:
' mon' Months MM wi th:
0 AAAA 9999
1 MM 12
1 JJ 31
0 HH 23
0 MN 59
0 SS 59
1 MM 12
errargt
8-65
A speci al use of e r r ar gt i s:
ERR = e r r ar gt ( NDFCT, VAR, ' ms g' ) for whi ch ERR = 1 and the stri ng VAR i s the
err or message.
See Also er r ar gn
idwt
8-66
i dwt
Purpose Si ngl e-l evel i nverse di scr ete 1-D wavel et transform.
Syntax X = i dwt ( cA, c D, ' wname' )
X = i dwt ( cA, c D, Lo_R, Hi _R)
X = i dwt ( cA, c D, ' wname' , L)
X = i dwt ( cA, c D, Lo_R, Hi _R, L)
Description The i dwt command performs a si ngl e-l evel one-di mensi onal wavel et
reconstructi on wi th respect to ei ther a par ti cul ar wavel et ('wname', see
wf i l t er s ) or parti cul ar wavel et r econstructi on fi l ters (Lo_R and Hi _R) you
speci fy.
X = i dwt ( cA, c D, 'wname' ) r etur ns the si ngl e-l evel reconstr ucted
approxi mati on coeffi ci ents vector X based on approxi mati on and detai l
coeffi ci ents vectors cA and cD, and usi ng the wavel et 'wname' .
X = i dwt ( cA, c D, Lo_R, Hi _R) reconstr ucts as above usi ng fi l ters you speci fy:
Lo_R i s the r econstructi on l ow-pass fi l ter
Hi _R i s the r econstructi on hi gh-pass fi l ter
Lo_R and Hi _R must be the same l ength. I f l a i s the l ength of c A (whi ch al so
equal s the l ength of c D) and l f i s the l ength of the fi l ter s Lo_R and Hi _R, then
l engt h( X) = 2*l a- l f +2.
X = i dwt ( cA, c D, 'wname' , L) or X = i dwt ( c A, cD, Lo_R, Hi _R, L) , returns the
l ength-L centr al por ti on of the r esul t obtai ned usi ng i dwt ( c A, c D, 'wname' ) . L
must be l ess than 2*l a- l f +2.
Examples i dwt i s the i nver se functi on of dwt i n the sense that the abstr act statement
i dwt ( dwt ( X, 'wname' ) , 'wname' ) gi ves back X. Consi der thi s exampl e.
% Cons t r uc t el ement ar y one- di me ns i onal s i gnal s .
r andn( ' s ee d' , 531316785)
s = 2 + kr on( ones ( 1, 8) , [ 1 - 1] ) + . . .
( ( 1: 16) . ^2) /32 + 0. 2*r andn( 1, 16) ;
idwt
8-67
% Per f or m s i ngl e - l ev el dwt of s us i ng db2.
[ ca1, c d1] = dwt ( s , ' db2' ) ;
s ubpl ot ( 221) ; pl ot ( ca1) ;
t i t l e ( ' Appr ox. c oef . f or db2' ) ;
s ubpl ot ( 222) ; pl ot ( cd1) ;
t i t l e ( ' Det ai l coe f . f or db2' ) ;
% Per f or m s i ngl e - l ev el i nve r s e di s c r et e wave l e t t r ans f or m,
% i l l us t r at i ng t hat i dwt i s t he i nv e r s e f unc t i on of dwt .
s s = i dwt ( ca1, cd1, ' db2' ) ;
e r r = nor m( s - s s ) ; % Chec k r e cons t r uct i on.
s ubpl ot ( 212) ; pl ot ( [ s ; s s ] ' ) ;
t i t l e ( ' Or i gi nal and r ec ons t r uc t e d s i gnal s ' ) ;
x l abe l ( [ ' Er r or nor m = ' , num2s t r ( er r ) ] )
% For a gi v e n wave l e t , comput e t he t wo as s oc i at ed
% r ec ons t r uc t i on f i l t e r s and i nve r s e t r ans f or m us i ng
% t he f i l t e r s di r e ct l y .
[ Lo_R, Hi _R] = wf i l t er s ( ' db2' , ' r ' ) ;
s s = i dwt ( ca1, cd1, Lo_R, Hi _R) ;
2 4 6 8
0
5
10
15
Approx. coef. for db2
2 4 6 8
1
0
1
2
Detail coef. for db2
2 4 6 8 10 12 14 16
0
5
10
Original and reconstructed signals
Error norm = 1.435e12
idwt
8-68
Algorithm Starti ng from the approxi mati on and detai l coeffi ci ents at l evel j, cA
j
and cD
j
,
the i nverse di screte wavel et tr ansfor m r econstructs cA
j-1
, i nver ti ng the
decomposi ti on step by i nserti ng zeros and convol vi ng the r esul ts wi th the
reconstructi on fi l ter s.
See Also dwt , i dwt pe r , upwl e v
References I . Daubechi es (1992), Ten l ectures on wavel ets, CBMS-NSF confer ence ser i es
i n appl i ed mathemati cs. SI AM Ed.
S. Mal l at (1989), A theory for mul ti resol uti on si gnal decomposi ti on: the
wavel et r epresentati on, I EEE Pattern Anal. and Machine I ntell., vol . 11, no.
7, pp 674693.
Y. Meyer (1990), Ondel ettes et opr ateur s, Tome 1, Her mann Ed. (Engl i sh
tr ansl ati on: Wavel ets and oper ator s, Cambr i dge Uni v. Pr ess. 1993.)
cA
j-1
Lo_R
Hi_R
high-pass
U
upsample
upsample
cA
j
cD
j
2
level j
low-pass
Where:
2
X Convolve with filter X
Insert zeros at odd-indexed elements
Take the central part of U with the
2
wkeep
wkeep
convenient length
level j-1
One-Dimensional IDWT
Reconstruction step
idwt2
8-69
i dwt2
Purpose Si ngl e-l evel i nver se di scr ete 2-D wavel et transform.
Syntax X = i dwt 2( c A, cH, cV, c D, ' wname' )
X = i dwt 2( c A, cH, cV, c D, Lo_R, Hi _R)
X = i dwt 2( c A, cH, cV, c D, ' wname' , S)
X = i dwt 2( c A, cH, cV, c D, Lo_R, Hi _R, S)
Description The i dwt 2 command perfor ms a si ngl e-l evel two-di mensi onal wavel et
reconstr ucti on wi th respect to ei ther a par ti cul ar wavel et ('wname', see
wf i l t er s ) or parti cul ar wavel et r econstructi on fi l ter s (Lo_R and Hi _R) you
speci fy.
X = i dwt 2( c A, cH, cV, c D, 'wname') uses the wavel et 'wname' to compute the
si ngl e-l evel reconstr ucted appr oxi mati on coeffi ci ents vector X based on
approxi mati on vector cA and (hori zontal , verti cal , and di agonal ) detai l vectors
cH, cV and c D.
X = i dwt 2( c A, cH, cV, c D, Lo_R, Hi _R) reconstr ucts as above, usi ng fi l ters you
speci fy:
Lo_R i s the r econstructi on l ow-pass fi l ter
Hi _R i s the r econstructi on hi gh-pass fi l ter
Lo_R and Hi _R must be the same l ength.
I f s a = s i z e ( c A) = s i z e ( c H) = s i z e( c V) = s i z e( cD) and l f i s the l ength of
the fi l ter s, then s i z e ( X) = 2*s i z e( cA) - l f +2.
X = i dwt 2( c A, cH, cV, c D, 'wname', S) and X =
i dwt 2( c A, cH, c V, c D, Lo_R, Hi _R, S) return the si ze S centr al por ti on of the
resul t obtai ned usi ng the syntax i dwt 2( cA, c H, c V, cD, 'wname' ) . S must be l ess
than 2*s i z e ( cA) - l f +2.
Examples i dwt 2 i s the i nverse functi on of dwt 2 i n the sense that the abstr act statement
i dwt 2( dwt 2( X, 'wname' ) , 'wname' ) gi ves back X. Consi der thi s exampl e.
% Load or i gi nal i mage.
l oad woman;
% X c ont ai ns t he l oaded i mage .
s X = s i z e( X) ;
idwt2
8-70
% Per f or m s i ngl e - l ev el de compos i t i on
% of X us i ng db4.
[ cA1, c H1, c V1, c D1] = dwt 2( X, ' db4' ) ;
% I nv er t di r ec t l y de compos i t i on of X
% us i ng c oef f i ci ent s at l ev el 1.
A0 = i dwt 2( c A1, c H1, cV1, cD1, ' db4' , s X) ;
% Che ck f or pe r f ec t r e c ons t r uct i on.
max ( max( X- A0) )
ans =
3. 3032e- 10
Algorithm
See Also dwt 2, i dwt per 2, upwl e v2
Two-Dimensional IDWT
Reconstruction step
cA
j
rows
Upsample columns: insert zeros at odd-indexed columns
Upsample rows: insert zeros at odd-indexed rows
Convolve with filter X the rows of the entry
Convolve with filter X the columns of the entry
Where:
1 2
1 2
1 2
1 2
2 1
2 1
X
rows
Hi_R
Lo_R
X
rows
rows
Hi_R
Lo_R
cA
j+1
cD
j+1
cD
j+1
cD
j+1
(h)
(v)
(d)
horizontal
vertical
diagonal
columns
rows
columns
Lo_R
Hi_R
columns
1 2
1 2
wkeep
idwtper
8-71
i dwtper
Purpose Si ngl e-l evel i nver se di scr ete 1-D wavel et transform (peri odi zed).
Syntax X = i dwt per ( c A, c D, ' wname' )
X = i dwt per ( c A, c D, Lo_R, Hi _R)
X = i dwt per ( c A, c D, ' wname' , L)
X = i dwt per ( c A, c D, Lo_R, Hi _R, L)
Description i dwt per i s a one-di mensi onal wavel et anal ysi s functi on.
X = i dwt per ( c A, c D, 'wname') returns the si ngl e-l evel r econstructed
approxi mati on coeffi ci ents vector X based on appr oxi mati on and detai l vector s
cA and cD at a gi ven l evel , usi ng the per i odi zed i nverse wavel et tr ansfor m.
'wname' i s a stri ng contai ni ng the wavel et name (see wf i l t e r s ).
I nstead of gi vi ng the wavel et name, you can gi ve the fi l ter s.
For X = i dwt pe r ( c A, cD, Lo_R, Hi _R) :
Lo_R i s the reconstr ucti on l ow-pass fi l ter .
Hi _R i s the reconstr ucti on hi gh-pass fi l ter .
I f l a = l engt h( cA) = l engt h( cD) then l e ngt h( X) = 2*l a.
For X = i dwt pe r ( cA, cD, 'wname', L) or X = i dwt per ( c A, cD, Lo_R, Hi _R, L) , L i s
the l ength of the r esul t.
i dwt per i s the i nver se functi on of dwt pe r i n the sense that the abstract
statement i dwt pe r ( dwt pe r ( X, 'wname') , 'wname') gets back to X.
Examples % Set i ni t i al s i gnal and ge t f i l t er s .
x = s i n( 0. 3*[ 1: 300] ) ; l x = l e ngt h( x )
l x =
300
w = ' db9' ;
[ Lo_D, Hi _D, Lo_R, Hi _R] = wf i l t er s ( w) ;
% DWT wi t h z er o- paddi ng s i gnal ex t e ns i on.
[ caz p, c dz p] = dwt ( x, w) ;
idwtper
8-72
% The t r ans f or m us es s ome e xt r a c oef f i ci ent s ,
% at mos t 2 i f l x i s odd.
l xt z p = 2*l e ngt h( c az p)
l xt z p =
316
% Rec ons t r uc t i on.
x z p = i dwt ( c az p, cdz p, w, l x ) ;
% Er r or wi t h z er o- paddi ng.
e r r z p = max( abs ( x- xz p) )
e r r z p =
7. 3231e- 12
% Per i odi z ed DWT.
[ cap, cdp] = dwt per ( x , w) ;
% The t r ans f or m us es a mi ni mum of ex t r a coef f i c i e nt s .
l xt p = 2*l engt h( cap)
l xt p =
300
% Rec ons t r uc t i on.
x p = i dwt per ( c ap, c dp, w, l x ) ;
% Er r or wi t h per i odi z e d DWT.
e r r p = max ( abs ( x - x p) )
e r r p =
1. 4588e- 11
Note: I n general , the fol l owi ng abstr act statement i s not tr ue:
i dwt per ( dwt ( X, 'wname') , 'wname') = X .
See Also dwt pe r
idwtper2
8-73
i dwtper2
Purpose Si ngl e-l evel i nver se di scr ete 2-D wavel et transform (peri odi zed).
Syntax X = i dwt per 2( cA, cH, c V, cD, ' wname' )
X = i dwt per 2( cA, cH, c V, cD, Lo_R, Hi _R)
X = i dwt per 2( cA, cH, c V, cD, ' wname' , S)
X = i dwt per 2( cA, cH, c V, cD, Lo_R, Hi _R, S)
Description i dwt per 2 i s a two-di mensi onal wavel et anal ysi s functi on.
X = i dwt per 2( cA, cH, c V, cD, 'wname') returns the si ngl e-l evel r econstructed
approxi mati on coeffi ci ents vector X based on approxi mati on and detai l s vector s
cA, c H, c V, and cD at a gi ven l evel , usi ng the per i odi zed i nverse wavel et
tr ansfor m. 'wname' i s a stri ng contai ni ng the wavel et name (see wf i l t e r s ).
I nstead of gi vi ng the wavel et name, you can gi ve the fi l ter s.
For X = i dwt pe r 2( cA, c H, cV, cD, Lo_R, Hi _R) , Lo_R i s the reconstr ucti on
l ow-pass fi l ter and Hi _R i s the r econstructi on hi gh-pass fi l ter .
I f s a = s i z e ( c A) = s i z e ( c H) = s i z e( cV) = s i z e( cD) , then s i z e ( X) = 2*s a.
For X = i dwt pe r 2( cA, c H, cV, cD, 'wname', S) or
X = i dwt per 2( cA, cH, c V, cD, Lo_R, Hi _R, S) , S i s the si ze of the r esul t.
i dwt per 2 i s the i nver se functi on of dwt pe r 2 i n the sense the abstr act statement
i dwt per 2( dwt per 2( X, 'wname') , 'wname') gets back to X.
Examples % Set i ni t i al s i gnal and ge t f i l t er s .
l oad t i r e
% X c ont ai ns t he l oaded i mage .
s x = s i z e( X)
s x =
205 232
w = ' db9' ;
[ Lo_D, Hi _D, Lo_R, Hi _R] = wf i l t er s ( w) ;
% DWT wi t h z er o- paddi ng i mage e xt ens i on.
[ ca0, ch0, cv 0, c d0] = dwt 2( X, w) ;
idwtper2
8-74
% The t r ans f or m us es s ome e xt r a c oef f i ci ent s .
s xt z p = 2*s i z e ( c a0)
s xt z p =
222 248
% Rec ons t r uc t i on.
x 0 = i dwt 2( c a0, c h0, c v0, cd0, w, s x ) ;
% Er r or wi t h z er o- paddi ng.
e r r 0 = max ( max ( abs ( X- x 0) ) )
e r r 0 =
6. 3292e- 09
% Per i odi z ed DWT.
[ cap, chp, c vp, c dp] = dwt pe r 2( X, w) ;
% The t r ans f or m us es a mi ni mum of ex t r a coef f i c i e nt s .
l xt p = 2*s i z e( cap)
l xt p =
206 232
% Rec ons t r uc t i on.
x p = i dwt per 2( cap, chp, c vp, c dp, w, s x ) ;
% Er r or wi t h per i odi z e d DWT.
e r r p = max ( max ( abs ( X- x p) ) )
e r r p =
6. 7353e- 09
Note: I n general , the fol l owi ng abstr act statement i s not tr ue:
i dwt per 2( dwt 2( X, 'wname') , 'wname') = X.
See Also dwt pe r 2
ind2depo
8-75
i nd2depo
Purpose Node i ndex to node depth-posi ti on.
Syntax [ D, P] = i nd2depo( ORD, N)
Description i nd2depo i s a tree management uti l i ty.
For a tr ee of order ORD, [ D, P] = i nd2depo( ORD, N) computes the depths D and
the posi ti ons P (at thi s depths D) for the nodes wi th i ndi ces N.
The nodes are number ed from l eft to r i ght and fr om top to bottom. The r oot
i ndex i s 0.
D, P, N are col umn vector s. The val ues of D, P, N ar e constr ai ned by:
D = depths, 0 D dmax
P = posi ti ons at depth D, 0 P order
D-1
N = i ndi ces, 0 N < (order
(dmax+1)
-1)/(order-1)
Note that [ D, P] = i nd2depo( ORD, [ D P] ) .
Examples % Cr e at e i ni t i al t r e e.
or d = 2; t = maket r ee ( or d, 3) ; % Bi nar y t r e e of dept h 3.
t t = nodej oi n( t , 5) ;
t t = nodej oi n( t t , 4) ;
pl ot t r e e ( t t )
(1) (2)
(3) (4) (5) (6)
(7) (8) (13) (14)
(0)
ind2depo
8-76
% Li s t t t node s ( i ndex ) .
al n_i nd = al l nodes ( t t )
al n_i nd =
0
1
2
3
4
5
6
7
8
13
14
% Swi t c h f r om i nde x t o de pt h- pos i t i on.
[ de pt h, pos ] = i nd2de po( or d, al n_i nd) ;
al n_depo = [ de pt h, pos ]
al n_depo =
0 0
1 0
1 1
2 0
2 1
2 2
2 3
3 0
3 1
3 6
3 7
See Also depo2i nd, maket r e e, wt r ee mgr
instdfft
8-77
i nstdfft
Purpose I nver se nonstandar d 1-D fast Four i er transfor m.
Syntax [ X, T] = i ns t df f t ( XHAT, LOWB, UPPB)
Description i ns t df f t i s a general mathemati cal uti l i ty.
[ X, T] = i ns t df f t ( XHAT, LOWB, UPPB) r etur ns the i nver se nonstandar d FFT of
XHAT, on a power of 2 regul ar gri d (not necessari l y i nteger s) on the i nter val
[ LOWB, UPPB] .
Output arguments ar e X the r ecovered si gnal computed on the ti me i nterval T
gi ven by T = LOWB + [ 0: n- 1] *( UPPB- LOWB) /n, where n i s the l ength of XHAT.
Outputs ar e vector s of l ength n.
Algorithm See ns t df f t al gor i thm secti on.
Limitations The l ength of XHAT must be a power of two.
See Also f f t , i f f t , ns t df f t
intwave
8-78
i ntwave
Purpose I ntegrate wavel et functi on psi .
Syntax [ I NTEG, XVAL] = i nt wave ( ' wname' , PREC)
[ I NTEG, XVAL] = i nt wave ( ' wname' , PREC, PFLAG)
[ I NTEG, XVAL] = i nt wave ( ' wname' )
Description [ I NTEG, XVAL] = i nt wav e( 'wname', PREC) r etur ns val ues of the wavel et functi on
i ntegr al s I NTEG (from to XVAL val ues): for x i n XVAL.
The functi on i s appr oxi mated on the 2PREC poi nts gri d XVAL, where PREC i s a
posi ti ve i nteger. 'wname' i s a str i ng contai ni ng the name of the wavel et (see
wf i l t er s ).
When used wi th three ar guments, the thi r d one i s a dummy ar gument.
[ I NTEG, XVAL] = i nt wav e( 'wname', PREC, PFLAG) i n addi ti on pl ots I NTEG on XVAL
gr i d i f PFLAG i s nonzero.
[ I NTEG, XVAL] = i nt wave ( 'wname', PREC) i s equi val ent to
[ I NTEG, XVAL] = i nt wave ( 'wname', PREC, 0) .
[ I NTEG, XVAL] = i nt wave ( 'wname') i s equi val ent to
[ I NTEG, XVAL] = i nt wave ( 'wname', 8) .
i nt wave i s used onl y for conti nuous anal ysi s (see c wt ).
y ( ) y d

x

intwave
8-79
Examples % Set wav el e t name .
wname = ' db4' ;
% Pl ot wave l et f unct i on.
[ phi , ps i , x val ] = wave f un( wname, 7) ;
s ubpl ot ( 211) ; pl ot ( xv al , ps i ) ; t i t l e( ' Wav el e t ' ) ;
% Comput e and pl ot wav e l e t i nt e gr al s appr oxi mat i ons
% on a dy adi c gr i d.
[ i nt e g, x val ] = i nt wav e( wname, 7) ;
s ubpl ot ( 212) ; pl ot ( xv al , i nt eg) ;
t i t l e ( [ ' Wave l e t i nt egr al s ove r [ - I nf x ] ' . . .
' f or e ac h val ue of xv al ' ] ) ;
Algorithm Fi rst, the wavel et functi on i s approxi mated on a gr i d of 2
PREC
poi nts usi ng
wav ef un. A pi ecewi se constant i nter pol ati on i s used i n order to compute the
i ntegral s usi ng cums um.
See Also wav ef un
0 1 2 3 4 5 6 7
1
0
1
2
Wavelet
0 1 2 3 4 5 6 7
0.4
0.2
0
0.2
0.4
Wavelet integrals over [Inf x] for each value of xval
isnode
8-80
i snode
Purpose True for exi sti ng node.
Syntax R = i s node( T, N)
Description i s node i s a tree management uti l i ty.
R = i s node( T, N) returns 1s for nodes N, whi ch exi st i n the tree structure T,
and 0s for others. N can be a col umn vector contai ni ng the i ndi ces of nodes or a
matr i x, that contai ns the depths and posi ti ons of nodes.
I n the l ast case, N( i , 1) i s the depth of i -th node and N( i , 2) i s the posi ti on of
i -th node.
The nodes are number ed fr om l eft to r i ght and fr om top to bottom. The r oot
i ndex i s 0.
Examples % Cr e at e i ni t i al t r e e.
or d = 2;
t = make t r ee ( or d, 3) ; % bi nar y t r e e of de pt h 3.
t t = nodej oi n( t , 5) ;
isnode
8-81
t t = nodej oi n( t t , 4) ;
pl ot t r e e ( t t )
% Che ck node i ndex .
i s node( t t , [ 1; 3; 25] )
ans =
1
1
0
% Che ck node dept h- pos i t i on.
i s node( t t , [ 1 0; 3 1; 4 5] )
ans =
1
1
0
See Also i s t node , make t r ee , wt r e emgr
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,6) (3,7)
(0,0)
(1) (2)
(3) (4) (5) (6)
(7) (8) (13) (14)
(0)
istnode
8-82
i stn ode
Purpose Check i f nodes are termi nal nodes.
Syntax R = i s t node ( T, N)
Description i s t node i s a tr ee management uti l i ty.
R = i s t node ( T, N) r etur ns ranks (i n l eft to ri ght termi nal nodes or der i ng) for
termi nal nodes N bel ongi ng to the tree str uctur e T and 0s for others.
N can be a col umn vector contai ni ng the i ndi ces of nodes or a matri x that
contai ns the depths and posi ti ons of nodes.
I n the l ast case, N( i , 1) i s the depth of i -th node and N( i , 2) i s the posi ti on of
i -th node.
The nodes are number ed fr om l eft to r i ght and fr om top to bottom. The r oot
i ndex i s 0.
Examples % Cr eate i ni ti al tr ee.
or d = 2;
t = make t r ee ( or d, 3) ; % bi nar y t r ee of de pt h 3.
t t = nodej oi n( t , 5) ;
t t = nodej oi n( t t , 4) ;
pl ot t r ee ( t t )
istnode
8-83
% Fi nd t e r mi nal node s and r et ur n i ndi c es f or t e r mi nal
% nodes i n t he t r e e s t r uc t ur e .
i s t node ( t t , [ 14] )
ans =
6
i s t node ( t t , [ 15] )
ans =
0
i s t node ( t t , [ 1; 7; 14; 25] )
ans =
0
1
6
0
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,6) (3,7)
(0,0)
(1) (2)
(3) (4) (5) (6)
(7) (8) (13) (14)
(0)
istnode
8-84
i s t node( t t , [ 1 0; 3 1; 4 5] )
ans =
0
2
0
See Also i s node, maket r e e, wt r ee mgr
maketree
8-85
maketr ee
8
Purpose Make tree.
Syntax [ T, NB] = make t r e e( ORD, D)
[ T, NB] = make t r e e( ORD, D, NBI )
[ T, NB] = make t r e e( ORD)
Description maket r e e i s a tree management uti l i ty.
maket r e e creates a tree of order ORD and depth D. ORD i s an i nteger equal to the
number of chi l dren of a gener i c node. Each nontermi nal node has ORD chi l dren.
For wavel et packet decomposi ti on, a conveni ent structure i s a bi nar y tree for
the one-di mensi onal case (ORD = 2) and a quaternary tr ee for the
two-di mensi onal case (ORD = 4). The depth D i s the number of l evel s of the tr ee.
[ T, NB] = make t r ee ( ORD, D) cr eates a tree structure of order ORD wi th depth D.
Output ar gument NB i s the number of termi nal nodes (NB = ORD^D). Output
vector T i s organi zed as:
[ T( 1) . . . T( NB+1) ] where T( i ) , i = 1, . . . , NB ar e the i ndi ces of the
termi nal nodes and T( NB+1) = - ORD.
The nodes are number ed from l eft to r i ght and fr om top to bottom. The r oot
i ndex i s 0.
When used wi th thr ee i nput arguments, [ T, NB] = maket r e e( ORD, D, NBI )
computes T as a ( 1+NBI ) - by-( NB+1) matr i x wi th T( 1, : ) as above and in the
range T( 2: NBI +1, : ) the user i s fr ee to add thei r own mater i al .
[ T, NB] = make t r e e( ORD) i s equi val ent to [ T, NB] = maket r e e( ORD, 0, 0) .
[ T, NB] = make t r e e( ORD, D) i s equi val ent to [ T, NB] = maket r e e ( ORD, D, 0) .
maketree
8-86
Examples % Cr e at e bi nar y t r ee ( t r e e of or de r 2) of de pt h 3.
t 2 = maket r e e( 2, 3) ;
% Pl ot t r e e s t r uct ur e t 2.
pl ot t r ee ( t 2)
% Cr e at e bi nar y t r ee ( t r e e of or de r 4) of de pt h 2.
t 4 = maket r e e( 4, 2) ;
% Pl ot t r e e s t r uct ur e t 4.
pl ot t r ee ( t 4)
See Also pl ot t r e e, wt r e emgr
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)
(0,0)
(1,0) (1,1) (1,2) (1,3)
(2,0) (2,1) (2,2) (2,3) (2,4) (2,5) (2,6) (2,7) (2,8) (2,9) (2,10) (2,11) (2,12) (2,13) (2,14) (2,15)
(0,0)
mexihat
8-87
mexi hat
Purpose Mexi can hat wavel et.
Syntax [ PSI , X] = mex i hat ( LB, UB, N)
Description [ PSI , X] = me xi hat ( LB, UB, N) returns val ues of the Mexi can hat wavel et on an
N poi nt r egul ar gri d, X, on the i nterval [ LB, UB] .
Output ar guments ar e the wavel et functi on ps i computed on the gr i d X, and
the gr i d X.
Thi s wavel et has [-5 5] as effecti ve suppor t.
Thi s functi on i s proporti onal to the second deri vati ve functi on of the Gaussi an
probabi l i ty densi ty functi on.
Examples % Set e f f ec t i v e s uppor t and gr i d par amet er s .
l b = - 5; ub = 5; n = 1000;
% Comput e and pl ot Mex i can hat wave l et .
[ ps i , x] = me xi hat ( l b, ub, n) ;
pl ot ( x, ps i ) , t i t l e ( ' Mex i c an hat wave l e t ' )
See Also wav ei nf o
x ( )
2
3
-------
1 4


1 x
2
( )e
x
2
2
=
5 0 5
0.4
0.2
0
0.2
0.4
0.6
0.8
1
Mexican hat wavelet
meyer
8-88
meyer
Purpose Meyer wavel et.
Syntax [ PHI , PSI , T] = me ye r ( LOWB, UPPB, N)
[ PHI , T] = mey e r ( LOWB, UPPB, N, ' phi ' )
[ PSI , T] = mey e r ( LOWB, UPPB, N, ' ps i ' )
Description [ PHI , PSI , T] = me ye r ( LOWB, UPPB, N) returns Meyer wavel et and scal i ng
functi ons eval uated on an N poi nt r egul ar gr i d on the i nterval [ LOWB, UPPB] .
N must be a power of two.
Output ar guments ar e the scal i ng functi on PHI and the wavel et functi on PSI
computed on the gr i d T. These functi ons have [-8 8] as effecti ve suppor t.
A fourth argument i s al l owed i f onl y one functi on i s requi red:
[ PHI , T] = mey e r ( LOWB, UPPB, N, ' phi ' )
[ PSI , T] = mey e r ( LOWB, UPPB, N, ' ps i ' )
when the fourth argument i s used but not equal to ' phi ' or ' ps i ' . Outputs are
the same as i n the mai n opti on.
The Meyer wavel et and scal i ng functi on are defi ned i n the fr equency domai n
by:

( ) 0 if =
2
3
------
8
3
------ [ , ]
( ) 2 ( )
1 2
e
i 2
2
---
3
2
------ 1




sin =
if 2
3
------
4
3
------
( ) 2 ( )
1 2
e
i 2
2
---
3
4
------ 1




cos = if
4
3
------
8
3
------
meyer
8-89
where

By changi ng the auxi l i ary functi on (see mey er aux ), you get a fami l y of di fferent
wavel ets. For the r equi red properti es of the auxi l i ary functi on , see Refer ences
i n Chapter 6.
a ( ) a
4
35 84a 70a
2
20a
3
+ ( ), = a 0 1 [ , ]

( ) 2 ( )
1 2
= if
2
3
------ ,

( ) 2 ( )
1 2
=

2
---
3
2
------ 1




cos if
2
3
------
4
3
------

( ) 0 = if
4
3
------ >
meyer
8-90
Examples % Set e f f e ct i v e s uppor t and gr i d par amet er s .
l owb = - 8; uppb = 8; n = 1024;
% Comput e and pl ot Mey e r wave l e t and s cal i ng f unc t i on.
[ phi , ps i , x ] = me ye r ( l owb, uppb, n) ;
s ubpl ot ( 211) , pl ot ( x, ps i )
t i t l e ( ' Mey er wav el e t ' )
s ubpl ot ( 212) , pl ot ( x, phi )
t i t l e ( ' Mey er s cal i ng f unc t i on' )
Algorithm Starti ng fr om an expl i ci t form of the Fouri er transfor m of , mey er computes
the val ues of on a regul ar gr i d and then the val ues of ar e computed usi ng
i ns t df f t , the i nver se nonstandar d di scr ete FFT.
The pr ocedur e for i s al ong the same l i nes.
See Also mey er aux, wave f un, wave i nf o
References I . Daubechi es (1992), Ten l ectures on wavel ets, CBMS-NSF confer ence ser i es
i n appl i ed mathemati cs. SI AM Ed. pp 117-119, 137, 152.
8 6 4 2 0 2 4 6 8
1
0
1
2
Meyer wavelet
8 6 4 2 0 2 4 6 8
0.5
0
0.5
1
1.5
Meyer scaling function

meyeraux
8-91
meyer aux
Purpose Meyer wavel et auxi l i ar y functi on.
Syntax Y = mey er aux( X)
Description Y = me ye r aux ( X) r etur ns val ues of the auxi l i ary functi on used for Meyer
wavel et generati on eval uated at the el ements of the vector or matri x X.
The functi on i s
See Also me y er
35x
4
84x
5
70x
6
20x
7
+
morlet
8-92
morl et
Purpose Mor l et wavel et.
Syntax [ PSI , X] = mor l et ( LB, UB, N)
Description [ PSI , X] = mor l e t ( LB, UB, N) r etur ns val ues of the Morl et wavel et on an N poi nt
regul ar gri d, X, on the i nterval [ LB, UB] .
Output ar guments ar e the wavel et functi on PSI computed on the gri d X, and
the gr i d X. Thi s wavel et has [-4 4] as effecti ve support.
Examples % Set e f f e ct i v e s uppor t and gr i d par amet er s .
l b = - 4; ub = 4; n = 1000;
% Comput e and pl ot Mor l et wav el et .
[ ps i , x ] = mor l et ( l b, ub, n) ;
pl ot ( x , ps i ) , t i t l e ( ' Mor l e t wav el et ' )
See Also wav ei nf o
x ( ) e
x
2
2
5x ( ) cos =
4 2 0 2 4
1
0.5
0
0.5
1
Morlet wavelet
nodeasc
8-93
nodeasc
Purpose Node ascendants.
Syntax A = nodeas c ( T, N)
A = nodeas c ( T, N, ' deppos ' )
Description nodeas c i s a tr ee management uti l i ty.
A = nodeas c ( T, N) r eturns the i ndi ces of al l the ascendants of the node N i n the
tr ee str uctur e T. N can be the i ndex node or the depth and posi ti on of node. A i s
a col umn vector wi th A(1) = i ndex of node N.
A = node as c( T, N, ' de ppos ' ) i s a matri x that contai ns the depths and posi ti ons
of al l ascendants. A( i , 1) i s the depth of i -th ascendant and A( i , 2) i s the
posi ti on of i -th ascendant.
nodeasc
8-94
Examples % Cr e at e bi nar y t r ee of dept h 3.
t = make t r ee ( 2, 3) ;
t t = nodej oi n( t , 5) ;
t t = nodej oi n( t t , 4) ;
pl ot t r ee ( t t )
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,6) (3,7)
(0,0)
(1) (2)
(3) (4) (5) (6)
(7) (8) (13) (14)
(0)
nodeasc
8-95
% Node de s c e ndant s .
nodedes c ( t t , 2)
ans =
7
3
1
0
nodedes c ( t t , 2, ' deppos ' )
ans =
nodeas c ( t t , [ 2 2] )
ans =
5
2
0
nodeas c ( t t , [ 2 2] , ' deppos ' )
ans =
2 2
1 1
0 0
See Also maket r e e, node de s c , nodepar , wt r e e mgr
nodedesc
8-96
nodedesc
Purpose Node descendants.
Syntax D = nodedes c( T, N)
D = nodedes c( T, N, ' de ppos ' )
Description nodedes c i s a tree management uti l i ty.
D = node de s c ( T, N) returns the i ndi ces of al l the descendants of the node N i n
the tr ee structure T. N can be the i ndex node or the depth and posi ti on of node.
D i s a col umn vector wi th D( 1) = i ndex of node N.
D = nodedes c( T, N, ' de ppos ' ) i s a matri x that contai ns the depths and
posi ti ons of al l descendants. D( i , 1) i s the depth of i -th descendant and D( i , 2)
i s the posi ti on of i -th descendant.
nodedesc
8-97
Examples % Cr e at e bi nar y t r ee of dept h 3.
t = make t r ee ( 2, 3) ;
t t = nodej oi n( t , 5) ;
t t = nodej oi n( t t , 4) ;
pl ot t r e e ( t t )
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,6) (3,7)
(0,0)
(1) (2)
(3) (4) (5) (6)
(7) (8) (13) (14)
(0)
nodedesc
8-98
% Node de s ce ndant s .
nodede s c ( t t , 2)
ans =
2
5
6
13
14
nodede s c ( t t , 2, ' deppos ' )
ans =
1 1
2 2
2 3
3 6
3 7
nodede s c ( t t , [ 2 2] , ' de ppos ' )
ans =
2 2
nodede s c ( t t , [ 1 1] , ' de ppos ' )
ans =
1 1
2 2
2 3
3 6
3 7
nodede s c ( t t , [ 1 1] )
ans =
2
5
6
13
14
See Also maket r e e, node as c, node par , wt r e emgr
nodejoin
8-99
nodejoi n
Purpose Recompose node.
Syntax T = nodej oi n( T, N)
T = nodej oi n( T)
Description nodej oi n i s a tree management uti l i ty.
T = nodej oi n( T, N) returns the modi fi ed tree str uctur e T cor respondi ng to a
recomposi ti on of the node N.
The nodes are number ed from l eft to r i ght and fr om top to bottom. The r oot
i ndex i s 0.
T = nodej oi n( T) i s equi val ent to T = node j oi n( T, 0) .
Examples % Cr e at e bi nar y t r ee of dept h 3.
t = make t r ee ( 2, 3) ;
% Pl ot t r ee s t r uct ur e t .
pl ot t r e e ( t )
(1) (2)
(3) (4) (5) (6)
(7) (8) (9) (10) (11) (12) (13) (14)
(0)
nodejoin
8-100
% Mer ge node s of i ndi c e s 4 and 5.
t t = nodej oi n( t , 5) ;
t t = nodej oi n( t t , 4) ;
% Pl ot ne w t r e e s t r uct ur e t t .
pl ot t r ee ( t t )
See Also maket r e e, node s pl t , wt r ee mgr
(1) (2)
(3) (4) (5) (6)
(7) (8) (13) (14)
(0)
nodepar
8-101
nodepar
Purpose Node parent.
Syntax F = nodepar ( T, N)
F = nodepar ( T, N, ' deppos ' )
Description nodepar i s a tr ee management uti l i ty.
F = nodepar ( T, N) r etur ns the i ndi ces of the par ent(s) of the nodes N i n the
tr ee str uctur e T. N can be a col umn vector contai ni ng the i ndi ces of nodes or a
matr i x that contai ns the depths and posi ti ons of nodes. I n the l ast case, N( i , 1)
i s the depth of i -th node and N( i , 2) i s the posi ti on of i -th node.
F = node par ( T, N, ' de ppos ' ) i s a matri x that contai ns the depths and posi ti ons
of r etur ned nodes. F( i , 1) i s the depth of i -th node and F( i , 2) i s the posi ti on
of i -th node.
nodepar ( T, 0) or nodepar ( T, [ 0, 0] ) r etur ns- 1.
nodepar ( T, 0, ' de ppos ' ) or node par ( T, [ 0, 0] , ' deppos ' ) returns [ - 1, 0] .
nodepar
8-102
Examples % Cr e at e bi nar y t r ee of dept h 3.
t = make t r ee ( 2, 3) ;
t t = nodej oi n( t , 5) ;
t t = nodej oi n( t t , 4) ;
pl ot t r ee ( t t )
% Nodes par e nt .
nodepar ( t t , [ 2 2] , ' deppos ' )
ans =
1 1
nodepar ( t t , [ 1; 7; 14] )
ans =
0
3
6
See Also maket r e e, node as c, node de s c , wt r ee mgr
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,6) (3,7)
(0,0)
(1) (2)
(3) (4) (5) (6)
(7) (8) (13) (14)
(0)
nodesplt
8-103
nodespl t
Purpose Spl i t (decompose) node.
Syntax T = nodes pl t ( T, N)
Description nodes pl t i s a tree management uti l i ty.
T = nodes pl t ( T, N) r etur ns the modi fi ed tr ee structure T cor respondi ng to the
decomposi ti on of the node N.
Examples % Cr e at e bi nar y t r ee ( t r e e of or der 2) of de pt h 3.
t = make t r ee ( 2, 3) ;
% Pl ot t r ee s t r uct ur e t .
pl ot t r e e ( t )
(1) (2)
(3) (4) (5) (6)
(7) (8) (9) (10) (11) (12) (13) (14)
(0)
nodesplt
8-104
Spl i t node of i nde x 10.
t t = nodes pl t ( t , 10) ;
% Pl ot ne w t r e e s t r uct ur e t t .
pl ot t r ee ( t t )
See Also maket r e e, node j oi n, wt r ee mgr
(1) (2)
(3) (4) (5) (6)
(7) (8) (9) (10) (11) (12) (13) (14)
(21) (22)
(0)
nstdfft
8-105
nstdfft
Purpose Nonstandar d 1-D fast Four i er transform.
Syntax [ XHAT, OMEGA] = ns t df f t ( X, LOWB, UPPB)
Description ns t df f t i s a general mathemati cal uti l i ty.
[ XHAT, OMEGA] = ns t df f t ( X, LOWB, UPPB) returns a non-standar d FFT of si gnal
X sampl ed on a power of 2 r egul ar gr i d (not necessari l y i nteger s) on the i nter val
[ LOWB, UPPB] .
Output ar guments ar e XHAT, the shi fted FFT of X computed on the i nterval
OMEGA gi ven by OMEGA = [ - n: 2: n- 2] / ( 2*( UPPB - LOWB) ) , wher e n i s the
l ength of X. Outputs ar e vector s of l ength n.
Length of X must be a power of two.
Algorithm Gi ven obser vati ons between two bounds l and u: x
1
, x
2
, . . . , x
N
, whi ch
ar e regul ar l y sampl ed from a conti nuous si gnal f:
x
k
= f(l + (k - 1)) for k = 1 to N wher e = (u - 1)/N
ns t df f t computes approxi mati ons of the conti nuous Fouri er tr ansfor m
coeffi ci ents: for : : usi ng the
standar d di screte fast fouri er transform f f t .
For a gi ven frequency : can be r ewri tten
as usi ng t = sN + l .
The i ntegr al term can be appr oxi mated by the fi ni te sum:
.
N 2
q
=
f

( ) f t ( )e
2 it
t d
l
u

=
1
2
------ =
1
N
-------
1
2
------
1
N
-------
f

( ) f t ( )e
2 i t
t d
l
u

=
f

( ) Ne
2i l
f l sN + ( )e
2 it sN
s d
0
1

=
1
N
---- fl k 1 ( ) + )e
2 i k 1 ( )
k 1 =
N

nstdfft
8-106
Si nce : :
then : 1 : , whi ch ar e the usual fr equenci es of the di screte
Fouri er transform.
I t tur ns out that can be approxi mated by:
wher e
whi ch can be computed usi ng standard f f t and a nor mal i zati on. The functi on
i ns t df f t i nver ts thi s transform i n three steps: normal i zati on, use of i f f t , and
tr ansl ati on i n ti me.
The l ength of X must be a power of two.
See Also f f t , f f t s hi f t , i ns t df f t

1
2
------ =
1
N
-------
1
2
------
1
N
-------
j N
N
2
------- = =
N
2
--- - 1
f

( )
e
2 i l
x
k

k 1 ( )j
k 1 =
N


N
e
2i N
=
ntnode
8-107
ntnode
Purpose Number of termi nal nodes.
Syntax NB = nt node ( T)
Description nt node i s a tree management uti l i ty.
NB = nt node( T) r etur ns the number of termi nal nodes i n the tr ee str uctur e T.
Examples % Cr e at e bi nar y t r ee ( t r e e of or der 2) of de pt h 3.
t = make t r ee ( 2, 3) ;
% Pl ot t r ee s t r uct ur e t .
pl ot t r e e ( t )
% Numbe r of t e r mi nal node s .
nt node( t )
ans =
8
See Also maket r e e, wt r e emgr
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)
(0,0)
num2mstr
8-108
num2mstr
Purpose Conver t number to stri ng i n maxi mum preci si on.
Syntax S = num2ms t r ( N)
Description num2ms t r i s a gener al uti l i ty.
S = num2ms t r ( N) converts r eal number s of i nput matri x N to stri ng output
vector S, i n maxi mum pr eci si on.
See Also num2s t r
orthfilt
8-109
or thfi l t
Purpose Or thogonal wavel et fi l ter set.
Syntax [ Lo_D, Hi _D, Lo_R, Hi _R] = or t hf i l t ( W)
Description [ Lo_D, Hi _D, Lo_R, Hi _R] = or t hf i l t ( W) computes the four fi l ters associ ated
wi th the scal i ng fi l ter Wcorr espondi ng to a wavel et:
For an or thogonal wavel et, i n the mul ti resol uti on framewor k, we start wi th the
scal i ng functi on and the wavel et functi on . One of the fundamental r el ati ons
i s the twi n-scal e r el ati on:
Al l the fi l ters used i n DWT and I DWT are i nti matel y rel ated to the sequence
. Cl earl y i f i s compactl y suppor ted, the sequence (w
n
) i s fi ni te and
can be vi ewed as a FI R fi l ter . The scal i ng fi l ter Wi s:
A l ow-pass FI R fi l ter
Of l ength 2N
Of sum 1
Of norm
Lo_D Decomposi ti on l ow-pass fi l ter
Hi _D Decomposi ti on hi gh-pass fi l ter
Lo_R Reconstr ucti on l ow-pass fi l ter
Hi _R Reconstr ucti on hi gh-pass fi l ter
1
2
---
x
2
---


w
n
x n ( ).
n Z

=
w
n
( )
n Z
1
2
-------
orthfilt
8-110
For exampl e, for the db3 scal i ng fi l ter:
l oad db3
db3
db3 =
0. 2352 0. 5706 0. 3252 - 0. 0955 - 0. 0604 0. 0249
s um( db3)
ans =
1. 000
nor m( db3)
ans =
0. 7071
From fi l ter W, we defi ne four FI R fi l ters, of l ength 2N and nor m 1, organi zed as
fol l ows:
The four fi l ter s are computed usi ng the fol l owi ng scheme:
where qmf i s such that Hi _R and Lo_R ar e quadr atur e mi r ror fi l ter s
(i .e. Hi _R(k) = (-1)
k
Lo_R(2N - 1 - k)), and where wr ev fl i ps the fi l ter coeffi ci ents.
So Hi _D and Lo_D are al so quadratur e mi r ror fi l ters. The computati on of these
fi l ter s i s per formed usi ng or t hf i l t .
Filters Low-pass High-pass
Decomposi ti on Lo_D Hi _D
Reconstructi on Lo_R Hi _R
Lo_R =
W
nor m(W)
Hi_R =qmf(Lo_R) Hi_D = wrev(Hi_R)
W
orthfilt
8-111
Examples % Load s c al i ng f i l t e r .
l oad db8; w = db8;
s ubpl ot ( 421) ; s t em( w) ;
t i t l e ( ' Or i gi nal s c al i ng f i l t e r ' ) ;
% Comput e t he f our f i l t er s .
[ Lo_D, Hi _D, Lo_R, Hi _R] = or t hf i l t ( w) ;
s ubpl ot ( 423) ; s t em( Lo_D) ;
t i t l e ( ' Dec ompos i t i on l ow- pas s f i l t er ' ) ;
s ubpl ot ( 424) ; s t em( Hi _D) ;
t i t l e ( ' Dec ompos i t i on hi gh- pas s f i l t e r ' ) ;
s ubpl ot ( 425) ; s t em( Lo_R) ;
t i t l e ( ' Rec ons t r uct i on l ow- pas s f i l t e r ' ) ;
s ubpl ot ( 426) ; s t em( Hi _R) ;
t i t l e ( ' Rec ons t r uct i on hi gh- pas s f i l t er ' ) ;
% Che ck f or or t honor mal i t y.
df = [ Lo_D; Hi _D] ;
r f = [ Lo_R; Hi _R] ;
i d = df *df '
i d =
1. 0000 - 0. 0000
- 0. 0000 1. 0000
i d = r f *r f '
i d =
1. 0000 0. 0000
0. 0000 1. 0000
% Che ck f or or t hogonal i t y by dy adi c t r ans l at i on, f or ex ampl e :
df = [ Lo_D 0 0; Hi _D 0 0] ;
df t = [ 0 0 Lo_D; 0 0 Hi _D] ;
z er = df *df t '
z er =
1. 0e- 12 *
- 0. 1883 0. 0000
- 0. 0000 - 0. 1883
orthfilt
8-112
% Hi gh and l ow f r e quenc y i l l us t r at i on.
f f t l d = f f t ( Lo_D) ; f f t hd = f f t ( Hi _D) ;
f r e q = [ 1: l e ngt h( Lo_D) ] /l engt h( Lo_D) ;
s ubpl ot ( 427) ; pl ot ( f r eq, abs ( f f t l d) ) ;
t i t l e ( ' Tr ans f e r modul us : l ow- pas s ' )
s ubpl ot ( 428) ; pl ot ( f r eq, abs ( f f t hd) ) ;
t i t l e ( ' Tr ans f e r modul us : hi gh- pas s ' )
See Also bi or f i l t , qmf , wf i l t e r s
References I . Daubechi es (1992), Ten l ectures on wavel ets, CBMS-NSF confer ence ser i es
i n appl i ed mathemati cs. SI AM Ed. pp 117-119, 137, 152.
0 10 20
1
0
1
Original scaling filter
0 10 20
1
0
1
Decomposition lowpass filter
0 10 20
1
0
1
Decomposition highpass filter
0 10 20
1
0
1
Reconstruction lowpass filter
0 10 20
1
0
1
Reconstruction highpass filter
0.2 0.4 0.6 0.8
0
1
2
Transfer modulus: lowpass
0.2 0.4 0.6 0.8
0
1
2
Transfer modulus: highpass
plottree
8-113
pl ottree
Purpose Pl ot tree.
Syntax pl ot t r e e( T)
Description pl ot t r e e i s a graphi cal tree management uti l i ty.
pl ot t r e e( T) pl ots the tree structure T (see maket r ee ).
Examples % Cr e at e bi nar y t r ee of dept h 3.
t = make t r ee ( 2, 3) ;
% Pl ot t r ee s t r uct ur e t .
pl ot t r e e ( t )
% Cr e at es a f i gur e c ont ai ni ng t he t r ee
% and a s i mpl e menu bar al l owi ng:
% - t o c l os e t he wi ndow
% - t o c hoos e node l abe l i ng mode bet we en
% i ndex and de pt h- pos i t i on.
plottree
8-114
See Also maket r e e, wpde c, wpde c2
qmf
8-115
qmf
Purpose Quadratur e mi r ror fi l ter .
Syntax Y = qmf ( X, P)
Y = qmf ( X)
Description Y = qmf ( X, P) changes the si gns of the even i ndex entri es of the rever sed vector
fi l ter coeffi ci ents X i f P i s even. I f P i s odd the same hol ds for odd i ndex entr i es.
Y = qmf ( X) i s equi val ent to Y = qmf ( X, 0) .
Let x be a fi ni te energy si gnal . Two fi l ter s F
0
and F
1
are quadr ature mi rr or
fi l ters (QMF) i f, for any x:
where y
0
i s a deci mated versi on of the si gnal x fi l ter ed wi th F
0
so y
0
i s defi ned
by x
0
= F
0
(x) and y
0
(n) = x
0
(2n), and si mi l arl y, y
1
i s defi ned by x
1
= F
1
(x) and
y
1
(n) = x
1
(2n). Thi s property ensur es a per fect reconstr ucti on of the associ ated
two-channel fi l ter banks scheme (See Str ang-Nguyen p. 103).
For exampl e, i f F
0
i s a Daubechi es scal i ng fi l ter and F
1
= qmf (F
0
) then the
tr ansfer functi ons F
0
(z) and F
1
(z) of the fi l ter s F
0
and F
1
sati sfy the condi ti on
(see the exampl e for db10):
Examples % Load s c al i ng f i l t e r as s oc i at e d wi t h an or t hogonal wav el e t .
l oad db10;
s ubpl ot ( 321) ; s t em( db10) ; t i t l e ( ' db10 l ow- pas s f i l t er ' ) ;
% Comput e t he quadr at ur e mi r r or f i l t er .
qmf db10 = qmf ( db10) ;
s ubpl ot ( 322) ; s t em( qmf db10) ; t i t l e( ' QMF db10 f i l t er ' ) ;
% Chec k f or f r e que nc y c ondi t i on ( nec es s ar y f or or t hogonal i t y ) : %
abs ( f f t ( f i l t er ) ) ^2 + abs ( f f t ( qmf ( f i l t e r ) ) ^2 = 1 at each
% f r e quency .
m = f f t ( db10) ;
mt = f f t ( qmf db10) ;

0
2

1
2
x
2
= +
F
0
z ( )
2
F
1
z ( )
2
+ 1 =
qmf
8-116
f r e q = [ 1: l e ngt h( db10) ] /l engt h( db10) ;
s ubpl ot ( 323) ; pl ot ( f r e q, abs ( m) ) ;
t i t l e ( ' Tr ans f e r modul us of db10' )
s ubpl ot ( 324) ; pl ot ( f r e q, abs ( mt ) ) ;
t i t l e ( ' Tr ans f e r modul us of QMF db10' )
s ubpl ot ( 325) ; pl ot ( f r e q, abs ( m) . ^2 + abs ( mt ) . ^2) ;
t i t l e ( ' Che ck QMF c ondi t i on f or db10 and QMF db10' )
x l abe l ( ' abs ( f f t ( db10) ) ^2 + abs ( f f t ( qmf ( db10) ) ^2 = 1' )
% Che ck f or or t honor mal i t y.
df = [ db10; qmf db10] *s qr t ( 2) ;
i d = df *df '
i d =
1. 0000 0. 0000
0. 0000 1. 0000
References G. Str ang, T. Nguyen (1996), Wavelets and Filter Banks, Wel l esl ey-Cambri dge
Press
0 10 20
0.5
0
0.5
db10 lowpass filter
0 10 20
0.5
0
0.5
QMF db10 filter
0 0.5 1
0
0.5
1
Transfer modulus of db10
0 0.5 1
0
0.5
1
Transfer modulus of QMF db10
0.2 0.4 0.6 0.8
0
1
2
Check QMF condition for db10 and QMF db10
abs(fft(db10))^2 + abs(fft(qmf(db10))^2 = 1
symwavf
8-117
symwavf
Purpose Syml ets wavel et fi l ter s.
Syntax F = s ymwavf ( ' symname' )
Description F = s ymwavf ( 'symname') returns the scal i ng fi l ter associ ated wi th the syml et
wavel et speci fi ed by 'symname'. Possi bl e val ues for N ar e: 2, 3, 4, 5, 6, 7 or 8.
Examples % Comput e t he s c al i ng f i l t e r cor r es pondi ng t o wav el et s ym4.
w = s ymwav f ( ' s ym4' )
w =
Col umns 1 t hr ough 7
0. 0228 - 0. 0089 - 0. 0702 0. 2106 0. 5683 0. 3519 - 0. 0210
Col umn 8
- 0. 0536
See Also wav ei nf o
thselect
8-118
th sel ect
Purpose Thr eshol d sel ecti on for de-noi si ng.
Syntax THR = t hs el ec t ( X, TPTR)
Description t hs el ec t i s a one-di mensi onal de-noi si ng ori ented functi on.
THR = t hs el ec t ( X, TPTR) retur ns threshol d X-adapted val ue usi ng sel ecti on
rul e defi ned by str i ng TPTR.
Avai l abl e sel ecti on r ul es ar e:
TPTR = ' r i gr s ur e' , adapti ve threshol d sel ecti on usi ng pr i nci pl e of Stei ns
Unbi ased Ri sk Esti mate.
TPTR = ' heur s ur e' , heuri sti c vari ant of the fi rst opti on.
TPTR = ' s qt wol og' , threshol d i s sqrt(2*l og(l ength(X))).
TPTR = ' mi ni max i ' , mi ni max threshol di ng.
Thr eshol d sel ecti on r ul es ar e based on the underl yi ng model y = f(t) + e wher e
e i s a whi te noi se N(0,1). Deal i ng wi th unscal ed or nonwhi te noi se can be
handl ed usi ng rescal i ng output threshol d THR (see SCAL parameter i n wde n).
Avai l abl e opti ons are:
t pt r = ' r i gr s ur e' uses for the soft threshol d esti mator a threshol d sel ecti on
rul e based on Stei ns Unbi ased Esti mate of Ri sk (quadr ati c l oss functi on).
One gets an esti mate of the ri sk for a parti cul ar thr eshol d val ue t.
Mi ni mi zi ng the r i sks i n t gi ves a sel ecti on of the thr eshol d val ue.
t pt r = ' s qt wol og' uses a fi xed form thr eshol d yi el di ng mi ni max
per formance mul ti pl i ed by a smal l factor proporti onal to l og(l ength(s)).
t pt r = ' he ur s ur e' i s a mi xture of the two previ ous opti ons. As a resul t, i f the
si gnal to noi se r ati o i s ver y smal l , the SURE esti mate i s very noi sy. I f such a
si tuati on i s detected, the fi xed form thr eshol d i s used.
t pt r = ' mi ni max i ' uses a fi xed threshol d chosen to yi el d mi ni max
per formance for mean square er ror agai nst an i deal procedure. The mi ni max
pri nci pl e i s used i n stati sti cs i n order to desi gn esti mators. Si nce the
de-noi sed si gnal can be assi mi l ated to the esti mator of the unknown
regr essi on functi on, the mi ni max esti mator i s the one that real i zes the
thselect
8-119
mi ni mum of the maxi mum mean squar e er ror obtai ned for the wor st
functi on i n a gi ven set.
Examples % Gener at e Gaus s i an whi t e noi s e .
i ni t = 2055415866; r andn( ' s ee d' , i ni t ) ;
x = r andn( 1, 1000) ;
% Fi nd t hr e s hol d f or e ach s el ec t i on r ul e .
% adapt i ve t hr es hol d us i ng SURE.
t hr = t hs e l e ct ( x , ' r i gr s ur e' )
t hr =
1. 8065
% Fi x ed f or m t hr es hol d.
t hr = t hs e l e ct ( x , ' s qt wol og' )
t hr =
3. 7169
% Heur i s t i c var i ant of t he f i r s t opt i ons .
t hr = t hs e l e ct ( x , ' heur s ur e' )
t hr =
3. 7169
% Mi ni max t hr e s hol d.
t hr = t hs e l e ct ( x , ' mi ni max i ' )
t hr =
2. 2163
See Also wde n
References D.L. Donoho (1993), Progr ess i n wavel et anal ysi s and WVD: a ten mi nute
tour , i n Progress in wavelet analysis and applications, Y. Meyer , S. Roques,
pp. 109128. Fronti res Ed.
D.L. Donoho, I .M. Johnstone (1994), I deal spati al adaptati on by wavel et
shri nkage, Biometrika, vol 81, pp. 425455.
D.L. Donoho (1995), De-noi si ng by soft-threshol di ng, I EEE Trans. on I nf.
Theory, 41, 3, pp. 613627.
tnodes
8-120
tn odes
Purpose Termi nal nodes.
Syntax N = t node s ( T)
N = t node s ( T, ' de ppos ' )
[ N, K] = t node s ( T)
[ N, K] = t node s ( T, ' de ppos ' )
Description t node s i s a tree management uti l i ty.
N = t node s ( T) returns the i ndi ces of ter mi nal nodes of the tree structur e T
(see make t r ee ). N i s a col umn vector .
The nodes are number ed fr om l eft to r i ght and fr om top to bottom. The r oot
i ndex i s 0.
N = t node s ( T, ' de ppos ' ) retur ns a matr i x N whi ch contai ns the depths and
posi ti ons of termi nal nodes.
N( i , 1) i s the depth of i -th termi nal node. N( i , 2) i s the posi ti on of i -th
termi nal node.
For [ N, K] = t node s ( T) or [ N, K] = t nodes ( T, ' deppos ' ) , M = N( K) are the
i ndi ces reorder ed i n tr ee T, fr om l eft to ri ght.
Examples % Cr e at e i ni t i al t r e e.
or d = 2; t = maket r ee ( or d, 3) ; % Bi nar y t r ee of de pt h 3.
t t = nodej oi n( t , 5) ;
t t = nodej oi n( t t , 4) ;
pl ot t r ee ( t t )
tnodes
8-121
% Li s t t e r mi nal node s ( i nde x) .
t node s ( t t )
ans =
4
5
7
8
13
14
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,6) (3,7)
(0,0)
(1) (2)
(3) (4) (5) (6)
(7) (8) (13) (14)
(0)
tnodes
8-122
% Li s t t e r mi nal node s ( de pt h- pos i t i on) .
t node s ( t t , ' deppos ' )
ans =
2 1
2 2
3 0
3 1
3 6
3 7
See Also maket r e e, wt r e emgr
treedpth
8-123
tr eedpth
Purpose Tree depth.
Syntax D = t r e edpt h( T)
Description t r e edpt h i s a tree management uti l i ty.
D = t r e edpt h( T) returns the depth D of the tree T.
Examples % Cr e at e bi nar y t r ee ( t r e e of or der 2) of de pt h 3.
t = make t r ee ( 2, 3) ;
% Pl ot t r ee s t r uct ur e t .
pl ot t r e e ( t )
% Tr e e de pt h.
t r e edpt h( t )
ans =
3
See Also maket r e e, wt r e emgr
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)
(0,0)
treeord
8-124
tr eeord
Purpose Tree or der .
Syntax ORD = t r e eor d( T)
Description t r e eor d i s a tr ee management uti l i ty.
ORD = t r e eor d( T) r etur ns the order ORD of the tree T.
Examples % Cr e at e bi nar y t r ee ( t r e e of or de r 2) of de pt h 3.
t = make t r ee ( 2, 3) ;
% Pl ot t r e e s t r uct ur e t .
pl ot t r ee ( t )
% Tr e e or der .
t r e eor d( t )
ans =
2
See Also maket r e e, wt r e emgr
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)
(0,0)
upcoef
8-125
upcoef
Purpose Di r ect reconstructi on from 1-D wavel et coeffi ci ents.
Syntax Y = upc oe f ( O, X, ' wname' , N)
Y = upc oe f ( O, X, ' wname' , N, L)
Y = upc oe f ( O, X, Lo_R, Hi _R, N)
Y = upc oe f ( O, X, Lo_R, Hi _R, N, L)
Y = upc oe f ( O, X, ' wname' )
Y = upc oe f ( O, X, Lo_R, Hi _R)
Description upc oe f i s a one-di mensi onal wavel et anal ysi s functi on.
Y = upcoef ( O, X, 'wname', N) computes the N steps r econstr ucted coeffi ci ents of
vector X.
'wname' i s a stri ng contai ni ng the wavel et name.
N must be a str i ctl y posi ti ve i nteger.
I f O = ' a' , approxi mati on coeffi ci ents ar e r econstructed.
I f O = ' d' , detai l coeffi ci ents are reconstr ucted.
Y = upcoef ( O, X, 'wname', N, L) computes the N steps r econstructed coeffi ci ents
of vector X and takes the l ength-L centr al por ti on of the resul t. I nstead of gi vi ng
the wavel et name, you can gi ve the fi l ter s.
For Y = upcoe f ( O, X, Lo_R, Hi _R, N) or Y = upc oe f ( O, X, Lo_R, Hi _R, N, L) , Lo_R
i s the reconstr ucti on l ow-pass fi l ter and Hi _R i s the reconstr ucti on hi gh-pass
fi l ter.
Y = upc oe f ( O, X, 'wname') i s equi val ent to Y = upc oe f ( O, X, 'wname', 1) .
Y = upc oe f ( O, X, Lo_R, Hi _R) i s equi val ent to Y = upcoe f ( O, X, Lo_R, Hi _R, 1) .
Examples % Appr oxi mat i on s i gnal s , obt ai ned f r om a s i ngl e c oe f f i c i e nt
% at l e ve l s 1 t o 6.
c f s = [ 1] ; % De compos i t i on r educ ed a s i ngl e c oef f i ci ent .
e s s up = 10; % Es s e nt i al s uppor t of t he s cal i ng f i l t er db6.
f i gur e( 1)
f or i =1: 6
upcoef
8-126
% Rec ons t r uc t at t he t op l e ve l an appr ox i mat i on
% whi c h i s e qual t o z er o ex ce pt at l ev el i wher e onl y
% one coef f i ci ent i s equal t o 1.
r ec = upcoef ( ' a' , c f s , ' db6' , i ) ;
% e s s up i s t he e s s e nt i al s uppor t of t he
% r ec ons t r uc t e d s i gnal .
s ubpl ot ( 6, 1, i ) , h = pl ot ( r ec ( 1: es s up) ) ;
s et ( ge t ( h, ' par ent ' ) , ' xl i m' , [ 1 325] ) ;
e s s up = es s up*2;
e nd
s ubpl ot ( 611)
t i t l e ( [ ' Appr ox i mat i on s i gnal s , obt ai ne d f r om a s i ngl e ' . . .
' c oe f f i ci ent at l e ve l s 1 t o 6' ] )
% The s ame c an be done f or de t ai l s .
% Det ai l s s i gnal s , obt ai ned f r om a s i ngl e coe f f i c i e nt
% at l e ve l s 1 t o 6.
c f s = [ 1] ;
mi = 12; ma = 30; % Es s ent i al s uppor t of
% t he wav el et f i l t er db6.
50 100 150 200 250 300
1
0
1
Approximation signals, obtained from a single coefficient at levels 1 to 6
50 100 150 200 250 300
1
0
1
50 100 150 200 250 300
0.5
0
0.5
50 100 150 200 250 300
0.5
0
0.5
50 100 150 200 250 300
0.2
0
0.2
50 100 150 200 250 300
0.2
0
0.2
upcoef
8-127
r ec = upc oe f ( ' d' , c f s , ' db6' , 1) ;
f i gur e( 2)
s ubpl ot ( 611) , pl ot ( r ec ( 3: 12) )
f or i =2: 6
% Rec ons t r uc t at t op l e ve l a s i ngl e de t ai l
% c oe f f i ci ent at l e ve l i .
r ec = upcoef ( ' d' , c f s , ' db6' , i ) ;
s ubpl ot ( 6, 1, i ) , pl ot ( r e c( mi *2^( i - 2) : ma*2^( i - 2) ) )
e nd
s ubpl ot ( 611)
t i t l e ( [ ' Det ai l s i gnal s obt ai ned f r om a s i ngl e ' . . .
' coef f i c i e nt at l e v el s 1 t o 6' ] )
Algorithm upc oe f i s equi val ent to the N ti mes repeated use of the i nverse wavel et
tr ansfor m.
See Also i dwt
1 2 3 4 5 6 7 8 9
1
0
1
Detail signals obtained from a single coefficient at levels 1 to 6
2 4 6 8 10 12 14 16 18
1
0
1
5 10 15 20 25 30 35
0.5
0
0.5
10 20 30 40 50 60 70
0.5
0
0.5
20 40 60 80 100 120 140
0.2
0
0.2
50 100 150 200 250
0.2
0
0.2
upcoef2
8-128
upcoef2
Purpose Di r ect r econstructi on fr om 2-D wavel et coeffi ci ents.
Syntax Y = upc oe f 2( O, X, ' wname' , N, S)
Y = upc oe f 2( O, X, Lo_R, Hi _R, N, S)
Y = upc oe f 2( O, X, ' wname' , N)
Y = upc oe f 2( O, X, Lo_R, Hi _R, N)
Y = upc oe f 2( O, X, ' wname' )
Y = upc oe f 2( O, X, Lo_R, Hi _R)
Description upc oe f 2 i s a two-di mensi onal wavel et anal ysi s functi on.
Y = upcoe f 2( O, X, 'wname', N, S) computes the N steps r econstructed coeffi ci ents
of matri x X and takes the centr al part of si ze S. 'wname' i s a str i ng contai ni ng the
name of the wavel et.
I f O = 'a', approxi mati on coeffi ci ents are reconstr ucted; other wi se i f O = ' h'
(' v ' or ' d' r especti vel y), hor i zontal (ver ti cal or di agonal respecti vel y) detai l
coeffi ci ents ar e reconstr ucted. N must be a str i ctl y posi ti ve i nteger.
I nstead of gi vi ng the wavel et name, you can gi ve the fi l ter s.
For Y = upcoe f 2( O, X, Lo_R, Hi _R, N, S) , Lo_R i s the reconstr ucti on l ow-pass
fi l ter and Hi _R i s the r econstructi on hi gh-pass fi l ter.
Y = upc oe f 2( O, X, 'wname', N) or Y = upc oe f 2( O, X, Lo_R, Hi _R, N) return the
computed r esul t wi thout any tr uncati on.
Y = upc oe f 2( O, X, 'wname') i s equi val ent to Y = upcoef 2( O, X, 'wname', 1) .
Y = upc oe f 2( O, X, Lo_R, Hi _R) i s equi val ent to
Y = upc oe f 2( O, X, Lo_R, Hi _R, 1) .
upcoef2
8-129
Examples % Load or i gi nal i mage.
l oad woman;
% X c ont ai ns t he l oaded i mage .
% Per f or m de compos i t i on at l e ve l 2
% of X us i ng db4.
[ c, s ] = wave de c2( X, 2, ' db4' ) ;
% Rec ons t r uc t appr ox i mat i on and det ai l s
% at l e ve l 1, f r om c oe f f i ci ent s .
% Thi s can be done us i ng wr coef 2, or
% e qui v al ent l y us i ng:
%
% St e p 1: Ex t r ac t coef f i c i e nt s f r om t he
% dec ompos i t i on s t r uct ur e [ c, s ] .
%
% St e p 2: Re cons t r uc t us i ng upc oe f 2.
s i z = s ( s i z e ( s , 1) , : ) ;
c a1 = appc oe f 2( c , s , ' db4' , 1) ;
a1 = upc oe f 2( ' a' , c a1, ' db4' , 1, s i z ) ;
c hd1 = det coef 2( ' h' , c , s , 1) ;
hd1 = upcoef 2( ' h' , c hd1, ' db4' , 1, s i z ) ;
c vd1 = det coef 2( ' v ' , c , s , 1) ;
v d1 = upcoef 2( ' v ' , c vd1, ' db4' , 1, s i z ) ;
c dd1 = det coef 2( ' d' , c , s , 1) ;
dd1 = upcoef 2( ' d' , c dd1, ' db4' , 1, s i z ) ;
Algorithm See upc oef .
See Also i dwt 2
upwlev
8-130
upwl ev
Purpose Si ngl e-l evel reconstr ucti on of 1-D wavel et decomposi ti on.
Syntax [ NC, NL, cA] = upwl e v( C, L, ' wname' )
[ NC, NL, cA] = upwl e v( C, L, Lo_R, Hi _R)
Description upwl e v i s a one-di mensi onal wavel et anal ysi s functi on.
[ NC, NL, cA] = upwl ev ( C, L, 'wname') performs the si ngl e-l evel reconstructi on of
the wavel et decomposi ti on str uctur e [ C, L] gi vi ng the new one [ NC, NL] , and
extr acts the l ast approxi mati on coeffi ci ents vector cA.
[ C, L] i s a decomposi ti on at l evel n = l engt h( L) - 2, so [ NC, NL] i s the same
decomposi ti on at l evel n-1 and c A i s the approxi mati on coeffi ci ents vector at
l evel n.
'wname' i s a stri ng contai ni ng the wavel et name, C i s the ori gi nal wavel et
decomposi ti on vector , and L the corr espondi ng bookkeepi ng vector (for detai l ed
stor age i nformati on, see wave dec ).
I nstead of gi vi ng the wavel et name, you can gi ve the fi l ter s.
For [ NC, NL, c A] = upwl ev ( C, L, Lo_R, Hi _R) , Lo_R i s the r econstructi on
l ow-pass fi l ter and Hi _R i s the r econstructi on hi gh-pass fi l ter .
Examples % Load or i gi nal one- di mens i onal s i gnal .
l oad s ums i n; s = s ums i n;
% Per f or m de compos i t i on at l e ve l 3 of s us i ng db1.
[ c, l ] = wave de c( s , 3, ' db1' ) ;
s ubpl ot ( 311) ; pl ot ( s ) ;
t i t l e ( ' Or i gi nal s i gnal s . ' ) ;
s ubpl ot ( 312) ; pl ot ( c) ;
t i t l e ( ' Wav el et dec ompos i t i on s t r uc t ur e , l ev el 3' )
x l abe l ( [ ' Coe f s f or appr ox . at l e ve l 3 ' . . .
' and f or det . at l e ve l s 3, 2 and 1' ] )
upwlev
8-131
% One s t e p r ec ons t r uct i on of t he wav el et dec ompos i t i on
% s t r uc t ur e at l ev el 3 [ c , l ] , s o t he new s t r uc t ur e [ nc, nl ]
% i s t he wav el et dec ompos i t i on s t r uc t ur e at l e v el 2.
[ nc , nl ] = upwl ev ( c , l , ' db1' ) ;
s ubpl ot ( 313) ; pl ot ( nc ) ;
t i t l e ( ' Wav el et dec ompos i t i on s t r uc t ur e , l e v el 2' )
x l abe l ( [ ' Coe f s f or appr ox . at l e ve l 2 ' . . .
' and f or det . at l e ve l s 2 and 1' ] )
See Also i dwt , upc oe f , wave de c
0 200 400 600 800 1000
5
0
5
Original signal s.
0 200 400 600 800 1000
10
0
10
Wavelet decomposition structure, level 3
Coefs for approx. at level 3 and for det. at levels 3, 2 and 1
0 200 400 600 800 1000
5
0
5
Wavelet decomposition structure, level 2
Coefs for approx. at level 2 and for det. at levels 2 and 1
upwlev2
8-132
upwl ev2
Purpose Si ngl e-l evel reconstr ucti on of 2-D wavel et decomposi ti on.
Syntax [ NC, NS, cA] = upwl e v2( C, S, ' wname' )
[ NC, NS, cA] = upwl e v2( C, S, Lo_R, Hi _R)
Description upwl e v2 i s a two-di mensi onal wavel et anal ysi s functi on.
[ NC, NS, cA] = upwl ev 2( C, S, 'wname') performs the si ngl e-l evel r econstructi on
of wavel et decomposi ti on structure [ C, S] gi vi ng the new one [ NC, NS] , and
extr acts the l ast approxi mati on coeffi ci ents matr i x cA.
[ C, S] i s a decomposi ti on at l evel n = s i z e( S, 1) - 2, so [ NC, NS] i s the same
decomposi ti on at l evel n-1 and c A i s the approxi mati on matr i x at l evel n.
'wname' i s a stri ng contai ni ng the wavel et name, C i s the ori gi nal wavel et
decomposi ti on vector , and S the cor respondi ng bookkeepi ng matri x (for
detai l ed storage i nformati on, see wave de c2).
For [ NC, NS, c A] = upwl ev 2( C, S, Lo_R, Hi _R) , Lo_R i s the reconstr ucti on
l ow-pass fi l ter and Hi _R i s the r econstructi on hi gh-pass fi l ter .
upwlev2
8-133
Examples % Load or i gi nal i mage.
l oad woman;
% X c ont ai ns t he l oaded i mage .
% Per f or m de compos i t i on at l e ve l 2
% of X us i ng db1.
[ c, s ] = wave de c2( X, 2, ' db1' ) ;
s c = s i z e( c)
s c =
1 65536
v al _s = s
v al _s =
64 64
64 64
128 128
256 256
% One s t e p r ec ons t r uct i on of wave l e t
% dec ompos i t i on s t r uct ur e [ c, s ] .
[ nc , ns ] = upwl ev 2( c , s , ' db1' ) ;
s nc = s i z e ( nc)
s nc =
1 65536
v al _ns = ns
v al _ns =
128 128
128 128
256 256
See Also i dwt 2, upcoef 2, wave de c 2
wavedec
8-134
wavedec
Purpose Mul ti -l evel 1-D wavel et decomposi ti on.
Syntax [ C, L] = wav ede c( X, N, ' wname' )
[ C, L] = wav ede c( X, N, Lo_D, Hi _D)
Description wav edec performs a mul ti -l evel one-di mensi onal wavel et anal ysi s usi ng ei ther
a speci fi c wavel et ('wname', see wf i l t e r s ) or speci fi c wavel et decomposi ti on
fi l ter s (Lo_D and Hi _D).
[ C, L] = wav edec ( X, N, 'wname') returns the wavel et decomposi ti on of the si gnal
X at l evel N, usi ng 'wname'. N must be a str i ctl y posi ti ve i nteger (see wmaxl ev ).
The output decomposi ti on str uctur e contai ns the wavel et decomposi ti on vector
C and bookkeepi ng vector L. The structur e i s organi zed as i n thi s l evel -3
decomposi ti on exampl e:
[ C, L] = wav ede c( X, N, Lo_D, Hi _D) returns the decomposi ti on structure as
above, gi ven the l ow- and hi gh-pass decomposi ti on fi l ters you speci fy.
X
cA
1
cD
1
cA
2 cD
2
cA
3
cD
3
C:
L:
Dec ompos i t i on:
cD
1
cD
2
cA
3
cD
3
cA
3
length of
cD
3
length of
cD
2
length of length of
X
length
of
cD
1
wavedec
8-135
Examples % Load or i gi nal one- di mens i onal s i gnal .
l oad s ums i n; s = s ums i n;
% Per f or m de compos i t i on at l e ve l 3 of s us i ng db1.
[ c, l ] = wave de c( s , 3, ' db1' ) ;
Algorithm Gi ven a si gnal s of l ength N, the DWT consi sts of l og
2
N stages at most. The fi r st
step produces, starti ng from s, two sets of coeffi ci ents: approxi mati on
coeffi ci ents CA
1
and detai l coeffi ci ents CD
1
. These vectors ar e obtai ned by
convol vi ng s wi th the l ow-pass fi l ter Lo_D for approxi mati on, and wi th the
hi gh-pass fi l ter Hi _D for detai l , fol l owed by dyadi c deci mati on (downsampl i ng).
100 200 300 400 500 600 700 800 900
2
1
0
1
2
Original signal s.
100 200 300 400 500 600 700 800 900
4
2
0
2
4
Wavelet decomposition structure
Coefs for approx. at level 3 and for det. at levels 3, 2 and 1
wavedec
8-136
Mor e preci sel y, the fi rst step i s:
The l ength of each fi l ter i s equal to 2N. I f n = l ength(s), the si gnal s F and G
ar e of l ength n + 2N - 1 and the coeffi ci ents cA
1
and cD
1
ar e of l ength
.
The next step spl i ts the appr oxi mati on coeffi ci ents cA
1
i n two parts usi ng the
same scheme, repl aci ng s by cA
1
, and produci ng cA
2
and cD
2
, and so on.
s
Lo_D
Hi_D
high-pass
F
G
downsample
downsample approximation coefs
cA
1
cD
1
2
detail coefs
low-pass
2
where:
2
X Convolve with filter X
Keep the even indexed elements
(We call this operation downsampling.)
floor
n 1
2
----------- -


N +
One-Dimensional DWT
Decomposition step
Lo_D
Hi_D
cA
j
2
Initialization
Convolve with filter X
Downsample
cA
0
= s
where:
2
2
X
cA
j+1
cD
j+1
level j+1
level j
wavedec
8-137
The wavel et decomposi ti on of the si gnal s anal yzed at l evel j has the fol l owi ng
str uctur e: [cA
j
, cD
j
, ..., cD
1
].
Thi s structure contai ns, for J = 3, the termi nal nodes of the fol l owi ng tree:
See Also dwt , wave i nf o, wf i l t er s , wmax l e v
References I . Daubechi es (1992), Ten l ectures on wavel ets, CBMS-NSF confer ence ser i es
i n appl i ed mathemati cs. SI AM Ed.
S. Mal l at (1989), A theory for mul ti resol uti on si gnal decomposi ti on: the
wavel et r epresentati on, I EEE Pattern Anal. and Machine I ntell., vol . 11, no.
7, pp 674693.
Y. Meyer (1990), Ondel ettes et oprateurs, Tome 1, Hermann Ed. (Engl i sh
tr ansl ati on: Wavel ets and oper ators, Cambr i dge Uni v. Pr ess. 1993.)
s
cD
1
cD
2
cD
3 cA
3
wavedec2
8-138
wavedec2
Purpose Mul ti -l evel 2-D wavel et decomposi ti on.
Syntax [ C, S] = wav ede c2( X, N, ' wname' )
[ C, S] = wav ede c2( X, N, Lo_D, Hi _D)
Description wav edec 2 i s a two-di mensi onal wavel et anal ysi s functi on.
[ C, S] = wav ede c2( X, N, 'wname') retur ns the wavel et decomposi ti on of the
matr i x X at l evel N, usi ng the wavel et named i n stri ng 'wname' (see wf i l t e r s ).
Outputs are the decomposi ti on vector C and the cor respondi ng bookkeepi ng
matr i x S.
N must be a str i ctl y posi ti ve i nteger (see wmaxl ev ).
I nstead of gi vi ng the wavel et name, you can gi ve the fi l ter s.
For [ C, S] = wav edec 2( X, N, Lo_D, Hi _D) , Lo_D i s the decomposi ti on l ow-pass
fi l ter and Hi _D i s the decomposi ti on hi gh-pass fi l ter. The output wavel et
two-di mensi onal decomposi ti on structure [ C, S] contai ns the wavel et
decomposi ti on vector C and the corr espondi ng bookkeepi ng matri x S.
Vector C i s or gani zed as:
C = [ A( N) | H( N) | V( N) | D( N) | . . .
H( N- 1) | V( N- 1) | D( N- 1) | . . . | H( 1) | V( 1) | D( 1) ] .
where A, H, V, D, ar e r ow vector s such that:
A = approxi mati on coeffi ci ents
H = hor i zontal detai l coeffi ci ents
V = ver ti cal detai l coeffi ci ents
D = di agonal detai l coeffi ci ents
each vector i s the vector col umnwi se storage of a matri x.
Matri x S i s such that:
S( 1, : ) = si ze of approxi mati on coeffi ci ents(N)
S( i , : ) = si ze of detai l coeffi ci ents(N- i +2) for i = 2, ...N+1 and
S( N+2, : ) = s i z e( X) .
wavedec2
8-139
Examples % Load or i gi nal i mage.
l oad woman;
% X c ont ai ns t he l oaded i mage .
% Per f or m de compos i t i on at l e ve l 2
% of X us i ng db1.
[ c, s ] = wave de c2( X, 2, ' db1' ) ;
% Dec ompos i t i on s t r uct ur e or gani z at i on.
s i z ex = s i z e ( X)
s i z ex =
256 256
s i z ec = s i z e ( c )
s i z ec =
1 65536
v al _s = s
v al _s =
64 64
64 64
128 128
256 256
cA
n
coef s ( 3n+1 s ec t i ons )
cH
n
cV
n
cD
n
cH
n1
cV
n1
cD
n1
cH
1
cV
1
cD
1
. . .
32 32
.
.
.
32 32
256 256
s i z es ( n+2- by- 2)
512 512 X
wavedec2
8-140
Algorithm For i mages, an al gor i thm si mi l ar to the one-di mensi onal case i s possi bl e for
two-di mensi onal wavel ets and scal i ng functi ons obtai ned fr om
one-di mensi onal ones by tensor pr oduct.
Thi s ki nd of two-di mensi onal DWT l eads to a decomposi ti on of appr oxi mati on
coeffi ci ents at l evel j i n four components: the approxi mati on at l evel j+1 and the
detai l s i n three or i entati ons (hor i zontal , verti cal , and di agonal ).
The fol l owi ng char t descr i bes the basi c decomposi ti on step for i mages:
Two-Dimensional DWT
Decomposition step
rows
Lo_D
Hi_D
rows
cA
j
2 1
columns
Initialization
Downsample columns: keep the even indexed columns
Downsample rows: keep the even indexed rows
Convolve with filter X the rows of the entry
Convolve with filter X the columns of the entry
cA
0
= s for the decomposition initialization
where
2 1
2 1
2 1
2 1
2 1
2 1
2 1
X
columns
Hi_D
Lo_D
X
columns
columns
Hi_D
Lo_D
cA
j+1
cD
j+1
cD
j+1
cD
j+1
(h)
(v)
(d)
horizontal
vertical
diagonal
rows
columns
wavedec2
8-141
So, for J =2, the two-di mensi onal wavel et tree has the form:
See Also dwt 2, wav ei nf o, wf i l t e r s , wmaxl ev
References I . Daubechi es (1992), Ten l ectures on wavel ets, CBMS-NSF confer ence ser i es
i n appl i ed mathemati cs. SI AM Ed.
S. Mal l at (1989), A theory for mul ti resol uti on si gnal decomposi ti on: the
wavel et r epresentati on, I EEE Pattern Anal. and Machine I ntell., vol . 11, no.
7, pp 674693.
Y. Meyer (1990), Ondel ettes et opr ateur s, Tome 1, Her mann Ed. (Engl i sh
tr ansl ati on: Wavel ets and oper ators, Cambr i dge Uni v. Pr ess. 1993.)
cD
h
1
cD
d
1
cD
v
1
cA
2
cD
h
2
cD
d
2
cD
v
2
s
wavedemo
8-142
wavedemo
Purpose Wavel et tool box demos.
Syntax wav edemo
Description wav edemo br i ngs up a GUI that al l ows you to choose between several Wavel et
Tool box demos.
wavefun
8-143
wavefun
Purpose Wavel et and scal i ng functi ons.
Syntax [ phi , ps i , XVAL] = wav ef un( ' wname' , i t er )
[ phi 1, ps i 1, phi 2, ps i 2, XVAL] = wave f un( ' wname' , i t e r )
[ ps i , XVAL] = wav ef un( ' wname' , i t er )
wav ef un ( ' wname' , a, b)
Description The functi on wav ef un r etur ns appr oxi mati ons of the wavel et functi on ' wname'
and the associ ated scal i ng functi on, i f i t exi sts. Posi ti ve i nteger i t e r
determi nes the number of i terati ons computed, and thus the r efi nement of the
approxi mati ons.
For an orthogonal wavelet:
[ phi , ps i , XVAL] = wav ef un( ' wname' , i t er ) r etur ns the scal i ng and wavel et
functi ons on the 2
iter
poi nts gr i d XVAL.
For a biorthogonal wavelet:
[ phi 1, ps i 1, phi 2, ps i 2, XVAL] = wav ef un( ' wname' , i t e r ) r etur ns the scal i ng
and wavel et functi ons both for decomposi ti on ( phi 1, ps i 1) and for
reconstr ucti on ( phi 2, ps i 2) .
For a Meyer wavelet:
[ phi , ps i , XVAL] = wav ef un( ' wname' , i t er )
For a Morlet or Mexican Hat wavelet:
[ ps i , XVAL] = wav ef un( ' wname' , i t er )
wav ef un( ' wname' , a, b) , where a and b are posi ti ve i ntegers, i s equi val ent to
wav ef un( ' wname' , max( a, b) ) , and draws pl ots of the wavel et and scal e
approxi mati ons.
When a i s set equal to the speci al val ue 0,
wav ef un( ' wname' , 0) i s equi val ent to wav ef un( ' wname' , 8, b) .
wav ef un( ' wname' ) i s equi val ent to wav ef un( ' wname' , 8) .
wavefun
8-144
Examples On the fol l owi ng graph, 10 pi ecewi se l i near approxi mati ons of the s ym4 wavel et
obtai ned after each i terati on of the cascade al gor i thm ar e shown.
% Set number of i t er at i ons and wav el et name.
i t e r = 10;
wav = ' s ym4' ;
% Comput e appr ox i mat i ons of t he wave l e t f unc t i on us i ng t he
% c as cade al gor i t hm.
f or i = 1: i t er
[ phi , ps i , x val ] = wave f un( wav , i ) ;
pl ot ( x val , ps i ) ;
hol d on
e nd
t i t l e ( [ ' Appr ox i mat i ons of t he wave l e t ' , wav , . . .
' f or 1 t o ' , num2s t r ( i t er ) , ' i t e r at i ons ' ] ) ;
hol d of f
Algorithm For compactl y suppor ted wavel ets defi ned by fi l ters, i n gener al no cl osed form
anal yti c for mul a exi sts.
The al gor i thm used i s the cascade al gor i thm. I t uses the si ngl e-l evel i nver se
wavel et transform repeatedl y.
0 1 2 3 4 5 6 7
1.5
1
0.5
0
0.5
1
1.5
2
Approximations of the wavelet sym4 for 1 to 10 iterations
wavefun
8-145
Let us begi n wi th the scal i ng functi on .
Si nce i s al so equal to , (accordi ng to the notati on used i n Chapter 6), thi s
functi on i s char acteri zed by the fol l owi ng coeffi ci ents i n the or thogonal
framewor k:
<, > = 1 onl y i f n = 0 and equal to 0 other wi se
<, > = 0 for posi ti ve j, and al l k.
Thi s expansi on can be vi ewed as a wavel et decomposi ti on str uctur e. Detai l
coeffi ci ents ar e al l zer os and approxi mati on coeffi ci ents ar e al l zer os except one
equal to 1.
Then we use the r econstructi on al gor i thm i n or der to appr oxi mate the functi on
over a dyadi c gr i d, accordi ng to the fol l owi ng r esul t:
For any dyadi c rati onal of the for m x = n2
-j
i n whi ch the functi on i s conti nuous
and where j i s suffi ci entl y l arge, we have poi ntwi se conver gence and:
where C i s a constant, and i s a posi ti ve constant dependi ng on the wavel et
regul ar i ty.
Then usi ng a good approxi mati on of on dyadi c r ati onal s, we can use pi ecewi se
constant or pi ecewi se l i near i nter pol ati ons on dyadi c i nterval s, for whi ch
uni form convergence occurs wi th si mi l ar exponenti al rate:
So usi ng a J-steps reconstr ucti on scheme, we obtai n an approxi mati on that
converges exponenti al l y towar ds when J goes to i nfi ni ty.
Approxi mati ons ar e computed over a gri d of dyadi c r ati onal s cover i ng the
suppor t of the functi on to be appr oxi mated.

0 0 ,

0 n ,

j k ,

x ( ) 2
j
2
---
,
j n2
j J
,
C.2
j

C.2
j

wavefun
8-146
Si nce a scal ed versi on of the wavel et functi on can al so be expanded on the
, the same scheme can be used, after a si ngl e-l evel reconstr ucti on
starti ng wi th the appropri ate wavel et decomposi ti on str ucture. Approxi mati on
coeffi ci ents ar e al l zeros and detai l coeffi ci ents are al l zeros except one equal
to 1.
For bi orthogonal wavel ets, the same i deas can be appl i ed on each of the two
mul ti resol uti on schemes i n dual i ty.
Note: Thi s al gor i thm may di verge i f the functi on to be appr oxi mated i s not
conti nuous on dyadi c r ati onal s.
See Also i nt wave , wav ei nf o, wf i l t e r s
References I . Daubechi es, Ten l ectur es on wavel ets, CBMS, SI AM, 1992, p. 202-213.
G. Str ang, T. Nguyen (1996), Wavelets and Filter Banks, Wel l esl ey-Cambri dge
Press.

1 n ,
( )
n
waveinfo
8-147
wavei nfo
Purpose I nformati on on wavel ets.
Syntax wav ei nf o
wav ei nf o( ' wname' )
Description wav ei nf o gi ves i nformati on on al l wavel ets.
wav ei nf o( 'wname') gi ves i nformati on on the wavel et fami l y whose short name
i s speci fi ed by the str i ng 'wname'. Avai l abl e fami l y short names are:
or user -defi ned short names for thei r own wavel et fami l i es (see wave mngr ).
wav ei nf o( ' ws y s ' ) gi ves i nformati on on wavel et packets.
' haar ' : Haar wavel et.
' db' : Daubechi es wavel ets.
' s y m' : Syml ets.
' c oi f ' : Coi fl ets.
' bi or ' : Bi orthogonal wavel ets.
' me yr ' : Meyer wavel et.
' me xh' : Mexi can hat wavel et.
' mor l ' : Morl et wavel et.
waveinfo
8-148
Examples wav ei nf o( ' db' )
DBI NFO I nf or mat i on on Daube chi e s wav el et s .
Daube chi e s Wav el et s
Gener al c har ac t e r i s t i c s : Compac t l y s uppor t ed
wav el et s wi t h ex t r emal phas e and hi ghe s t
numbe r of vani s hi ng moment s f or a gi ve n
s uppor t wi dt h. As s oc i at ed s cal i ng f i l t er s ar e
mi ni mum- phas e f i l t er s .
Fami l y Daubec hi e s
Shor t name db
Or der N N s t r i c t l y pos i t i v e i nt e ge r
Exampl e s db1 or haar , db4, db15
Or t hogonal ye s
Bi or t hogonal ye s
Compact s uppor t ye s
DWT pos s i bl e
CWT pos s i bl e
Suppor t wi dt h 2N- 1
Fi l t e r s l e ngt h 2N
Regul ar i t y about 0. 2 N f or l ar ge N
Symme t r y f ar f r om
Numbe r of vani s hi ng moment s f or ps i N
Ref er ence : I . Daubec hi e s ,
Ten l ec t ur es on wave l e t s CBMS, SI AM, 61, 1994, 194- 202.
See Also wav emngr
wavemenu
8-149
wavemenu
Purpose Star t gr aphi cal user i nterface tool s.
Syntax wav emenu
Description wav emenu bri ngs up a menu for accessi ng the vari ous graphi cal tool s provi ded
i n the Wavel et Tool box. For i nstructi ons on usi ng these tool s see:
Examples wav emenu
Continuous Wavelet 1-D Chapter 2
Wavelet 1-D and Wavelet 2-D Chapter 2
Wavelet Packet 1-D and Wavelet Packet 2-D Chapter 5
Wavelet Display and Wavelet Packet Display Chapter 1
wavemngr
8-150
wavemngr
Purpose Wavel et manager .
Syntax wav emngr ( ' c r e at e ' )
wav emngr ( ' add' , FN, FSN, WT, NUMS, FI LE)
wav emngr ( ' add' , FN, FSN, WT, NUMS, FI LE, B)
wav emngr ( ' del ' , N)
wav emngr ( ' r es t or e' )
wav emngr ( ' r es t or e' , I N2)
OUT1 = wave mngr ( ' r ead' )
OUT1 = wave mngr ( ' r ead' , I N2)
OUT1 = wave mngr ( ' r ead_as c ' )
Description wav emngr i s a type of wavel ets manager . I t al l ows you to create, add, del ete,
restore, or read wavel ets.
wav emngr ( ' c r e at e ' ) creates the wav el et s . i nf MAT-fi l e usi ng the
wav el et s . as c ASCI I -fi l e.
wav emngr ( ' add' , FN, FSN, WT, NUMS, FI LE) or
wav emngr ( ' add' , FN, FSN, WT, NUMS, FI LE, B) , adds a new wavel et fami l y to the
tool box.
FN = Fami l y Name (str i ng)
FSN = Fami l y Short Name (stri ng of l ength l ess than four char acter s)
WT = Wavel et type
WT = 1, orthogonal wavel ets
WT = 2, bi orthogonal wavel ets
WT = 3, wavel et wi th scal i ng functi on
WT = 4, wavel et wi thout scal i ng functi on
NUMS = Stri ng of number s
FI LE = MAT-fi l e or M-fi l e name (stri ng). See the exampl e for usage.
B = [l b ub] l ower and upper bounds of effecti ve support for wavel ets of
type = 3 or 4.
wavemngr
8-151
Thi s opti on i s ful l y documented i n Chapter Chapter 7, Addi ng Your Own
Wavel ets .
wav emngr ( ' del ' , N) , del etes a wavel et fami l y. FSN = Fami l y Shor t Name or
Wavel et Name (i n the fami l y).
wav emngr ( ' r es t or e' ) or wave mngr ( ' r es t or e ' , I N2) , r estores pr evi ous or
i ni ti al wavel ets. I f nar gi n = 1, the previ ous wav el et s . as c fi l e i s restor ed;
other wi se the i ni ti al wave l e t s . as c fi l e i s r estored. Here I N2 i s a dummy
ar gument.
OUT1 = wave mngr ( ' r ead' ) OUT1 gi ves al l wavel ets fami l i es.
OUT1 = wave mngr ( ' r ead' , I N2) r etur ns al l wavel ets, I N2 i s a dummy
ar gument.
OUT1 = wav emngr ( ' r e ad_as c ' ) r eads wave l e t s . as c ASCI I -fi l e and OUT1 gi ves
al l wavel ets i nformati on.
wavemngr
8-152
Examples % Li s t i ni t i al wav el et s f ami l i e s .
wav emngr ( ' r e ad' )
ans =
===================================
Haar haar
Daube chi e s db
Bi or Spl i ne s bi or
Coi f l et s coi f
Syml e t s s y m
Mor l e t mor l
Mex i c an_hat me xh
Mey er me yr
===================================
% Li s t al l wav el et s .
wav emngr ( ' r e ad' , 1)
ans =
===================================
Haar haar
===================================
Daube chi e s db
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
db1 db2 db3 db4
db5 db6 db7 db8
db9 db10 dbxx
===================================
Bi or Spl i ne s bi or
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bi or 1. 1 bi or 1. 3 bi or 1. 5 bi or 2. 2
bi or 2. 4 bi or 2. 6 bi or 2. 8 bi or 3. 1
bi or 3. 3 bi or 3. 5 bi or 3. 7 bi or 3. 9
bi or 4. 4 bi or 5. 5 bi or 6. 8
===================================
Coi f l et s coi f
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c oi f 1 c oi f 2 coi f 3 c oi f 4
c oi f 5
===================================
wavemngr
8-153
Syml e t s s y m
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
s ym2 s ym3 s y m4 s ym5
s ym6 s ym7 s y m8
===================================
Mor l e t mor l
===================================
Mex i c an_hat me xh
===================================
Mey er me yr
===================================
I n the fol l owi ng exampl e, new compactl y supported or thogonal wavel ets are
added to the tool box. These wavel ets, whi ch are a sl i ght gener al i zati on of the
Daubechi es wavel ets, ar e based on the use of Ber nstei n pol ynomi al s and ar e
due to Kateb and Lemar i i n an unpubl i shed work.
Note: The M-fi l es used i n thi s exampl e can be found i n the wave de mo di rectory.
% Add new f ami l y of or t hogonal wave l et s .
% You mus t def i ne:
%
% Fami l y Name: Lemar i e
% Fami l y Shor t Name : l em
% Type of wave l e t : 1 ( or t h)
% Wav el e t s numbe r s : 1 2 3 4 5
% Fi l e dr i ve r : l emwavf
%
% The f unc t i on l emwav f . m mus t be as f ol l ow:
% f unct i on w = l emwav f ( wname)
% whe r e t he i nput ar gument wname i s a s t r i ng:
% wname = ' l em1' or ' l e m2' . . . i . e . ,
% wname = s h. name + numbe r
% and w t he cor r es pondi ng s cal i ng f i l t er .
% Ten addi t i on i s obt ai ne d us i ng:
wavemngr
8-154
wav emngr ( ' add' , ' Le mar i e ' , ' l em' , 1, ' 1 2 3 4 5' , ' l emwavf ' ) ;
% The as c i i f i l e ' wave l et s . as c' i s s av ed as
% ' wave l e t s . pr v' , t hen i t i s modi f i e d and
% t he MAT f i l e ' wave l e t s . i nf ' i s gener at ed.
% Li s t wav el et s f ami l i e s .
wav emngr ( ' r e ad' )
ans =
===================================
Haar haar
Daube chi e s db
Bi or Spl i ne s bi or
Coi f l et s coi f
Syml e t s s y m
Mor l e t mor l
Mex i c an_hat me xh
Mey er me yr
Lemar i e l e m
===================================
% Remov e t he added f ami l y .
wav emngr ( ' de l ' , ' Le mar i e ' ) ;
% Li s t wav el et s f ami l i e s .
wav emngr ( ' r e ad' )
ans =
===================================
Haar haar
Daube chi e s db
Bi or Spl i ne s bi or
Coi f l et s coi f
Syml e t s s y m
Mor l e t mor l
Mex i c an_hat me xh
Mey er me yr
===================================
wavemngr
8-155
% Res t or e t he pr ev i ous as ci i f i l e
% ' wave l e t s . pr v' , t hen bui l d
% t he MAT- f i l e ' wave l e t s . i nf ' .
wav emngr ( ' r e s t or e' ) ;
% Li s t r e s t or e d wave l e t s .
wav emngr ( ' r e ad' , 1)
ans =
===================================
Haar haar
===================================
Daube chi e s db
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
db1 db2 db3 db4
db5 db6 db7 db8
db9 db10 dbxx
===================================
Bi or Spl i nes bi or
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bi or 1. 1 bi or 1. 3 bi or 1. 5 bi or 2. 2
bi or 2. 4 bi or 2. 6 bi or 2. 8 bi or 3. 1
bi or 3. 3 bi or 3. 5 bi or 3. 7 bi or 3. 9
bi or 4. 4 bi or 5. 5 bi or 6. 8
===================================
Coi f l et s coi f
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
c oi f 1 c oi f 2 coi f 3 c oi f 4 c oi f 5
===================================
Syml e t s s y m
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
s ym2 s ym3 s y m4 s ym5
s ym6 s ym7 s y m8
===================================
Mor l e t mor l
===================================
Mex i c an_hat me xh
===================================
Mey er me yr
===================================
wavemngr
8-156
Lemar i e l e m
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
l em1 l e m2 l e m3 l em4 l e m5
===================================
% Res t or e i ni t i al wave l et s .
%
% Res t or e t he i ni t i al as c i i f i l e
% ' wave l e t s . i ni ' and i ni t i al
% MAT- f i l e ' wave l e t s . bi n' .
wav emngr ( ' r e s t or e' , 0) ;
% Li s t wav el et s f ami l i e s .
wav emngr ( ' r e ad' )
ans =
===================================
Haar haar
Daube chi e s db
Bi or Spl i ne s bi or
Coi f l et s coi f
Syml e t s s y m
Mor l e t mor l
Mex i c an_hat me xh
Mey er me yr
===================================
% Add new f ami l y of or t hogonal wav el et s .
wav emngr ( ' add' , ' Le mar i e ' , ' l em' , 1, ' 1 2 3' , ' l emwavf ' ) ;
% Al l c ommand l i ne c apabi l i t i es ar e av ai l abl e f or
% t he new wave l e t s .
%
% Exampl e 1: c omput e t he f our as s oci at ed f i l t er s .
[ Lo_D, Hi _D, Lo_R, Hi _R] = wf i l t e r s ( ' l e m3' ) ;
% Exampl e 2: c omput e s c al e and wav el et f unct i ons .
[ phi , ps i , x val ] = wave f un( ' l em3' ) ;
wavemngr
8-157
% Add a new f ami l y of or t hogonal wav el et s : s pe c i al f or m
% f or t he GUI mode .
%
% The M- f i l e l emwavf al l ows y ou t o c omput e t he f i l t er f or
% any or der . I f you want t o get a popup of t he f or m
% 1 2 3 **, as s oci at ed wi t h t he f ami l y , t hen wave l e t s ar e
% appende d f or GUI mode us i ng:
wav emngr ( ' r e s t or e' , 0) ;
wav emngr ( ' add' , ' Le mar i e ' , ' l em' , 1, ' 1 2 3 **' , ' l e mwav f ' ) ;
% Af t er t hi s s eque nc e, al l GUI capabi l i t i e s ar e avai l abl e f or
% t he new wave l e t s .
% Not e t hat t he l as t c ommand al l ows a s hor t cut i n t he
% or der def i ni t i on onl y i f pos s i bl e or de r s ar e i nt e ge r s .
Caution: wav e mngr works on the cur rent di r ector y. I f you add a new wavel et
fami l y, i t i s avai l abl e i n thi s di r ector y onl y. Refer to Chapter 7, Addi ng Your
Own Wavel ets .
Limitations wav emngr al l ows you to add a new wavel et. You must veri fy that i t i s trul y a
wavel et. No check i s per formed ei ther about thi s poi nt or about the type of the
new wavel et.
waverec
8-158
waver ec
Purpose Mul ti -l evel 1-D wavel et r econstructi on.
Syntax X = wav er ec ( C, L, ' wname' )
X = wav er ec ( C, L, Lo_R, Hi _R)
Description wav er ec performs a mul ti -l evel one-di mensi onal wavel et reconstr ucti on usi ng
ei ther a speci fi c wavel et ('wname', see wf i l t e r s ) or speci fi c r econstructi on fi l ter s
(Lo_R and Hi _R). wave r e c i s the i nverse functi on of wave de c i n the sense that
the abstract statement wave r e c( wave dec ( X, N, 'wname') , 'wname') retur ns X.
X = wav er ec ( C, L, 'wname') reconstr ucts the si gnal X based on the mul ti -l evel
wavel et decomposi ti on str uctur e [ C, L] and wavel et 'wname'. (For i nformati on
about the decomposi ti on str uctur e, see wav ede c.)
X = wav er ec ( C, L, Lo_R, Hi _R) reconstr ucts the si gnal X as above, usi ng the
reconstructi on fi l ter s you speci fy.
Remarks Note that X = wav er ec ( C, L, 'wname') i s equi val ent to
X = appcoef ( C, L, 'wname', 0) .
Examples % Load or i gi nal one- di mens i onal s i gnal .
l oad l el ec cum; s = l e l e cc um( 1: 3920) ; l s = l engt h( s ) ;
% Per f or m de compos i t i on of s i gnal at l ev el 3 us i ng db5.
[ c, l ] = wave de c( s , 3, ' db5' ) ;
% Rec ons t r uc t s f r om t he wave l e t dec ompos i t i on s t r uct ur e [ c, l ] .
a0 = wav er ec ( c , l , ' db5' ) ;
% Che ck f or pe r f ec t r e c ons t r uct i on.
e r r = nor m( s - a0)
e r r =
3. 2079e- 09
See Also appcoef , i dwt , wav ede c
waverec2
8-159
waver ec2
Purpose Mul ti -l evel 2-D wavel et r econstructi on.
Syntax X = wav er ec 2( C, S, ' wname' )
X = wav er ec 2( C, S, Lo_R, Hi _R)
Description wav er ec 2 i s a two-di mensi onal wavel et anal ysi s functi on.
X = wav er ec 2( C, S, 'wname') perfor ms a mul ti -l evel wavel et r econstructi on of
two-di mensi onal si gnal X based on the wavel et decomposi ti on structur e [ C, S]
(for detai l ed stor age i nfor mati on, see wav edec 2). 'wname' i s a str i ng contai ni ng
the name of wavel et (see wf i l t er s ).
I nstead of gi vi ng the wavel et name, you can gi ve the fi l ter s. For
X = wav er ec 2( C, S, Lo_R, Hi _R) , Lo_R i s the r econstructi on l ow-pass fi l ter and
Hi _R i s the reconstr ucti on hi gh-pass fi l ter .
wav er ec 2 i s the i nverse functi on of wave de c2 i n the sense that the abstr act
statement wave r e c2( wave de c2( X, N, 'wname') , 'wname') gets back to X.
Remarks Note that X = wav er ec 2( C, S, 'wname') i s equi val ent to
X = appcoef 2( C, S, 'wname', 0) .
Examples % Load or i gi nal i mage.
l oad woman;
% X c ont ai ns t he l oaded i mage .
% Per f or m de compos i t i on at l e ve l 2
% of X us i ng s ym4.
[ c, s ] = wave de c2( X, 2, ' s ym4' ) ;
% Rec ons t r uc t X f r om t he wave l e t
% dec ompos i t i on s t r uct ur e [ c, s ] .
a0 = wav er ec 2( c, s , ' s y m4' ) ;
% Che ck f or pe r f ec t r e c ons t r uct i on.
max ( max ( X- a0) )
ans =
1. 9463e - 10
See Also appcoef 2, i dwt 2, wav ede c2
wcodemat
8-160
wcodemat
Purpose Extended pseudocol or matri x scal i ng.
Syntax Y = wcode mat ( X, NB, OPT, ABSOL)
Y = wcode mat ( X, NB, OPT)
Y = wcode mat ( X, NB)
Y = wcode mat ( X)
Description wc odemat i s a general uti l i ty.
Y = wcode mat ( X, NB, OPT, ABSOL) returns a coded versi on of i nput matr i x X i f
ABSOL = 0, or ABS( X) i f ABSOL i s nonzer o, usi ng the fi rst NB i ntegers. Codi ng
can be done rowwi se (OPT = ' r ow' ), col umnwi se ( OPT = ' c ol ' ) or gl obal l y
(OPT = ' mat ' ). Codi ng uses a r egul ar gr i d between the mi ni mum and the
maxi mum val ues of each r ow (col umn or matri x, respecti vel y).
Y = wcode mat ( X, NB, OPT) i s equi val ent to Y = wc odemat ( X, NB, OPT, 1) .
Y = wcode mat ( X, NB) i s equi val ent to Y = wcode mat ( X, NB, ' mat ' , 1) .
Y = wcode mat ( X) i s equi val ent to Y = wc odemat ( X, 16, ' mat ' , 1) .
wcommon
8-161
wcommon
Purpose Fi nd common el ements.
Syntax [ XI , YI ] = wcommon( X, Y)
Description wc ommon i s a gener al uti l i ty.
For two vector s X and Y wi th i nteger components, [ XI , YI ] = wcommon( X, Y)
returns two vector s wi th 0 and 1 components such that:
XI ( k) = 1 i f X( k) bel ongs to Y; otherwi se XI ( k) = 0 and
YI ( j ) = 1 i f Y( j ) bel ongs to X; otherwi se YI ( j ) = 0.
Examples % Def i ne t wo v ec t or s .
x = [ 10 20 30 40 50 ] ;
y = [ 60 50 70 30 20 12 31 ] ;
% Fi nd common el ement s .
[ xi , y i ] = wc ommon( x , y )
x i =
0 1 1 0 1
y i =
0 1 0 1 1 0 0
% Li s t common el ement s .
c omel em = x( f i nd( x i ) )
c omel em =
20 30 50
wdatamgr
8-162
wdatamgr
Purpose Manager for data structure.
Syntax [ OUT1, OUT2] = wdat amgr ( O, D, I N3, I N4, I N5)
Description wdat amgr i s a tree management uti l i ty.
[ OUT1, OUT2] = wdat amgr ( O, D, I N3, I N4, I N5) wher e D i s the data structur e
and O i s a str i ng opti on. The possi bl e opti ons are:
' wr i t e_cf s ' : wri tes coeffi ci ents for a ter mi nal node
dat a = wdat amgr ( ' wr i t e _c f s ' , dat a, t r e e, node , c oe f s ) ;
' r e ad_c f s ' : reads coeffi ci ents for a ter mi nal node
c oe f s = wdat amgr ( ' r e ad_c f s ' , dat a, t r e e, node ) ;
' r e ad_e nt ' : reads the entr opy vector
e nt = wdat amgr ( ' r e ad_e nt ' , dat a, node s ) ;
' r e ad_e nt o' : r eads the opti mal entropy vector
e nt o = wdat amgr ( ' r ead_ent o' , dat a, nodes ) ;
' r e ad_t p_ent ' : r eads the type and the parameter for entr opy
[ t y pe _e nt , par am] = wdat amgr ( ' r e ad_t p_e nt ' , dat a) ;
' r e ad_wav e' : r eads the name of the wavel et
wav e = wdat amgr ( ' r ead_wav e' , dat a) ;
wdatamgr
8-163
Examples % Load s i gnal .
l oad noi s dopp; x = noi s dopp;
% Dec ompos e x at dept h 3 wi t h db1 wave l e t packe t s
% us i ng Shannon ent r opy .
[ t , d] = wpde c( x, 3, ' db1' , ' s hannon' ) ;
% Read ent r opy name.
e nt _name = wdat amgr ( ' r e ad_t p_ent ' , d)
e nt _name =
s hannon
% Read wave l et name.
wav _name = wdat amgr ( ' r e ad_wav e' , d)
wav _name =
db1
wdatamgr
8-164
% Read pac ke t ( 3, 2) coe f f i c i e nt s .
c f s = wdat amgr ( ' r e ad_cf s ' , d, t , [ 3 2] ) ;
% Read pac ke t ( 3, 2) ent r opy and opt i mal ent r opy .
i nd_node = depo2i nd( 2, [ 3 2] ) ;
e nt = wdat amgr ( ' r e ad_ent ' , d, i nd_node )
e nt =
- 318. 4298
% Opt i mal ent r opy i s NaN be caus e no opt i mi z at i on has be e n done .
e nt o = wdat amgr ( ' r e ad_e nt o' , d, i nd_node )
e nt o =
NaN
% Modi f y pac ke t ( 3, 2) c oe f f i c i e nt s .
ncf s = c os ( c f s ) ; % or any ot he r modi f i c at i on !
% Updat e pac ke t ( 3, 2) c oe f f i c i e nt s .
d = wdat amgr ( ' wr i t e _c f s ' , d, t , [ 3 2] , ncf s ) ;
% Updat e nodes e nt r opy .
d = e nt r upd( t , d, ' s hannon' ) ;
nent = wdat amgr ( ' r e ad_e nt ' , d, i nd_node)
nent =
22. 2830
See Also wpdec , wpde c 2, wt r ee mgr
wden
8-165
wden
Purpose Automati c 1-D de-noi si ng usi ng wavel ets.
Syntax [ XD, CXD, LXD] = wde n( X, TPTR, SORH, SCAL, N, ' wname' )
[ XD, CXD, LXD] = wde n( C, L, TPTR, SORH, SCAL, N, ' wname' )
Description wde n i s a one-di mensi onal de-noi si ng ori ented functi on.
wde n per forms an automati c de-noi si ng process of a one-di mensi onal si gnal
usi ng wavel ets.
[ XD, CXD, LXD] = wde n( X, TPTR, SORH, SCAL, N, 'wname') r etur ns a de-noi sed
ver si on XD of i nput si gnal X obtai ned by threshol di ng the wavel et coeffi ci ents.
Addi ti onal output ar guments [ CXD, LXD] ar e the wavel et decomposi ti on
str uctur e (see wave de c ) of the de-noi sed si gnal XD.
TPTR str i ng contai ns thr eshol d sel ecti on r ul es:
' r i gr s ur e ' use the pri nci pl e of Stei ns Unbi ased Ri sk.
' he ur s ur e ' i s an heuri sti c vari ant of the fi rst opti on.
' s qt wol og' for uni versal thr eshol d .
' mi ni maxi ' for mi ni max thr eshol di ng (see t hs el ec t for mor e detai l s).
SORH (' s ' or ' h' ) i s for soft or hard thr eshol di ng (see wt hr e s h for more detai l s).
SCAL defi nes mul ti pl i cati ve threshol d r escal i ng:
' one' for no rescal i ng.
' s l n' for rescal i ng usi ng a si ngl e esti mati on of l evel noi se based on fi rst l evel
coeffi ci ents.
' ml n' for rescal i ng done usi ng l evel -dependent esti mati on of l evel noi se.
Wavel et decomposi ti on i s perfor med at l evel N and 'wname' i s a stri ng contai ni ng
the name of the desi r ed orthogonal wavel et (see wmaxl e v and wf i l t e r s ).
[ XD, CXD, LXD] = wde n( C, L, TPTR, SORH, SCAL, N, 'wname') r etur ns the same
output ar guments, usi ng the same opti ons as above, but obtai ned di rectl y fr om
the i nput wavel et decomposi ti on str uctur e [ C, L] of the si gnal to be de-noi sed,
at l evel N and usi ng 'wname' or thogonal wavel et.
2 . ( ) log
wden
8-166
The under l yi ng model for the noi sy si gnal i s basi cal l y of the fol l owi ng form:
where ti me n i s equal l y spaced.
I n the si mpl est model , suppose that e(n) i s a Gaussi an whi te noi se N(0,1) and
the noi se l evel a i s supposed to be equal to 1.
The de-noi si ng objecti ve i s to suppr ess the noi se part of the si gnal s and to
recover f.
The de-noi si ng pr ocedur e pr oceeds i n thr ee steps:
1 Decomposi ti on. Choose a wavel et, and choose a l evel N. Compute the wavel et
decomposi ti on of the si gnal s at l evel N.
2 Detai l coeffi ci ents thr eshol di ng. For each l evel from 1 to N, sel ect a threshol d
and appl y soft threshol di ng to the detai l coeffi ci ents.
3 Reconstr ucti on. Compute wavel et reconstr ucti on based on the ori gi nal
appr oxi mati on coeffi ci ents of l evel N and the modi fi ed detai l coeffi ci ents of
l evel s fr om 1 to N.
Mor e detai l s about thr eshol d sel ecti on r ul es can be found i n Chapter 6 and i n
the hel p for t hs e l e ct . Let us poi nt out that:
The detai l coeffi ci ents vector i s the super posi ti on of the coeffi ci ents of f and
the coeffi ci ents of e, and that the decomposi ti on of e l eads to detai l
coeffi ci ents that ar e standar d Gaussi an whi te noi ses.
Mi ni max and SURE threshol d sel ecti on rul es are more conservati ve and ar e
more conveni ent when smal l detai l s of functi on f l i e i n the noi se range. The
two other r ul es remove the noi se mor e effi ci entl y. The opti on ' heur s ur e ' i s
a compromi se.
I n pr acti ce the basi c model cannot be used di r ectl y. Thi s secti on exami nes the
opti ons avai l abl e, i n or der to deal wi th model devi ati ons. The remai ni ng
par ameter s c al has to be speci fi ed. I t cor responds to threshol d r escal i ng
methods.
Opti on s cal = ' one ' cor responds to the basi c model .
s n ( ) f n ( ) e n ( ) + =

wden
8-167
I n gener al you can i gnor e the noi se l evel that must be esti mated. The detai l
coeffi ci ents CD
1
(the fi nest scal e) ar e essenti al l y noi se coeffi ci ents wi th
standard devi ati on equal to . The medi an absol ute devi ati on of the
coeffi ci ents i s a r obust esti mate of . The use of a robust esti mate i s cr uci al
for two reasons. The fi r st i s that i f l evel 1 coeffi ci ents contai n f detai l s, these
detai l s are concentrated i n few coeffi ci ents. The second reason i s to avoi d
si gnal end effects, whi ch are pur e arti facts due to computati ons on the edges.
Opti on s c al = ' s l n' handl es thr eshol d rescal i ng usi ng a si ngl e esti mati on
of l evel noi se based on the fi rst l evel coeffi ci ents.
When you suspect a nonwhi te noi se e, threshol ds must be r escal ed by a l evel
dependent esti mati on of the l evel noi se. The same ki nd of str ategy i s used by
esti mati ng l evel by l evel . Thi s esti mati on i s i mpl emented i n M-fi l e
wnoi s e s t , whi ch handl es the wavel et decomposi ti on str uctur e of the or i gi nal
si gnal s di r ectl y.
Opti on s c al = ' ml n' handl es threshol d r escal i ng usi ng a l evel -dependent es-
ti mati on of the l evel noi se.
Examples % Set s i gnal t o noi s e r at i o and s et r and s ee d.
s nr = 3; i ni t = 2055615866;
% Gener at e or i gi nal s i gnal and a noi s y v er s i on addi ng
% a s t andar d Gaus s i an whi t e noi s e .
[ xr ef , x ] = wnoi s e( 3, 11, s nr , i ni t ) ;
% De- noi s e noi s y s i gnal us i ng s of t heur i s t i c SURE t hr es hol di ng
% and s cal e d noi s e opt i on, on det ai l c oe f f i c i e nt s obt ai ne d
% f r om t he dec ompos i t i on of x , at l e ve l 5 by s y m8 wav el et .
l ev = 5;
x d = wde n( x, ' heur s ur e ' , ' s ' , ' one ' , l ev , ' s y m8' ) ;

l ev
wden
8-168
% Pl ot s i gnal s .
s ubpl ot ( 611) , pl ot ( xr ef ) , axi s ( [ 1 2048 - 10 10] ) ;
t i t l e ( ' Or i gi nal s i gnal ' ) ;
s ubpl ot ( 612) , pl ot ( x) , ax i s ( [ 1 2048 - 10 10] ) ;
t i t l e ( [ ' Noi s y s i gnal - Si gnal t o noi s e r at i o = ' , . . .
num2s t r ( f i x( s nr ) ) ] ) ;
s ubpl ot ( 613) , pl ot ( xd) , axi s ( [ 1 2048 - 10 10] ) ;
t i t l e ( ' De- noi s ed s i gnal - heur i s t i c SURE' ) ;
% De- noi s e noi s y s i gnal us i ng s of t SURE t hr e s hol di ng
x d = wde n( x, ' heur s ur e ' , ' s ' , ' one' , l ev , ' s y m8' ) ;
% Pl ot s i gnal .
s ubpl ot ( 614) , pl ot ( xd) , axi s ( [ 1 2048 - 10 10] ) ;
t i t l e ( ' De- noi s ed s i gnal - SURE' ) ;
% De- noi s e noi s y s i gnal us i ng f i x e d f or m t hr e s hol d wi t h
% a s i ngl e l ev el e s t i mat i on of noi s e s t andar d dev i at i on.
x d = wde n( x, ' s qt wol og' , ' s ' , ' s l n' , l ev , ' s y m8' ) ;
% Pl ot s i gnal .
s ubpl ot ( 615) , pl ot ( xd) , axi s ( [ 1 2048 - 10 10] ) ;
t i t l e ( ' De- noi s ed s i gnal - Fi x e d f or m t hr e s hol d' ) ;
% De- noi s e noi s y s i gnal us i ng mi ni max t hr e s hol d wi t h
% a mul t i pl e l ev el e s t i mat i on of noi s e s t andar d dev i at i on.
x d = wde n( x, ' mi ni maxi ' , ' s ' , ' s l n' , l ev , ' s y m8' ) ;
% Pl ot s i gnal .
s ubpl ot ( 616) , pl ot ( xd) , axi s ( [ 1 2048 - 10 10] ) ;
t i t l e ( ' De- noi s ed s i gnal - Mi ni max' ) ;
% I f many t r i al s ar e ne ce s s ar y, i t i s be t t er t o per f or m
% dec ompos i t i on once and t hr e s hol d i t many t i me s :
% dec ompos i t i on.
[ c, l ] = wave de c( x, l ev , ' s y m8' ) ;
% t hr e s hol d t he de c ompos i t i on s t r uct ur e [ c, l ] .
x d = wde n( c, l , ' mi ni maxi ' , ' s ' , ' s l n' , l e v, ' s ym8' ) ;
wden
8-169
See Also t hs el ec t , wav e de c, wde ncmp, wf i l t e r s , wt hr e s h
References A. Antoni adi s, G. Oppenhei m, Eds. (1995), Wavel ets and stati sti cs, 103,
Lecture Notes i n Stati sti cs, Spri nger Ver l ag.
D.L. Donoho (1993), Pr ogress i n wavel et anal ysi s and WVD: a ten mi nute
tour , i n Progress in wavelet analysis and applications, Y. Meyer , S. Roques,
pp. 109128. Fronti res Ed.
D.L. Donoho, I .M. Johnstone (1994), I deal spati al adaptati on by wavel et
shri nkage, Biometrika, vol 81, pp. 425455.
D.L. Donoho (1995), De-noi si ng by soft-threshol di ng, I EEE Trans. on I nf.
Theory, 41, 3, pp. 613627.
D.L. Donoho, I .M. Johnstone, G. Ker kyachari an, D. Pi car d (1995), Wavel et
shri nkage: asymptoti a, J our. Roy. Stat. Soc., seri es B, vol . 57, no. 2, pp. 301
369.
10
0
10
Original signal
10
0
10
Noisy signal Signal to noise ratio = 3
10
0
10
Denoised signal heuristic SURE
10
0
10
Denoised signal SURE
10
0
10
Denoised signal Fixed form threshold
500 1000 1500 2000
10
0
10
Denoised signal Minimax
wdencmp
8-170
wdencmp
Purpose De-noi si ng or compr essi on usi ng wavel ets.
Syntax [ XC, CXC, LXC, PERF0, PERFL2] =
wde nc mp( ' gbl ' , X, ' wname' , N, THR, SORH, KEEPAPP)
[ XC, CXC, LXC, PERF0, PERFL2] = wde nc mp( ' l vd' , X, ' wname' , N, THR, SORH)
[ XC, CXC, LXC, PERF0, PERFL2] = wde nc mp( ' l vd' , C, L, ' wname' , N, THR, SORH)
Description wde nc mp i s a one- or two-di mensi onal de-noi si ng and compressi on or i ented
functi on.
wde nc mp per for ms a de-noi si ng or compr essi on pr ocess of a si gnal or an i mage,
usi ng wavel ets.
[ XC, CXC, LXC, PERF0, PERFL2] = wde nc mp( ' gbl ' , X, 'wname', N, THR, SORH,
KEEPAPP) r etur ns a de-noi sed or compressed versi on XC of i nput si gnal X (one-
or two-di mensi onal ) obtai ned by wavel et coeffi ci ents threshol di ng usi ng gl obal
posi ti ve threshol d THR.
Addi ti onal output ar guments [ CXC, LXC] ar e the wavel et decomposi ti on
str ucture of XC (see wave de c or wav edec 2). PERF0 and PERFL2 are L
2
-norm
recovery and compressi on score i n percentage.
PERFL2 = 100 (vector-nor m of CXC /vector-nor m of C)
2
i f [ C, L] denotes the
wavel et decomposi ti on str uctur e of X.
I f X i s a one-di mensi onal si gnal and 'wname' an orthogonal wavel et, PERFL2 i s
reduced to .
Wavel et decomposi ti on i s perfor med at l evel N and 'wname' i s a stri ng contai ni ng
wavel et name (see wmaxl ev and wf i l t er s ). SORH (' s ' or ' h' ) i s for soft or har d
threshol di ng (see wt hr es h for mor e detai l s). I f KEEPAPP = 1, approxi mati on
coeffi ci ents cannot be thr eshol ded, other wi se i t i s possi bl e.
wde nc mp( ' gbl ' , C, L, 'wname', N, THR, SORH, KEEPAPP) has the same output
ar guments, usi ng the same opti ons as above, but obtai ned di rectl y from the
i nput wavel et decomposi ti on structur e [ C, L] of the si gnal to be de-noi sed or
compr essed, at l evel N and usi ng 'wname' wavel et.
100 XC
2
X
2
------------------------
wdencmp
8-171
For the one-di mensi onal case and ' l vd' opti on:
[ XC, CXC, LXC, PERF0, PERFL2] = wde nc mp( ' l vd' , X, ' wname' , N, THR, SORH)
or
[ XC, CXC, LXC, PERF0, PERFL2] =
wde nc mp( ' l v d' , C, L, ' wname' , N, THR, SORH)
has the same output arguments, usi ng the same opti ons as above, but al l owi ng
l evel -dependent thr eshol ds contai ned i n vector THR (THR must be of l ength N).
I n addi ti on, the approxi mati on i s kept. Note that, wi th respect to wde n
(automati c de-noi si ng), wde ncmp al l ows mor e fl exi bi l i ty and you can i mpl ement
your own de-noi si ng str ategy.
For the two-di mensi onal case and ' l v d' opti on:
[ XC, CXC, LXC, PERF0, PERFL2] = wde nc mp( ' l vd' , X, ' wname' , N, THR, SORH)
or
[ XC, CXC, LXC, PERF0, PERFL2] =
wde nc mp( ' l v d' , C, L, ' wname' , N, THR, SORH)
THR must be a matr i x 3 by N contai ni ng the l evel -dependent threshol ds i n the
three or i entati ons; hori zontal , di agonal , and verti cal .
I deas for de-noi si ng can be found i n Chapter 2, Usi ng Wavel ets , and i n the
Descri pti on secti on of the wden r efer ence entry.
The compressi on featur es of a gi ven wavel et basi s ar e pri mari l y l i nked to the
rel ati ve scar ceness of the wavel et domai n representati on for the si gnal . The
noti on behi nd compr essi on i s based on the concept that the regul ar si gnal
component can be accur atel y approxi mated usi ng a smal l number of
approxi mati on coeffi ci ents (at a sui tabl y sel ected l evel ) and some of the detai l
coeffi ci ents.
Li ke de-noi si ng, the compressi on pr ocedur e contai ns thr ee steps:
1 Decomposi ti on.
2 Detai l coeffi ci ent threshol di ng. For each l evel from 1 to N, a threshol d i s se-
l ected and hard thr eshol di ng i s appl i ed to the detai l coeffi ci ents.
3 Reconstr ucti on.
The di ffer ence wi th the de-noi si ng pr ocedur e i s found i n step 2.
wdencmp
8-172
Examples % Load or i gi nal i mage.
l oad s i ns i n
% X c ont ai ns t he l oade d i mage .
% Gener at e noi s y i mage .
i ni t =2055615866; r andn( ' s ee d' , i ni t ) ;
x = X + 18*r andn( s i z e ( X) ) ;
% Us e wde ncmp f or i mage de- noi s i ng.
% f i nd def aul t v al ues ( s e e dde nc mp) .
[ t hr , s or h, ke epapp] = ddencmp( ' de n' , ' wv ' , x ) ;
% de- noi s e i mage us i ng gl obal t hr e s hol di ng opt i on.
x d = wde nc mp( ' gbl ' , x, ' s ym4' , 2, t hr , s or h, ke epapp) ;
Original Image
20 40 60 80 100120
20
40
60
80
100
120
Noisy Image
20 40 60 80 100120
20
40
60
80
100
120
Denoised Image
20 40 60 80 100120
20
40
60
80
100
120
wdencmp
8-173
% Load el ec t r i cal s i gnal and s e l e ct a par t .
l oad l e l ec cum; i ndx = 2600: 3100;
x = l el e cc um( i ndx) ;
% Us e wde nc mp f or s i gnal compr e s s i on.
% c ompr e s s us i ng a f i xe d t hr e s hol d.
t hr =35;
[ xd, c xd, l x d, pe r f 0, per f l 2] = . . .
wde ncmp( ' gbl ' , x , ' db3' , 3, t hr , ' h' , 1) ;
% Us e wde nc mp f or s i gnal de - noi s i ng.
% Fi nd def aul t v al ues ( s e e ddenc mp) .
[ t hr , s or h, ke epapp] = ddencmp( ' de n' , ' wv ' , x) ;
% De- noi s e s i gnal us i ng gl obal t hr e s hol di ng opt i on.
x d = wde nc mp( ' gbl ' , x, ' db3' , 2, t hr , s or h, ke epapp) ;
2600 2700 2800 2900 3000 3100
100
200
300
400
500
Original signal
2600 2700 2800 2900 3000 3100
100
200
300
400
500
Compressed signal
2_norm rec.: 99.95 % zero cfs: 85.08 %
wdencmp
8-174
% Load or i gi nal i mage.
l oad woman;
% X c ont ai ns t he l oaded i mage .
x =X( 100: 200, 100: 200) ;
nbc = s i z e ( map, 1) ;
% Us e wde ncmp f or i mage c ompr es s i on.
% Wav e l e t de compos i t i on of x.
n = 5; w = ' s y m2' ;
[ c, l ] = wave de c2( x , n, w) ;
% Wav el et coef f i ci ent s t hr e s hol di ng.
t hr =20;
[ xd, c xd, l x d, pe r f 0, pe r f l 2] = . . .
wde nc mp( ' gbl ' , c, l , w, n, t hr , ' h' , 1) ;
2600 2700 2800 2900 3000 3100
100
200
300
400
500
Original signal
2600 2700 2800 2900 3000 3100
100
200
300
400
500
Denoised signal
wdencmp
8-175
% I n addi t i on t he f i r s t opt i on al l ows l e ve l and or i ent at i on-
% depende nt t hr e s hol ds . I n t hi s c as e t he appr ox i mat i on i s ke pt .
% The l ev el - de pe ndent t hr es hol ds i n t he t hr e e or i ent at i ons
% hor i z ont al , di agonal and ve r t i c al ar e as f ol l ows :
t hr _h = [ 17 18] ; % Hor i z ont al t hr es hol ds .
t hr _d = [ 19 20] ; % Di agonal t hr es hol ds .
t hr _v = [ 21 22] ; % Ver t i cal t hr es hol ds .
t hr = [ t hr _h ; t hr _d ; t hr _v]
t hr =
17 18
19 20
21 22
[ xd, c xd, l x d, pe r f 0, per f l 2] = . . .
wde nc mp( ' l vd' , x, ' s y m8' , 2, t hr , ' h' ) ;
See Also dde nc mp, wave dec , wave dec 2, wde n, wpde nc mp, wt hr e s h
References R.A. DeVore, B. Jawer th, B.J. Luci er (1992), I mage compressi on thr ough
wavel et transform codi ng, I EEE Trans. on I nf. Theory, vol . 38, No 2, pp.
719-746.
D.L. Donoho (1993), Progr ess i n wavel et anal ysi s and WVD: a ten mi nute
tour , i n Pr ogress i n wavel et anal ysi s and appl i cati ons, Y. Meyer , S. Roques,
pp. 109-128. Fronti r es Ed.
Original image
20 40 60 80 100
20
40
60
80
100
threshold = 20
2_norm rec.: 99.14 % nul cfs : 79.51 %
20 40 60 80 100
20
40
60
80
100
wdencmp
8-176
D.L. Donoho, I .M. Johnstone(1994), I deal spati al adaptati on by wavel et
shri nkage, Biometrika, vol 81, pp. 425455.
D.L. Donoho, I .M. Johnstone, G. Ker kyachari an, D. Pi car d (1995), Wavel et
shri nkage: asymptopi a, J our. Roy. Stat. Soc., ser i es B, vol . 57 no. 2, pp. 301
369.
D.L. Donoho, I .M. Johnstone, I deal de-noi si ng i n an orthonormal basi s chosen
from a l i brary of bases, C.R.A.S. Pari s, t. 319, Ser. I , pp. 13171322.
D.L. Donoho (1995), De-noi si ng by soft-threshol di ng, I EEE Trans. on I nf.
Theory, 41, 3, pp. 613627.
wentropy
8-177
wentropy
8
Purpose Entropy (wavel et packet).
Syntax E = went r opy( X, T, P)
E = went r opy( X, T)
Description E = went r opy ( X, T, P) returns the entropy E of the vector or matri x i nput X. I n
both cases, output E i s a real number. T i s a stri ng contai ni ng the type of
entr opy:
T = ' s hannon' , ' t hr e s hol d' , ' nor m' , ' l og e ne r gy ' , ' s ur e ' , ' us e r '
P i s an opti onal par ameter dependi ng on T val ue:
I f T = ' s hannon' or ' l og ener gy ' , P i s not used.
I f T = ' t hr es hol d' or ' s ur e ' , P i s the thr eshol d and must be a posi ti ve
number.
I f T = ' nor m' , P i s the power and must be such that 1 <= P < 2.
I f T = ' us e r ' , P i s a str i ng contai ni ng the M-fi l e name of your own entropy
functi on, wi th a si ngl e i nput X.
E = went r opy( X, T) i s equi val ent to E = we nt r opy( X, T, 0) .
Functi onal s ver i fyi ng an addi ti ve-type property are wel l sui ted for effi ci ent
sear chi ng of bi nar y-tr ee str uctur es and the fundamental spl i tti ng pr oper ty of
the wavel et packets decomposi ti on. Cl assi cal entr opy-based cr i teri a match
these condi ti ons and descri be i nfor mati on-r el ated pr oper ti es for an accurate
repr esentati on of a gi ven si gnal . Entropy i s a common concept i n many fi el ds,
mai nl y i n si gnal processi ng. The fol l owi ng exampl e l i sts di ffer ent entr opy
cr i ter i a, many others ar e avai l abl e and can be easi l y i ntegrated. I n the
fol l owi ng expressi ons s i s the si gnal and (s
i
)
i
the coeffi ci ents of s i n an
orthonormal basi s.
wentropy
8-178
The entr opy E must be an addi ti ve cost functi on such that E(0) = 0 and
.
The (non-normal i zed) Shannon entr opy.
so
wi th the conventi on 0log(0) = 0.
The concentrati on i n l
p
nor m wi th 1 p < 2.
E2(s
i
) = | s
i
|
p
so
The l og ener gy entropy.
so
wi th the conventi on log(0) = 0.
The threshol d entropy.
E4(s
i
) = 1 i f | s
i
| > p and 0 el sewher e so E4(s) = #{i such that | s
i
| > p} i s the
number of ti me i nstants when the si gnal i s gr eater than a thr eshol d p.
The SURE entr opy.
E5(s) = n-#{i such that
See the secti on enti tl ed Usi ng wavel et packets for compressi on and de-noi s-
i ng i n Chapter 6 for more i nformati on.
E s ( ) E s
i
( )
i

=
E1 s
i
( ) s
i
2
s
i
2
( ) log = E1 s ( ) s
i
2
s
i
2
( ) log
i

=
E2 s ( ) s
i
p
i

s
p
p
= =
E3 s
i
( ) s
i
2
( ) log = E3 s ( ) s
i
2
( ) log
i

=
s
i
p } min s
i
2
p
2
( , )
i

+
wentropy
8-179
Examples % Gener at e i ni t i al s i gnal .
x = r andn( 1, 200) ;
% Comput e Shannon ent r opy of x.
e = went r opy ( x , ' s hannon' )
e =
- 142. 7607
% Comput e l og ener gy e nt r opy of x .
e = went r opy ( x , ' l og e ne r gy' )
e =
- 281. 8975
% Comput e t hr e s hol d ent r opy of x
% wi t h t hr e s hol d e qual t o 0. 2.
e = went r opy ( x , ' t hr es hol d' , 0. 2)
e =
162
% Comput e Sur e e nt r opy of x
% wi t h t hr e s hol d e qual t o 3.
e = went r opy ( x , ' s ur e' , 3)
e =
- 0. 6575
% Comput e nor m e nt r opy of x wi t h power e qual t o 1. 1.
e = went r opy ( x , ' nor m' , 1. 1)
e =
160. 1583
wentropy
8-180
% Comput e us er e nt r opy of x wi t h a us e r de f i ned
% f unct i on: us er ent f or e xampl e .
% t hi s f unct i on mus t be an M- f i l e , wi t h f i r s t l i ne
% of t he f ol l owi ng f or m:
%
% f unc t i on e = us e r ent ( x)
%
% whe r e x i s a v ec t or and e i s a r eal number .
% The n a new e nt r opy i s def i ned and can be us ed t ypi ng:
%
% e = went r opy ( x , ' us er ' , ' us er ent ' )
References R.R. Coi fman, M.V. Wi ckerhauser, (1992), Entropy-based Al gori thms for best
basi s sel ecti on, I EEE Trans. on I nf. Theory, vol . 38, 2, pp. 713718.
D.L. Donoho, I .M. Johnstone, I deal de-noi si ng i n an orthonormal basi s chosen
from a l i brary of bases, C.R.A.S. Pari s, t. 319, Ser. I , pp. 13171322.
wfilters
8-181
wfi l ters
Purpose Wavel et fi l ters.
Syntax [ Lo_D, Hi _D, Lo_R, Hi _R] = wf i l t er s ( ' wname' )
[ F1, F2] = wf i l t e r s ( ' wname' , ' t ype' )
Description [ Lo_D, Hi _D, Lo_R, Hi _R] = wf i l t e r s ( 'wname') computes four fi l ters associ ated
wi th the or thogonal or bi orthogonal wavel et named i n the str i ng 'wname'.
The four output fi l ter s are:
Lo_D, the decomposi ti on l ow-pass fi l ter
Hi _D, the decomposi ti on hi gh-pass fi l ter
Lo_R, the reconstructi on l ow-pass fi l ter
Hi _R, the reconstructi on hi gh-pass fi l ter
Avai l abl e or thogonal or bi orthogonal wavel et names 'wname' are:
[ F1, F2] = wf i l t e r s ( 'wname', 't ype') r etur ns the fol l owi ng fi l ters:
Daubechi es : ' db1' or ' haar ' , ' db2' , . . . , ' db10' , . . . , ' db50'
Coi fl ets : ' c oi f 1' , . . . , ' c oi f 5'
Syml ets : ' s ym2' , . . . , ' s y m8'
Bi orthogonal : ' bi or 1. 1' , ' bi or 1. 3' , ' bi or 1. 5'
' bi or 2. 2' , ' bi or 2. 4' , ' bi or 2. 6' , ' bi or 2. 8'
' bi or 3. 1' , ' bi or 3. 3' , ' bi or 3. 5' , ' bi or 3. 7'
' bi or 3. 9' , ' bi or 4. 4' , ' bi or 5. 5' , ' bi or 6. 8'
Lo_D and Hi _D (Decomposi ti on fi l ter s) I f 't ype' = ' d'
Lo_R and Hi _R (Reconstr ucti on fi l ter s) I f 't ype' = ' r '
Lo_D and Lo_R (Low-pass fi l ter s) I f 't ype' = ' l '
Hi _D and Hi _R (Hi gh-pass fi l ter s) I f 't ype' = ' h'
wfilters
8-182
Examples % Set wav e l e t name .
wname = ' db5' ;
% Comput e t he f our f i l t er s as s oci at e d wi t h wave l e t name gi ve n
% by t he i nput s t r i ng wname .
[ Lo_D, Hi _D, Lo_R, Hi _R] = wf i l t e r s ( wname ) ;
s ubpl ot ( 221) ; s t em( Lo_D) ;
t i t l e ( ' Dec ompos i t i on l ow- pas s f i l t er ' ) ;
s ubpl ot ( 222) ; s t em( Hi _D) ;
t i t l e ( ' Dec ompos i t i on hi gh- pas s f i l t e r ' ) ;
s ubpl ot ( 223) ; s t em( Lo_R) ;
t i t l e ( ' Rec ons t r uct i on l ow- pas s f i l t e r ' ) ;
s ubpl ot ( 224) ; s t em( Hi _R) ;
t i t l e ( ' Rec ons t r uct i on hi gh- pas s f i l t er ' ) ;
x l abe l ( ' The f our f i l t er s f or db5' )
0 5 10
1
0.5
0
0.5
1
Decomposition lowpass filter
0 5 10
1
0.5
0
0.5
1
Decomposition highpass filter
0 5 10
1
0.5
0
0.5
1
Reconstruction lowpass filter
0 5 10
1
0.5
0
0.5
1
The four filters for coif5
Reconstruction highpass filter
wfilters
8-183
% Whe n us ed wi t h t wo i nput ar gume nt s , de pe ndi ng on s e cond
% ar gument , out put s ar e one r ow or one c ol umn of t he pr ev i ous
% f i gur e.
% Dec ompos i t i on f i l t e r s ( f i r s t r ow) .
[ Lo_D, Hi _D] = wf i l t er s ( wname, ' d' ) ;
% Rec ons t r uc t i on f i l t er s ( s ec ond r ow) .
[ Lo_R, Hi _R] = wf i l t er s ( wname, ' r ' ) ;
% Low- pas s f i l t e r s ( f i r s t c ol umn) .
[ Lo_D, Lo_R] = wf i l t er s ( wname, ' l ' ) ;
% Hi gh- pas s f i l t er s ( s e cond c ol umn) .
[ Hi _D, Hi _R] = wf i l t er s ( wname, ' h' ) ;
See Also bi or f i l t , or t hf i l t , wav ei nf o
References I . Daubechi es (1992), Ten l ectures on wavel ets, CBMS-NSF confer ence ser i es
i n appl i ed mathemati cs. SI AM Ed.
S. Mal l at (1989), A theory for mul ti resol uti on si gnal decomposi ti on: the
wavel et r epresentati on, I EEE Pattern Anal. and Machine I ntell., vol . 11, no.
7, pp 674693.
wkeep
8-184
wkeep
Purpose Keep part of a vector or a matri x.
Syntax Y = wke ep( X, L, O)
Y = wke ep( X, L)
Description wke ep i s a gener al uti l i ty.
For a vector, Y = wke ep( X, L, O) extr acts the vector Y fr om the vector X. L i s the
l ength of resul t Y. I f O = ' c ' (' l ' , ' r ' r especti vel y), Y i s the central (l eft, ri ght
respecti vel y) par t of X.
Y = wke ep( X, L) i s equi val ent to Y = wke ep( X, L, ' c ' ) .
For a matri x, Y = wke ep( X, S) extracts the centr al part of the matri x X. S i s the
si ze of Y.
Examples % For a v e ct or .
x = 1: 10;
y = wkee p( x, 6, ' c ' )
y =
3 4 5 6 7 8
y = wkee p( x, 6)
y =
3 4 5 6 7 8
y = wkee p( x, 7, ' c ' )
y =
2 3 4 5 6 7 8
y = wkee p( x, 6, ' l ' )
y =
1 2 3 4 5 6
y = wkee p( x, 6, ' r ' )
y =
5 6 7 8 9 10
wkeep
8-185
% For a mat r i x .
x = magi c( 5)
x =
17 24 1 8 15
23 5 7 14 16
4 6 13 20 22
10 12 19 21 3
11 18 25 2 9
y = wke e p( x, [ 3 2] )
y =
5 7
6 13
12 19
wmaxlev
8-186
wmaxl ev
Purpose Maxi mum wavel et decomposi ti on l evel .
Syntax L = wmaxl ev ( S, ' wname' )
Description wmaxl ev i s a one- or two-di mensi onal wavel et or wavel et packets or i ented
functi on.
wmaxl ev can hel p you avoi d unreasonabl e maxi mum l evel val ues.
L = wmaxl ev ( S, 'wname') returns the maxi mum l evel decomposi ti on of si gnal or
i mage of si ze S usi ng the wavel et named i n the stri ng 'wname' (see wf i l t e r s ).
wmaxl ev gi ves the maxi mum al l owed l evel decomposi ti on, but i n gener al , a
smal l er val ue i s taken.
Usual val ues are 5 for the one-di mensi onal case and 3 for the two-di mensi onal
case.
Examples % For a 1_D s i gnal .
s = 2^10;
w = ' db1' ;
% Comput e maxi mum l e ve l dec ompos i t i on.
% The r ul e i s t he l as t l e ve l f or whi ch at l e as t
% one c oe f f i ci ent i s c or r ec t .
l = wmax l e v( s , w)
l =
10
% Change wav el et .
w = ' db7' ;
% Comput e maxi mum l e ve l dec ompos i t i on.
l = wmax l e v( s , w)
l =
6
wmaxlev
8-187
% For a 2_D s i gnal .
s = [ 2^9 2^7] ;
w = ' db1' ;
% Comput e maxi mum l e ve l dec ompos i t i on.
l = wmax l e v( s , w)
l =
7
% whi ch i s t he s ame as :
l = wmax l e v( mi n( s ) , w)
l =
7
% Change wav el et .
w = ' db7' ;
% Comput e maxi mum l e ve l dec ompos i t i on.
l = wmax l e v( s , w)
l =
3
See Also wav edec , wave dec 2, wpde c, wpdec 2
wnoise
8-188
wnoi se
Purpose Gener ate noi sy wavel et test data.
Syntax X = wnoi s e( NUM, N)
[ X, XN] = wnoi s e( NUM, N, SNRAT)
[ X, XN] = wnoi s e( NUM, N, SNRAT, I NI T)
Description X = wnoi s e ( NUM, N) r etur ns val ues of test functi on number NUM, on a 2
N
sampl e
of [0,1].
[ X, XN] = wnoi s e ( NUM, N, SNRAT) retur ns a test vector X as above, rescal ed such
that s t d( x) = SNRAT. The returned vector XN contai ns the same test vector
cor rupted by addi ti ve Gaussi an whi te noi se N(0,1). XN has a si gnal -to-noi se
rati o of SNRAT.
[ X, XN] = wnoi s e( NUM, N, SNRAT, I NI T) r etur ns pr evi ous vector X and XN, but
the gener ator seed i s set to I NI T val ue.
The si x functi ons are due to Donoho and Johnstone (See Refer ence):
Examples % Gener at e 2^10 s ampl e s of ' Heavy s i ne ' ( i t e m 3) .
x = wnoi s e ( 3, 10) ;
% Gener at e 2^10 s ampl e s of ' Doppl e r ' ( i t em 4) and of
% noi s y ' Doppl er ' wi t h a s i gnal - t o- noi s e r at i o of 7.
[ x, noi s y x] = wnoi s e ( 4, 10, 7) ;
NUM = 1 Bl ocks
NUM = 2 Bumps
NUM = 3 Heavy si ne
NUM = 4 Doppl er
NUM = 5 Quadchi rp
NUM = 6 Mi shmash
wnoise
8-189
% To i nt r oduce y our own r and s e ed, a f our t h
% ar gument i s al l owe d:
i ni t = 2055415866;
[ x, noi s y x] = wnoi s e ( 4, 10, 7, i ni t ) ;
% Pl ot al l t he t es t f unct i ons .
i nd = l i ns pace ( 0, 1, 2^10) ;
f or i = 1: 6
x = wnoi s e ( i , 10) ;
s ubpl ot ( 6, 1, i ) , pl ot ( i nd, x)
e nd
See Also wde n
References D.L. Donoho, I .M. Johnstone(1994), I deal spati al adaptati on by wavel et
shri nkage, Biometrika, vol 81, pp. 425455.
0 0.2 0.4 0.6 0.8 1
10
0
10
0 0.2 0.4 0.6 0.8 1
0
5
10
0 0.2 0.4 0.6 0.8 1
10
0
10
0 0.2 0.4 0.6 0.8 1
0.5
0
0.5
0 0.2 0.4 0.6 0.8 1
1
0
1
0 0.2 0.4 0.6 0.8 1
5
0
5
wnoisest
8-190
wnoi sest
Purpose Esti mate noi se of 1-D wavel et coeffi ci ents.
Syntax STDC = wnoi s e s t ( C, L, S)
Description STDC = wnoi s e s t ( C, L, S) retur ns esti mates of detai l coeffi ci ents standard
devi ati on for l evel s contai ned i n i nput vector S. [ C, L] i s the i nput wavel et
decomposi ti on structure (see wav edec ).
The esti mator used i s Maxi mum Absol ute Devi ati on /0.6745, wel l sui ted for
zero mean Gaussi an whi te noi se i n de-noi si ng one-di mensi onal model s (see
t hs el ec t ).
Examples % Gener at e Gaus s i an whi t e noi s e .
i ni t = 2055415866; r andn( ' s ee d' , i ni t ) ;
x = r andn( 1, 1000) ;
% Dec ompos e x at l ev el 2 us i ng db3 wav el et .
[ c, l ] = wave de c( x, 2, ' db3' ) ;
% Es t i mat e s t andar d de v i at i on of c oe f f i c i e nt s
% at each l e ve l 1 and 2.
% Si nce x i s a Gaus s i an whi t e noi s e wi t h uni t
% v ar i anc e , es t i mat e s mus t be c l os e t o 1.
wnoi s e s t ( c , l , 1: 2)
ans =
1. 0111 1. 0763
% Now s uppos e t hat x c ont ai ns 10 out l i er s .
i nd = 50: 50: 500;
x ( i nd) = 100 * one s ( s i z e( i nd) ) ;
% Dec ompos e x at l ev el 1 us i ng db3 wav el et .
[ ca, c d] = dwt ( x, ' db3' ) ;
wnoisest
8-191
% Or di nar y e s t i mat e of cd s t andar d dev i at i on
% ove r e s t i mat e s noi s e l ev el .
s t d( c d)
ans =
8. 0206
% Robus t es t i mat e of c d s t andar d de v i at i on
% r emai ns c l os e t o 1 t he noi s e l e ve l .
medi an( abs ( c d) ) /0. 6745
ans =
1. 0540
Limitations Thi s procedure i s wel l sui ted for Gaussi an whi te noi se.
See Also t hs el ec t , wav e de c, wde n
References D.L. Donoho, I .M. Johnstone (1994), I deal spati al adaptati on by wavel et
shri nkage, Biometrika, vol 81, pp. 425455.
wp2wtree
8-192
wp2wtr ee
Purpose Extract wavel et tree from wavel et packet tree.
Syntax [ T, D] = wp2wt r ee ( T, D)
Description wp2wt r e e i s a one- or two-di mensi onal wavel et packet anal ysi s functi on.
[ T, D] = wp2wt r ee ( T, D) computes the modi fi ed tree str uctur e T and data
str ucture D (see maket r e e), corr espondi ng to the wavel et decomposi ti on tree.
Examples % Load s i gnal .
l oad noi s dopp; x = noi s dopp;
% Dec ompos e x at dept h 3 wi t h db1 wave l e t pac ke t s .
[ wpt , wpd] = wpde c( x , 3, ' db1' ) ;
% Pl ot wav el et pac ke t t r e e s t r uct ur e wpt .
pl ot t r ee ( wpt )
% Comput e wave l e t t r ee .
[ wt , wd] = wp2wt r ee ( wpt , wpd) ;
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)
(0,0)
wp2wtree
8-193
% Pl ot wave l et t r e e s t r uc t ur e wt .
pl ot t r e e ( wt )
See Also maket r e e, wpde c, wpdec 2
(1,0) (1,1)
(2,0) (2,1)
(3,0) (3,1)
(0,0)
wpcoef
8-194
wpcoef
Purpose Wavel et packet coeffi ci ents.
Syntax X = wpc oe f ( S, D, N)
X = wpc oe f ( S, D)
Description wpc oe f i s a one- or two-di mensi onal wavel et packet anal ysi s functi on.
X = wpc oe f ( S, D, N) r etur ns the coeffi ci ents associ ated wi th the node N. S i s the
tr ee str uctur e and D the data str uctur e (see make t r ee ). I f N doesnt exi st,
X = [ ];
X = wpc oe f ( S, D) i s equi val ent to X = wpcoef ( S, D, 0) .
Examples % Load s i gnal .
l oad noi s dopp; x = noi s dopp;
f i gur e ( 1) ; s ubpl ot ( 211) ;
pl ot ( x ) ; t i t l e ( ' Or i gi nal s i gnal ' ) ;
% Dec ompos e x at dept h 3 wi t h db1 wave l e t pac ke t s
% us i ng Shannon ent r opy .
[ t , d] = wpde c( x, 3, ' db1' , ' s hannon' ) ;
% Pl ot t r e e s t r uct ur e.
pl ot t r ee ( t )
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)
(0,0)
wpcoef
8-195
% Read packe t ( 2, 1) coe f f i c i e nt s .
c f s = wpcoef ( t , d, [ 2 1] ) ;
f i gur e( 1) ; s ubpl ot ( 212) ;
pl ot ( cf s ) ; t i t l e ( ' Pac ke t ( 2, 1) c oe f f i c i e nt s ' ) ;
See Also maket r e e, wpde c, wpdec 2
200 400 600 800 1000
10
5
0
5
10
Original signal
50 100 150 200 250
5
0
5
Packet (2,1) coefficients
wpcutree
8-196
wpcutree
Purpose Cut wavel et packet tree.
Syntax [ T, D] = wpc ut r ee ( T, D, L)
[ T, D, RN] = wpc ut r e e( T, D, L)
Description wpc ut r e e i s a one- or two-di mensi onal wavel et packet anal ysi s functi on.
[ T, D] = wpc ut r ee ( T, D, L) cuts the tr ee T at l evel L and computes the
cor respondi ng data str uctur e D (see maket r e e).
[ T, D, RN] = wpc ut r e e( T, D, L) returns the same arguments as above and i n
addi ti on, the vector RN contai ns the i ndi ces of the reconstr ucted nodes.
Examples % Load s i gnal .
l oad noi s dopp; x = noi s dopp;
% Dec ompos e x at dept h 3 wi t h db1 wave l e t pac ke t s .
[ wpt , wpd] = wpde c( x , 3, ' db1' ) ;
% Pl ot wav el et pac ke t t r e e s t r uct ur e wpt .
pl ot t r ee ( wpt )
% Cut wav e l e t packet t r ee at l e ve l 2.
[ nwpt , nwpd] = wpcut r e e( wpt , wpd, 2) ;
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)
(0,0)
wpcutree
8-197
% Pl ot ne w wav el et pac ket t r e e s t r uc t ur e wpt .
pl ot t r e e ( nwpt )
See Also maket r e e, wpde c, wpdec 2
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(0,0)
wpdec
8-198
wpdec
Purpose Wavel et packet decomposi ti on 1-D.
Syntax [ T, D] = wpdec ( X, N, ' wname' , E, P)
[ T, D] = wpdec ( X, N, ' wname' )
Description wpdec i s a one-di mensi onal wavel et packet anal ysi s functi on.
[ T, D] = wpdec ( X, N, wname, E, P) r etur ns a tree structur e T and a data
str ucture D (see maket r e e), cor respondi ng to a wavel et packet decomposi ti on of
the vector X, at l evel N, wi th a par ti cul ar wavel et ('wname', see wf i l t e r s ).
E i s a str i ng contai ni ng the type of entr opy (see we nt r opy ):
E = ' s hannon' , ' t hr e s hol d' , ' nor m' , ' l og e ne r gy' , ' s ur e ' , ' us e r '
P i s an opti onal par ameter:
' s hannon' or ' l og e ne r gy' : P i s not used
' t hr e s hol d' or ' s ur e' : P i s the threshol d (0 P)
' nor m' : P i s a power (1 P < 2)
' us er ' : P i s a stri ng contai ni ng a name of an user-defi ned functi on
[ T, D] = wpdec ( X, N, ' wname' ) i s equi val ent to
[ T, D] = wpdec ( X, N, ' wname' , ' s hannon' ) .
The wavel et packets method i s a gener al i zati on of wavel et decomposi ti on that
offer s a r i cher si gnal anal ysi s. Wavel et packets atoms are waveforms i ndexed
by three natural l y i nter pr eted par ameters: posi ti on and scal e as i n wavel et
decomposi ti on, and frequency.
For a gi ven orthogonal wavel et functi on, a l i brary of wavel et packets bases i s
gener ated. Each of these bases offers a par ti cul ar way of codi ng si gnal s,
preser vi ng gl obal ener gy and reconstr ucti ng exact features. The wavel et
packets can then be used for numer ous expansi ons of a gi ven si gnal . The most
sui tabl e decomposi ti on of a gi ven si gnal wi th respect to an entropy-based
cr i ter i on i s then sel ected.
Si mpl e and effi ci ent al gori thms exi st for both wavel et packets decomposi ti on
and opti mal decomposi ti on sel ecti on. Adapti ve fi l teri ng al gor i thms wi th di r ect
appl i cati ons i n opti mal si gnal codi ng and data compr essi on can then be
produced.
wpdec
8-199
I n the or thogonal wavel et decomposi ti on procedure, the generi c step spl i ts the
approxi mati on coeffi ci ents i nto two parts. After spl i tti ng we obtai n a vector of
approxi mati on coeffi ci ents and a vector of detai l coeffi ci ents, both at a coarser
scal e. The i nfor mati on l ost between two successi ve approxi mati ons i s captur ed
i n the detai l coeffi ci ents. The next step consi sts i n spl i tti ng the new
approxi mati on coeffi ci ent vector ; successi ve detai l s ar e never re-anal yzed.
I n the cor respondi ng wavel et packets si tuati on, each detai l coeffi ci ent vector i s
al so decomposed i nto two par ts usi ng the same appr oach as i n appr oxi mati on
vector spl i tti ng. Thi s offer s the ri chest anal ysi s: the compl ete bi nary tr ee i s
produced i n the one-di mensi onal case or a quaternar y tree i n the
two-di mensi onal case.
Examples % Load s i gnal .
l oad noi s dopp; x = noi s dopp;
% Dec ompos e x at dept h 3 wi t h db1 wave l e t packe t s
% us i ng Shannon ent r opy .
[ t , d] = wpde c( x, 3, ' db1' , ' s hannon' ) ;
% The r es ul t i s t he wav el et pac ke t s de compos i t i on s t r uc t ur e
% whi ch c ons i s t s of a t r e e s t r uct ur e t and t he as s oci at e
% dat a s t r uc t ur e d.
% Pl ot t r ee s t r uct ur e ( bi nar y t r e e, or t r e e of or de r 2) .
pl ot t r e e ( t )
% Ope r at i ons on t he s t r uc t ur e ar e de f i ne d i n M- f i l e
% wdat amgr and y ou ar e not s uppos ed t o handl e
% t hi s i nt e r nal s t r uct ur e di r ec t l y.
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)
(0,0)
wpdec
8-200
Algorithm The al gor i thm used for the wavel et packets decomposi ti on fol l ows the same
l i ne as the wavel et decomposi ti on process (see dwt , wave de c ).
See Also maket r e e, wave i nf o, wdat amgr , we nt r opy , wpdec 2, wt r e emgr
References R.R. Coi fman, M.V. Wi ckerhauser, (1992), Entropy-based Al gori thms for best
basi s sel ecti on, I EEE Trans. on I nf. Theory, vol . 38, 2, pp. 713718.
Y. Meyer (1993), Les ondel ettes. Al gori thmes et appl i cati ons, Col i n Ed.,
Pari s, 2nd edi ti on. (Engl i sh tr ansl ati on: Wavel ets: Al gori thms and
Appl i cati ons, SI AM).
M.V. Wi cker hauser, (1991) I NRI A l ectur es on wavel et packet al gori thms,
Proceedings ondelettes et paquets dondes 17-21 June, Rocquencour t Fr ance, pp
3199.
M.V. Wi cker hauser, (1994) Adapted wavelet analysis from theory to software
algorithms, A.K. Peter s.
wpdec2
8-201
wpdec2
Purpose Wavel et packet decomposi ti on 2-D.
Syntax [ T, D] = wpdec 2( X, N, ' wname' , E, P)
[ T, D] = wpdec 2( X, N, ' wname' )
Description wpdec 2 i s a two-di mensi onal wavel et packet anal ysi s functi on.
[ T, D] = wpdec 2( X, N, ' wname' , E, P) r etur ns a tr ee str uctur e T and a data
str uctur e D (see maket r e e), cor respondi ng to a wavel et packet decomposi ti on of
the matr i x X, at l evel N, wi th a parti cul ar wavel et ('wname', see wf i l t e r s ).
E i s a str i ng contai ni ng the type of entr opy (see we nt r opy ):
E = ' s hannon' , ' t hr e s hol d' , ' nor m' , ' l og e ne r gy' , ' s ur e ' , ' us e r '
P i s an opti onal par ameter:
' s hannon' or ' l og e ne r gy' : P i s not used
' t hr e s hol d' or ' s ur e' : P i s the threshol d (0 P)
' nor m' : P i s a power (1 P < 2)
' us er ' : P i s a stri ng contai ni ng a name of an user-defi ned functi on
[ T, D] = wpdec 2( X, N, ' wname' ) i s equi val ent to
[ T, D] = wpdec 2( X, N, ' wname' , ' s hannon' ) .
See wpde c for a more compl ete descr i pti on.
wpdec2
8-202
Examples % Load i mage .
l oad t i r e
% X c ont ai ns t he l oaded i mage .
% For an i mage t he dec ompos i t i on i s pe r f or me d us i ng:
[ t , d] = wpde c2( X, 2, ' db1' ) ;
% def aul t ent r opy i s t he s hannon one .
% Pl ot t r e e s t r uct ur e ( quar t e r nar y t r e e, or t r e e of or de r 4) .
pl ot t r ee ( t )
Algorithm The al gor i thm used for the wavel et packets decomposi ti on fol l ows the same
l i ne as the wavel et decomposi ti on process (see dwt 2, wav ede c2).
See Also maket r e e, wave i nf o, wdat amgr , we nt r opy , wpdec , wt r ee mgr
References R.R. Coi fman, M.V. Wi cker hauser, (1992), Entr opy-based al gor i thms for best
basi s sel ecti on, I EEE Trans. on I nf. Theory, vol . 38, 2, pp. 713718.
Y. Meyer (1993), Les ondel ettes. Al gori thmes et appl i cati ons, Col i n Ed.,
Pari s, 2nd edi ti on. (Engl i sh tr ansl ati on: Wavel ets: Al gori thms and
Appl i cati ons, SI AM).
M.V. Wi cker hauser, (1991) I NRI A l ectur es on wavel et packet al gori thms,
Proceedings ondelettes et paquets dondes 17-21 June Rocquencourt Fr ance, pp
3199.
M.V. Wi cker hauser, (1994) Adapted wavelet analysis from theory to software
Algorithms, A.K. Peter s.
(1,0) (1,1) (1,2) (1,3)
(2,0) (2,1) (2,2) (2,3) (2,4) (2,5) (2,6) (2,7) (2,8) (2,9) (2,10) (2,11) (2,12) (2,13) (2,14) (2,15)
(0,0)
wpdencmp
8-203
wpdencmp
Purpose De-noi si ng or compr essi on usi ng wavel et packet.
Syntax [ XD, TREED, DATAD, PERF0, PERFL2] =
wpdencmp( X, SORH, N, ' wname' , CRI T, PAR, KEEPAPP)
[ XD, TREED, DATAD, PERF0, PERFL2] =
wpdencmp( TREE, DATA, SORH, CRI T, PAR, KEEPAPP)
Description wpdencmp i s a one- or two-di mensi onal de-noi si ng and compr essi on ori ented
functi on.
wpdencmp perfor ms a de-noi si ng or compr essi on pr ocess of a si gnal or an i mage,
usi ng wavel et packet. The i deas and the procedur es for de-noi si ng and
compr essi on usi ng wavel et packet are the same as those used i n the wavel ets
framewor k (see wden and wdencmp).
[ XD, TREED, DATAD, PERF0, PERFL2] =
wpdencmp( X, SORH, N, 'wname', CRI T, PAR, KEEPAPP) r etur ns a de-noi sed or
compr essed ver si on XD of i nput si gnal X (one- or two-di mensi onal ) obtai ned by
wavel et packet coeffi ci ents threshol di ng.
Addi ti onal output ar guments [ TREED, DATAD] are the wavel et packet best
decomposi ti on structure (see be s t t r e e) of XD. PERFL2 and PERF0 are L
2
recovery
and compr essi on scores i n percentages.
PERFL2 = 100 * (vector-nor m of WP-cfs of XD / vector -norm of WP-cfs of X)
2
.
I f X i s a one-di mensi onal si gnal and 'wname' an orthogonal wavel et, PERFL2 i s
reduced to .
SORH (' s ' or ' h' ) i s for soft or har d threshol di ng (see wt hr es h for mor e detai l s).
Wavel et packet decomposi ti on i s performed at l evel N and 'wname' i s a str i ng
contai ni ng wavel et name. Best decomposi ti on i s per for med usi ng entropy
cr i teri on defi ned by str i ng CRI T and par ameter PAR (see went r opy for detai l s).
Thr eshol d parameter i s al so PAR. I f KEEPAPP = 1, approxi mati on coeffi ci ents
cannot be thr eshol ded, other wi se i t i s possi bl e.
100 XD
2
X
2
-------------------------
wpdencmp
8-204
[ XD, TREED, DATAD, PERF0, PERFL2] =
wpdencmp( TREE, DATA, SORH, CRI T, PAR, KEEPAPP) has the same output
ar guments, usi ng the same opti ons as above, but obtai ned di rectl y from the
i nput wavel et packet decomposi ti on str uctur e [ TREE, DATA] (see make t r e e and
wpdec ) of the si gnal to be de-noi sed or compr essed.
I n addi ti on i f CRI T = ' nobe s t ' no opti mi zati on i s done and the cur rent
decomposi ti on i s threshol ded.
Examples % Load or i gi nal s i gnal .
l oad s uml i chr ; x = s uml i c hr ;
% Us e wpde nc mp f or s i gnal c ompr es s i on.
% f i nd def aul t v al ues ( s e e dde nc mp) .
[ t hr , s or h, ke epapp, c r i t ] = dde ncmp( ' c mp' , ' wp' , x)
t hr =
0. 5193
s or h =
h
kee papp =
1
c r i t =
t hr es hol d
% Denoi s e s i gnal us i ng gl obal t hr e s hol di ng wi t h
% t hr e s hol d be s t bas i s .
[ xc , t r ee d, dat ad, pe r f 0, per f l 2] = . . .
wpdencmp
8-205
wpdencmp( x , s or h, 3, ' db2' , c r i t , t hr , kee papp) ;
% Load or i gi nal i mage.
l oad s i ns i n
% Gener at e noi s y i mage .
i ni t = 2055615866; r andn( ' s ee d' , i ni t ) ;
x = X/18 + r andn( s i z e ( X) ) ;
% Us e wpdenc mp f or i mage de - noi s i ng.
% f i nd def aul t v al ues ( s e e ddenc mp) .
[ t hr , s or h, ke epapp, c r i t ] = dde nc mp( ' den' , ' wp' , x)
t hr =
4. 9685
s or h =
h
100 200 300 400 500
2
1
0
1
2
Original signal
100 200 300 400 500
2
1
0
1
2
Compressed Signal using Wavelet Packets
2_norm rec.: 97.52 % zero cfs: 53.98 %
wpdencmp
8-206
kee papp =
1
c r i t =
s ur e
% Denoi s e i mage us i ng gl obal t hr e s hol di ng wi t h
% SURE be s t bas i s .
x d = wpde ncmp( x, s or h, 3, ' s ym4' , c r i t , t hr , kee papp) ;
% Gener at e heavy s i ne and a noi s y ve r s i on of i t .
[ xr ef , x] = wnoi s e( 5, 11, 7, i ni t ) ;
% Us e wpde nc mp f or s i gnal de- noi s i ng.
n = l e ngt h( x ) ;
t hr = s qr t ( 2*l og( n*l og( n) /l og( 2) ) ) ;
x wpd = wpdencmp( x, ' s ' , 4, ' s y m4' , ' s ur e ' , t hr , 1) ;
% Compar e wi t h wav el et - bas e d de - noi s i ng r e s ul t .
x wd = wden( x , ' r i gr s ur e' , ' s ' , ' one ' , 4, ' s ym4' ) ;
Original Image
20 40 60 80100120
20
40
60
80
100
120
Noisy Image
20 40 60 80100120
20
40
60
80
100
120
Denoised Image
20 40 60 80100120
20
40
60
80
100
120
wpdencmp
8-207
See Also dde nc mp, wdenc mp, we nt r opy, wpdec , wpdec 2
References A. Antoni adi s, G. Oppenhei m, Eds. (1995), Wavel ets and stati sti cs, Lectur e
Notes i n Stati sti cs, 103, Spri nger Ver l ag.
R.R. Coi fman, M.V. Wi cker hauser, (1992), Entr opy-based al gor i thms for best
basi s sel ecti on, I EEE Trans. on I nf. Theory, vol . 38, 2, pp. 713718.
R.A. DeVore, B. Jawer th, B.J. Luci er (1992), I mage compressi on thr ough
wavel et tr ansfor m codi ng, I EEE Trans. on I nf. Theory, vol . 38, No 2, pp. 719
746.
D.L. Donoho (1993), Progr ess i n wavel et anal ysi s and WVD: a ten mi nute
tour , i n Pr ogress i n wavel et anal ysi s and appl i cati ons, Y. Meyer , S. Roques,
pp. 109128. Fronti res Ed.
D.L. Donoho, I .M. Johnstone(1994), I deal spati al adaptati on by wavel et
shri nkage, Biometrika, vol 81, pp. 425455.
D.L. Donoho, I .M. Johnstone, G. Ker kyachari an, D. Pi car d (1995), Wavel et
shri nkage: asymptopi a, J our. Roy. Stat. Soc., ser i es B, vol . 57 no. 2, pp. 301
369.
500 1000 1500 2000
10
0
10
Original signal
500 1000 1500 2000
10
0
10
Noisy Signal
500 1000 1500 2000
10
0
10
Denoised Signal using Wavelet Packets
500 1000 1500 2000
10
0
10
Denoised Signal using Wavelets
wpfun
8-208
wpfun
Purpose Wavel et packet functi ons.
Syntax [ WPWS, X] = wpf un( ' wname' , NUM, PREC)
[ WPWS, X] = wpf un( ' wname' , NUM)
Description wpf un i s a wavel et packet anal ysi s functi on.
[ WPWS, X] = wpf un( 'wname', NUM, PREC) computes the wavel et packets for a
wavel et 'wname' (see wf i l t e r s ), on dyadi c i nter val s of l ength 2
-PREC
.
PREC must be a posi ti ve i nteger. Output matri x WPWS contai ns the W functi ons
of i ndex from 0 to NUM, stored rowwi se as [W
0
; W
1
;...; W
NUM
]. Output vector X i s
the cor respondi ng common X-gri d vector.
[ WPWS, X] = wpf un( 'wname', NUM) i s equi val ent to
[ WPWS, X] = wpf un( 'wname', NUM, 7) .
The computati on scheme for wavel et packets gener ati on i s easy when usi ng an
orthogonal wavel et. We star t wi th the two fi l ter s of l ength 2N, denoted h(n) and
g(n), corr espondi ng to the wavel et. They ar e the r eversed versi ons of the
l ow-pass decomposi ti on fi l ter and the hi gh-pass decomposi ti on fi l ter di vi ded by
r especti vel y.
Now by i nducti on l et us defi ne the fol l owi ng sequence of functi ons
(W
n
(x) , n = 0,1,2,...) by:
where W
0
(x) = (x) i s the scal i ng functi on and W
1
(x) = (x) i s the wavel et
functi on.
2
W
2n
x ( ) 2 h k ( )
k 0 = 2N 1 , ,

W
n
2x k ( ) =
W
2n 1 +
x ( ) 2 g k ( )
k 0 = 2N 1 , ,

W
n
2x k ( ) =

wpfun
8-209
For exampl e for the Haar wavel et we have:
N = 1, h(0) = h(1) = 1/2 and g(0) = - g(1) = 1/2.
The equati ons become:
W
0
(x) = (x) i s the haar scal i ng functi on and W
1
(x) = (x) i s the Haar wavel et,
both suppor ted i n [0,1].
Then we can obtai n W
2n
by addi ng two 1/2-scal ed versi ons of W
n
wi th di sti nct
suppor ts [0,1/2] and [1/2,1] and obtai n W
2n+1
by subtr acti ng the same ver si ons
of W
n
.
Star ti ng fr om mor e regul ar ori gi nal wavel ets, usi ng a si mi l ar constructi on, we
obtai n smoothed versi ons of thi s system of W-functi ons, al l wi th support i n the
i nter val [0, 2N-1].
W
2n
x ( ) W
n
2x ( ) W
n
2x 1 ( ) + =
W
2n 1 +
x ( ) W
n
2x ( ) W
n
2x 1 ( ) =

wpfun
8-210
Examples % Comput e t he db2 Wn f unc t i ons f or n = 0 t o 7, ge ne r at i ng
% t he db2 wave l e t packe t s .
[ wp, x ] = wpf un( ' db2' , 7) ;
See Also wav ef un, wav ei nf o
References R.R. Coi fman, M.V. Wi ckerhauser, (1992), Entropy-based Al gori thms for best
basi s sel ecti on, I EEE Trans. on I nf. Theory, vol . 38, 2, pp. 713718.
Y. Meyer (1993), Les ondel ettes. Al gori thmes et appl i cati ons, Col i n Ed.,
Pari s, 2nd edi ti on. (Engl i sh tr ansl ati on: Wavel ets: Al gori thms and
appl i cati ons, SI AM).
M.V. Wi cker hauser, (1991) I NRI A l ectur es on wavel et packet al gori thms,
Proceedi ngs ondel ettes et paquets dondes 17-21 June Rocquencour t Fr ance, pp
3199.
M.V. Wi ckerhauser, (1994) Adapted wavel et anal ysi s from theory to softwar e
al gor i thms, A.K. Peter s.
0 2 4
0.5
0
0.5
1
1.5
W0
0 2 4
2
1
0
1
2
W1
0 2 4
2
1
0
1
2
3
W2
0 2 4
2
1
0
1
2
3
W3
0 2 4
2
1
0
1
2
3
W4
0 2 4
2
1
0
1
2
3
W5
0 2 4
2
1
0
1
2
3
W6
0 2 4
2
1
0
1
2
3
W7
wpjoin
8-211
wpjoi n
Purpose Recompose wavel et packet.
Syntax [ T, D] = wpj oi n( T, D, N)
[ T, D, X] = wpj oi n( T, D, N)
[ T, D] = wpj oi n( T, D)
[ T, D, X] = wpj oi n( T, D)
Description wpj oi n i s a one- or two-di mensi onal wavel et packet anal ysi s functi on. wpj oi n
updates the tr ee and data structures after the r ecomposi ti on of a node.
The nodes are number ed from l eft to r i ght and fr om top to bottom. The r oot
i ndex i s 0.
[ T, D] = wpj oi n( T, D, N) r etur ns the modi fi ed tr ee structure T and the modi fi ed
data structur e D (see make t r ee ), corr espondi ng to a r ecomposi ti on of the node N.
[ T, D, X] = wpj oi n( T, D, N) al so returns the coeffi ci ents of the node.
[ T, D] = wpj oi n( T, D) i s equi val ent to [ T, D] = wpj oi n( T, D, 0) .
[ T, D, X] = wpj oi n( T, D) i s equi val ent to [ T, D, X] = wpj oi n( T, D, 0) .
wpjoin
8-212
Examples % Load s i gnal .
l oad noi s dopp; x = noi s dopp;
% Dec ompos e x at dept h 3 wi t h db1 wave l e t pac ke t s .
[ wpt , wpd] = wpde c( x , 3, ' db1' ) ;
% Pl ot wav el et pac ke t t r e e s t r uct ur e wpt .
pl ot t r ee ( wpt )
% Rec ompos e packet ( 1, 1) or 2
[ wpt , wpd] = wpj oi n( wpt , wpd, [ 1 1] ) ;
% Pl ot wav el et pac ke t t r e e s t r uct ur e wpt .
pl ot t r ee ( wpt )
See Also maket r e e, wpde c, wpde c2, wps pl t
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)
(0,0)
(1,0) (1,1)
(2,0) (2,1)
(3,0) (3,1) (3,2) (3,3)
(0,0)
wprcoef
8-213
wpr coef
Purpose Reconstruct wavel et packet coeffi ci ents.
Syntax X = wpr coef ( T, D, N)
Description wpr coef i s a one- or two-di mensi onal wavel et packet anal ysi s functi on.
X = wpr c oe f ( T, D, N) computes r econstructed coeffi ci ents of the node N. T i s the
tr ee str uctur e and D the data structur e (see maket r ee ).
X = wpr coef ( T, D) i s equi val ent to X = wpr coef ( T, D, 0) .
Examples % Load s i gnal .
l oad noi s dopp; x = noi s dopp;
f i gur e( 1) ; s ubpl ot ( 211) ;
pl ot ( x) ; t i t l e ( ' Or i gi nal s i gnal ' ) ;
% Dec ompos e x at dept h 3 wi t h db1 wave l e t packe t s
% us i ng Shannon ent r opy .
[ t , d] = wpde c( x, 3, ' db1' , ' s hannon' ) ;
% Pl ot t r ee s t r uct ur e.
pl ot t r e e ( t )
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)
(0,0)
wprcoef
8-214
% Rec ons t r uc t packet ( 2, 1) .
r cf s = wpr coef ( t , d, [ 2 1] ) ;
f i gur e ( 1) ; s ubpl ot ( 212) ;
pl ot ( r cf s ) ; t i t l e( ' Re cons t r uc t ed pac ke t ( 2, 1) ' ) ;
See Also maket r e e, wpde c, wpde c2, wpr e c, wpr e c2
200 400 600 800 1000
10
5
0
5
10
Original signal
200 400 600 800 1000
4
2
0
2
4
Reconstructed packet (2,1)
wprec
8-215
wpr ec
Purpose Wavel et packet reconstr ucti on 1-D.
Syntax X = wpr ec ( T, D)
Description wpr ec i s a one-di mensi onal wavel et packet anal ysi s functi on.
X = wpr ec ( T, D) returns the r econstructed vector X corr espondi ng to a wavel et
packet decomposi ti on structure [ T, D] . T i s the tree structur e and D the data
str uctur e (see make t r e e).
wpr ec i s the i nverse functi on of wpde c i n the sense that the abstr act statement
wpr ec ( wpdec ( X, 'wname') ) gets back to X.
See Also maket r e e, wpde c, wpdec 2, wpj oi n, wpr ec 2, wps pl t
wprec2
8-216
wpr ec2
Purpose Wavel et packet reconstr ucti on 2-D.
Syntax X = wpr ec 2( T, D)
Description wpr ec 2 i s a two-di mensi onal wavel et packet anal ysi s functi on.
X = wpr ec 2( T, D) returns the r econstr ucted matr i x X cor respondi ng to a
wavel et packet decomposi ti on str uctur e [ T, D] . T i s the tree str uctur e and D the
data str ucture (see make t r e e).
wpr ec 2 i s the i nverse functi on of wpde c2 i n the sense that the abstr act
statement wpr e c2( wpde c2( X, 'wname') ) gets back to X.
See Also maket r e e, wpde c, wpde c2, wpj oi n, wpr ec , wps pl t
wpsplt
8-217
wpspl t
Purpose Spl i t (decompose) wavel et packet.
Syntax [ T, D] = wps pl t ( T, D, N)
[ T, D, cA, c D] = wps pl t ( T, D, N)
[ T, D, cA, c H, cV, c D] = wps pl t ( T, D, N)
Description wps pl t i s a one- or two-di mensi onal wavel et packet anal ysi s functi on.
wps pl t updates the tr ee and data structures after the decomposi ti on of a node.
[ T, D] = wps pl t ( T, D, N) r etur ns the modi fi ed tr ee structure T and the modi fi ed
data str uctur e D, cor respondi ng to the decomposi ti on of the node N.
For a one-di mensi onal decomposi ti on:
[ T, D, cA, c D] = wps pl t ( T, D, N) wi th cA = appr oxi mati on and cD = detai l of
node N.
For a two-di mensi onal decomposi ti on:
[ T, D, cA, c H, cV, c D] = wps pl t ( T, D, N) wi th c A = approxi mati on and
cH, cV, c D = detai l s of node N.
wpsplt
8-218
Examples % Load s i gnal .
l oad noi s dopp;
x = noi s dopp;
% Dec ompos e x at dept h 3 wi t h db1 wave l e t pac ke t s .
[ wpt , wpd] = wpde c( x , 3, ' db1' ) ;
% Pl ot wav el et pac ke t t r e e s t r uct ur e wpt .
pl ot t r ee ( wpt )
% Dec ompos e packet ( 3, 0) .
[ wpt , wpd] = wps pl t ( wpt , wpd, [ 3 0] ) ;
% or e qui v al ent l y wps pl t ( wpt , wpd, 7) .
% Pl ot wav el et pac ke t t r e e s t r uct ur e wpt .
pl ot t r ee ( wpt )
See Also maket r e e, wave de c, wave de c2, wpdec , wpde c 2, wpj oi n
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)
(0,0)
(1,0) (1,1)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (3,6) (3,7)
(4,0) (4,1)
(0,0)
wpthcoef
8-219
wpthcoef
Purpose Wavel et packet coeffi ci ents thr eshol di ng.
Syntax NDATA = wpt hc oe f ( DATA, TREE, KEEPAPP, SORH, THR)
Description wpt hc oe f i s a one- or two-di mensi onal de-noi si ng and compr essi on uti l i ty.
NDATA = wpt hc oe f ( DATA, TREE, KEEPAPP, SORH, THR) r etur ns a new data
str uctur e obtai ned fr om the wavel et packet decomposi ti on str ucture
[ DATA, TREE] (see make t r e e) by coeffi ci ents thr eshol di ng.
I f KEEPAPP = 1, approxi mati on coeffi ci ents are not threshol ded, otherwi se i t i s
possi bl e.
I f SORH = ' s ' , soft thr eshol di ng i s appl i ed, i f SORH = ' h' , har d thr eshol di ng i s
appl i ed (see wt hr es h).
THR i s the threshol d val ue.
See Also maket r e e, wpde c, wpdec 2, wpde nc mp, wt hr e s h
wrcoef
8-220
wrcoef
Purpose Reconstr uct si ngl e br anch fr om 1-D wavel et coeffi ci ents.
Syntax X = wr c oe f ( ' t ype' , C, L, ' wname' , N)
X = wr c oe f ( ' t ype' , C, L, Lo_R, Hi _R, N)
X = wr c oe f ( ' t ype' , C, L, ' wname' )
X = wr c oe f ( ' t ype' , C, L, Lo_R, Hi _R)
Description wr c oe f reconstr ucts the coeffi ci ents of a one-di mensi onal si gnal , gi ven a
wavel et decomposi ti on str uctur e (C and L) and ei ther a speci fi ed wavel et
('wname', see wf i l t e r s ) or speci fi ed r econstructi on fi l ter s (Lo_R and Hi _R).
X = wr c oe f ( 't ype', C, L, 'wname', N) computes the vector of reconstructed
coeffi ci ents, based on the wavel et decomposi ti on structure [ C, L] (see wave de c),
at l evel N.
Ar gument 't ype' deter mi nes whether appr oxi mati on ('t ype' = ' a' ) or detai l
('t ype' = ' d' ) coeffi ci ents ar e reconstructed. When 't ype' = ' a' , N i s al l owed to
be 0, otherwi se str i ctl y posi ti ve N i s r equi r ed. Level N must be an i nteger such
that N <= l engt h( L) - 2.
X = wr c oe f ( 't ype', C, L, Lo_R, Hi _R, N) computes coeffi ci ents as above, gi ven the
reconstructi on fi l ter s you speci fy.
X = wr c oe f ( 't ype', C, L, 'wname') and X = wr coef ( 't ype', C, L, Lo_R, Hi _R)
reconstruct coeffi ci ents of maxi mum l evel N = l e ngt h( L) - 2.
wrcoef
8-221
Examples % Load or i gi nal one- di mens i onal s i gnal .
l oad s ums i n; s = s ums i n;
% Per f or m de compos i t i on at l e ve l 5 of s us i ng s ym4.
[ c, l ] = wave de c( s , 5, ' s y m4' ) ;
% Rec ons t r uc t appr ox i mat i on at l e ve l 5,
% f r om t he wav el et dec ompos i t i on s t r uc t ur e [ c, l ] .
a5 = wr c oe f ( ' a' , c, l , ' s y m4' , 5) ;
See Also appcoef , de t c oef , wave dec
0 200 400 600 800 1000
4
2
0
2
4
Original signal s.
0 200 400 600 800 1000
2
1
0
1
2
Reconstructed approximation at level 5 : a5
wrcoef2
8-222
wrcoef2
Purpose Reconstr uct si ngl e br anch fr om 2-D wavel et coeffi ci ents.
Syntax X = wr c oe f 2( ' t ype' , C, S, ' wname' , N)
X = wr c oe f 2( ' t ype' , C, S, Lo_R, Hi _R, N)
X = wr c oe f 2( ' t ype' , C, S, ' wname' )
X = wr c oe f 2( ' t ype' , C, S, Lo_R, Hi _R)
Description wr c oe f 2 i s a two-di mensi onal wavel et anal ysi s functi on. wr coef 2 r econstructs
the coeffi ci ents of an i mage.
X = wr c oe f 2( 't ype', C, S, 'wname', N) computes the matri x of reconstr ucted
coeffi ci ents of l evel N, based on the wavel et decomposi ti on str ucture [ C, S] (see
wav edec 2).
'wname' i s a stri ng contai ni ng the name of the wavel et. I f 't ype' = ' a' ,
approxi mati on coeffi ci ents ar e r econstructed; other wi se i f 't ype' = ' h' (' v ' or
' d' r especti vel y), hor i zontal (ver ti cal or di agonal respecti vel y) detai l
coeffi ci ents ar e reconstr ucted.
Level N must be an i nteger such that: 0 <= N <= s i z e ( S, 1) - 2 i f 't ype' = ' a'
and such that 1 <= N <= s i z e( S, 1) - 2 i f 't ype' = ' h' , ' v' or 'd'.
I nstead of gi vi ng the wavel et name, you can gi ve the fi l ter s.
For X = wr coe f 2( 't ype', C, S, Lo_R, Hi _R, N) , Lo_R i s the reconstr ucti on
l ow-pass fi l ter and Hi _R i s the r econstructi on hi gh-pass fi l ter .
X = wr c oe f 2( 't ype', C, S, 'wname') or X = wr coe f 2( 't ype', C, S, Lo_R, Hi _R)
reconstructs coeffi ci ents of maxi mum l evel N = s i z e( S, 1) - 2.
wrcoef2
8-223
Examples % Load or i gi nal i mage.
l oad woman;
% X c ont ai ns t he l oaded i mage .
% Per f or m de compos i t i on at l e ve l 2
% of X us i ng s ym5.
[ c, s ] = wave de c2( X, 2, ' s ym5' ) ;
% Rec ons t r uc t appr ox i mat i ons at
% l ev el s 1 and 2, f r om t he wave l e t
% dec ompos i t i on s t r uct ur e [ c, s ] .
a1 = wr c oe f 2( ' a' , c , s , ' s ym5' , 1) ;
a2 = wr c oe f 2( ' a' , c , s , ' s ym5' , 2) ;
% Rec ons t r uc t de t ai l s at l e ve l 2,
% f r om t he wav el et dec ompos i t i on
% s t r uc t ur e [ c , s ] .
% ' h' i s f or hor i z ont al ,
% ' v' i s f or v er t i cal ,
% ' d' i s f or di agonal .
hd2 = wr coef 2( ' h' , c , s , ' s y m5' , 2) ;
v d2 = wr coef 2( ' v ' , c , s , ' s y m5' , 2) ;
dd2 = wr coef 2( ' d' , c , s , ' s y m5' , 2) ;
% Al l t he s e i mages ar e of s ame s i z e s X.
s X = s i z e( X)
s X =
256 256
s a1 = s i z e ( a1)
s a1 =
256 256
s hd2 = s i z e( hd2)
s hd2 =
256 256
See Also appcoef 2, det c oe f 2, wav edec 2
wrev
8-224
wrev
Purpose Fl i p vector .
Syntax Y = wr e v( X)
Description wr e v i s a general uti l i ty.
Y = wr e v( X) rever ses the vector X.
Examples % Set s i mpl e v ec t or .
v = [ 1 2 3] ;
% Rev er s e v.
wr e v( v )
ans =
3 2 1
% Rev er s e v t r ans pos e.
wr e v( v ' )
ans =
3
2
1
See Also f l i pl r , f l i pud
wthcoef
8-225
wthcoef
Purpose Wavel et coeffi ci ents thr eshol di ng 1-D.
Syntax NC = wt hc oe f ( ' d' , C, L, N, P)
NC = wt hc oe f ( ' d' , C, L, N)
NC = wt hc oe f ( ' a' , C, L)
NC = wt hc oe f ( ' t ' , C, L, N, T, SORH)
Description wt hcoef i s a one-di mensi onal de-noi si ng and compressi on ori ented functi on.
NC = wt hc oe f ( ' d' , C, L, N, P) r etur ns coeffi ci ents obtai ned from the wavel et
decomposi ti on structure [ C, L] (see wav e de c), by r ate compressi on defi ned i n
vectors N and P. N contai ns the detai l l evel s to be compressed and P the
cor respondi ng percentages of l ower coeffi ci ents to be set to zer o. N and P must
be of same l ength. Vector N must be such that 1 <= N( i ) <= l e ngt h( L) - 2.
NC = wt hc oe f ( ' d' , C, L, N) retur ns coeffi ci ents obtai ned from [ C, L] by setti ng
to zer o al l the coeffi ci ents of detai l l evel s defi ned i n N.
NC = wt hcoe f ( ' a' , C, L) returns coeffi ci ents obtai ned by setti ng appr oxi mati on
coeffi ci ents to zer o.
NC = wt hc oe f ( ' t ' , C, L, N, T, SORH) returns coeffi ci ents obtai ned from the
wavel et decomposi ti on str uctur e [ C, L] by soft (i f SORH=' s ' ) or hard (i f
SORH=' h' ) threshol di ng (see wt hr es h) defi ned i n vectors N and T. N contai ns the
detai l l evel s to be threshol ded and T the cor respondi ng threshol ds. N and T
must be of the same l ength.
[ NC, L] i s the resul ti ng wavel et decomposi ti on structure.
See Also wav edec , wt hr e s h
wthcoef2
8-226
wth coef2
Purpose Wavel et coeffi ci ents thr eshol di ng 2-D.
Syntax NC = wt hc oe f 2( ' t ype' , C, S, N, T, SORH)
NC = wt hc oe f 2( ' t ype' , C, S, N)
NC = wt hc oe f 2( ' a' , C, S)
NC = wt hc oe f 2( ' t ' , C, S, N, T, SORH)
Description wt hcoef 2 i s a two-di mensi onal de-noi si ng and compressi on or i ented functi on.
For 't ype' = ' h' ( 'v' or ' d' ), NC = wt hc oe f 2( 't ype', C, S, N, T, SORH) r etur ns the
hor i zontal (ver ti cal or di agonal respecti vel y) coeffi ci ents obtai ned fr om the
wavel et decomposi ti on structure [ C, S] (see wav edec 2), by soft (i f SORH=' s ' ) or
hard (i f SORH=' h' ) threshol di ng defi ned i n vector s N and T. N contai ns the detai l
l evel s to be compressed and T the corr espondi ng thr eshol ds. N and T must be of
the same l ength. The vector N must be such that 1 <= N( i ) <= s i z e( S, 1) - 2.
For 't ype' = ' h' (' v ' or ' d' respecti vel y), NC = wt hc oe f 2( 't ype', C, S, N)
returns the coeffi ci ents of 't ype' ori entati on obtai ned fr om [ C, S] by setti ng to
zero al l the coeffi ci ents of detai l l evel s defi ned i n N.
NC = wt hc oe f 2( ' a' , C, S) retur ns the coeffi ci ents obtai ned by setti ng
approxi mati on coeffi ci ents to zer o.
NC = wt hc oe f 2( ' t ' , C, S, N, T, SORH) r etur ns the detai l coeffi ci ents obtai ned
from the wavel et decomposi ti on str uctur e [ C, S] by soft (i f SORH=' s ' ) or hard
(i f SORH=' h' ) thr eshol di ng (see wt hr e s h) defi ned i n vectors N and T. N contai ns
the detai l l evel s to be threshol ded and T the corr espondi ng threshol ds whi ch
ar e appl i ed i n the three detai l ori entati ons. N and T must be of the same l ength.
[ NC, S] i s the resul ti ng wavel et decomposi ti on structur e.
See Also wav edec 2, wt hr es h
wthresh
8-227
wthr esh
Purpose Perfor m soft or har d thr eshol di ng.
Syntax Y = wt hr e s h( X, SORH, T)
Description Y = wt hr e s h( X, SORH, T) returns the soft (i f SORH = ' s ' ) or hard (i f SORH = ' h' )
T-threshol di ng of the i nput vector or matr i x X. T i s the thr eshol d val ue.
Y = wt hr e s h( X, ' s ' , T) returns , soft threshol di ng i s
wavel et shr i nkage.
Y = wt hr e s h( X, ' h' , T) r etur ns , hard threshol di ng i s more
cr ude.
Examples % Gener at e s i gnal and s et t hr es hol d.
y = l i ns pace ( - 1, 1, 100) ;
t hr = 0. 4;
% Per f or m har d t hr es hol di ng.
y t har d = wt hr e s h( y , ' h' , t hr ) ;
% Per f or m s of t t hr es hol di ng.
y t s of t = wt hr e s h( y , ' s ' , t hr ) ;
See Also wde n, wde nc mp, wpdencmp
Y SIGN X ( ) X T ( )
+
=
Y X.1
X T > ( )
=
1 0 1
1
0.5
0
0.5
1
Original signal
1 0 1
1
0.5
0
0.5
1
Hard thresholded signal
1 0 1
1
0.5
0
0.5
1
Soft thresholded signal
wtreemgr
8-228
wtr eemgr
Purpose Manager for tr ee str ucture.
Syntax [ OUT1, OUT2, OUT3, OUT4] = wt r ee mgr ( OPT, STRUCTURE, I N3, I N4, I N5)
Description wt r e emgr i s a tr ee management uti l i ty.
Al l owed val ues for OPT and associ ated uses are descri bed i n the functi ons l i sted
i n the See Al so secti on:
For tree str uctur e i mpl ementati on see maket r ee .
See Also al l node s , i s node , i s t node , make t r e e, node as c, node de s c , node par , nt node,
t node s , t r e e dpt h, t r e eor d
' al l nodes ' : Al l nodes
' i s node ' : Check i f node
' i s t node' : Check i f ter mi nal node
' cr eat e ' : Cr eate a tr ee
' node as c' : Node ascendants
' node de s c ' : Node descendants
' node par ' : Node par ent
' nt node ' : Number of termi nal nodes
' t nodes ' : Ter mi nal nodes
' or de r ' : Or der of tr ee
' de pt h' : Depth of tree

B
GUI Reference
A-3 General Features
A-3 Col or Codi ng
A-3 Connectedness of Pl ots
A-4 Usi ng the Mouse
A-6 Control l i ng the Col ormap
A-7 Control l i ng the Number of Col ors
A-8 Control l i ng the Col orati on Mode
A-8 Customi zi ng Gr aphi cal Objects
A-10 Customi zi ng Pri nt Setti ngs
A-11 Usi ng Menus
A-14 Continuous Wavelet Tool Features
A-15 Wavelet 1-D Tool Features
A-15 Tr ee Mode
A-15 Mor e Di spl ay Opti ons
A-17 Wavelet 2-D Tool Features
A-18 Wavelet Packet Tool Features (1-D and 2-D)
A-19 Node Acti on Functi onal i ty
A-22 Wavelet Display Tool
A-23 Wavelet Packet Display Tool
B G UI Reference
B-2
Thi s appendi x expl ai ns some of the features of the Wavel et Tool box graphi cal
user i nter face (GUI ) that have not been descri bed i n the previ ous chapters.
Topi cs i ncl ude:
Gener al Features
Conti nuous Wavel et Tool Features
Wavel et 1-D Tool Featur es
Wavel et 2-D Tool Featur es
Wavel et Packet Tool Features (1-D and 2-D)
Wavel et Di spl ay Tool
Wavel et Packet Di spl ay Tool
G eneral Features
B-3
General Features
Some features of the Wavel et Tool boxs gr aphi cal user i nterface appl y to al l or
sever al of the tool s i n the tool box. These i ncl ude:
Col or codi ng
Connectedness of pl ots
Usi ng the mouse
Contr ol l i ng the col or map
Contr ol l i ng the number of col ors
Contr ol l i ng the col or ati on mode
Customi zi ng gr aphi cal objects
Customi zi ng pri nt setti ngs
Usi ng menus
Color Coding
I n al l the gr aphi cal tool s, the vari ous si gnal s and anal ysi s components ar e col or
coded i n thi s way:
Connectedness of Plots
Pl ots that contai n r el ated i nformati on and are gr aphed on the same absci ssa
ar e connected i n the sense that mani pul ati ons perfor med on one pl ot affect
al l the other s i n the same way.
Signal Shown in
Ori gi nal Red
Reconstructed or synthesi zed Yel l ow
Appr oxi mati ons Var i egated shades of bl ue
(hi gh l evel = dar ker )
Detai l s Var i egated shades of green
(hi gh l evel = dar ker )
B G UI Reference
B-4
For exampl e, the approxi mati ons and detai l s shown i n the separate mode vi ew
of a decomposi ti on al l r espond together when any of the pl ots i s magni fi ed or
zoomed:
Using the Mouse
The Wavel et Tool box uses thr ee di sti nct types of mouse control :
Left Mouse Button Middle Mouse Button Right Mouse Button
Make sel ecti ons,
acti vate contr ol s.
Di spl ay a cross-hai r to
show
posi ti on-dependent
i nfor mati on
Transl ate pl ots up and
down, and l eft and
r i ght
Zooming
Magnifies all
unison
here
the plots in
Shift + Option +
G eneral Features
B-5
Making Selections and Activating Controls
Most of the work you do wi th the Wavel et Tool box gr aphi cal tool s i nvol ves
maki ng sel ecti ons and acti vati ng contr ol s. You do thi s usi ng the l eft (or onl y)
mouse button.
Translating Plots
By hol di ng down the ri ght mouse button (or i ts equi val ent on a one- or
two-button mouse), you can move the mouse to dr aw a rectangl e i n ei ther a
hor i zontal or ver ti cal or i entati on. Rel easi ng the mi ddl e mouse button then
causes the pl ot to shi ft hori zontal l y or verti cal l y by an amount proporti onal to
the si ze of the r ectangl e.
Displaying Position-Dependent Information
When you hol d down the mi ddl e mouse button (or i ts equi val ent on a one- or
two-button mouse), a cross-hai r cur sor appears over the graph or pl ot.
Posi ti on-dependent i nformati on al so appears i n the Position box l ocated at the
bottom center of the tool .
The type of i nformati on that appear s depends on what tool you are usi ng and
on what pl ot your cursor i s i n.
B G UI Reference
B-6
Controlling the Colormap
The Colormap sel ecti on box, l ocated at the bottom ri ght of the wi ndow, al l ows
you to adjust the col or map that i s used to pl ot i mages or wavel et coeffi ci ents.
Thi s i s mor e than an estheti c adjustment: you ar e l i kel y to see di fferent
features dependi ng on your col ormap sel ecti on.
Consi der these i mages of the Mandel br ot set generated i n the Wavelet Packet
2-D tool , here usi ng the bone and 1bone col ormaps:
Colormap
bone 1bone
G eneral Features
B-7
Controlling the Number of Colors
The Nb. Colors sl i der, al so l ocated at the bottom ri ght of the wi ndow, al l ows you
to adjust how many col or s the tool uses to pl ot i mages or wavel et packet
coeffi ci ents (you can al so use the edi t contr ol ). At fi rst gl ance, thi s mi ght not
seem to be par ti cul ar l y i mpor tant. However , adjusti ng the number of col ors can
hi ghl i ght di fferent features of the pl ot.
Consi der the coeffi ci ents pl ot of the Koch curve generated i n the Continuous
Wavelet tool , here usi ng 129 col ors:
and her e usi ng 68 col or s:
Nb. Colors
B G UI Reference
B-8
Controlling the Coloration Mode
I n Wavelet 1-D tool and Continuous Wavelet tool the col or ati on of
coeffi ci ents can be done i n sever al di ffer ent ways.
Customizing Graphical Objects
I n order to customi ze your graphi cs setti ngs, you can sel ect i n al l the wi ndows
the OptionsHandles Graphics Settings menu opti on. When the Axes Settings
sub-menu opti on i s sel ected, you ar e asked to di sabl e or not the Dynami cal
Vi sual i zati on Tool (DVT), l ocated at the bottom of the wi ndow. So, after the
desi r ed customi zati on i s per formed, you must di sabl e the Axes Settings
sub-menu opti on i n or der to reacti ve the DVT.
Three parameters are used to do coefficients col-
oration:
init or current:
by level or all levels:

abs (or not):
When init is selected, coloration is per-
formed with all the coefficients values.
When current is selected, only a por-
tion of the coefficients is used to make
the coloration. This portion is taken
from the current axis limits of the dis-
played coefficients.
When by level is selected, the colora-
tion is done separately for each detail
level. Otherwise the wavelet coeffi-
cients at all levels are used to scale the
coloration.
When abs is selected, the absolute val-
ues of the coefficients are used.
Coloration mode
G eneral Features
B-9
When the sub-menu Window Settings i s enabl ed, you can edi t the cur rent fi gur e
parameter s.
When the sub-menu Axes Settings i s enabl ed, cl i cki ng wi th the mouse on an axi s
wi l l sel ect i t for edi ti ng.
B G UI Reference
B-10
When the sub-menu Texts Settings i s enabl ed, doubl e-cl i cki ng wi th the mouse
on an axi s wi l l sel ect i t for edi ti ng.
Customizing Print Settings
Usi ng the menu opti on FilePrint Settings you can access to the Print
Parameters wi ndow.
If you want to print to a file,
enter a name here.
G eneral Features
B-11
Using Menus
Al most al l the wi ndows provi de a si mi l ar str uctur e at the top of the wi ndow.
The mai n anal ysi s wi ndows have a FileDemo Analysis menu opti on whi ch
al l ows you to sel ect an exampl e of anal ysi s wi th pre-defi ned par ameters. Her e
i s an exampl e of the Wavelet 1-D tool .
The Options menu al l ows you to change the cur rent setti ngs i n your wi ndows.
B G UI Reference
B-12
Choosi ng Zoom Preferences:
Enabl i ng or di sabl i ng the gr aphi cal objects setti ngs modi fi cati on:
Choosi ng the Defaul t Di spl ay Mode you want to be used i n the fi r st di spl ay of
the Wavelet 1-D tool :
G eneral Features
B-13
The Windows menu al l ows to jump di r ectl y fr om a wi ndow to another .
B G UI Reference
B-14
Continuous Wavelet Tool Features
The Continuous Wavelet Tool has been al most compl etel y descr i bed i n the
secti on Conti nuous Anal ysi s Usi ng the Gr aphi cal I nter face on page 2-7. Here
i s an exampl e of an opti on, previ ousl y not descri bed, that al l ows you to perform
anal ysi s usi ng di ffer ent scal e modes.
The three edit boxes allow you to
specify the first scale value, the
maximum scale value and the step
size.
Default: min=2, step=2, max=32
In power 2 mode, the scale values
used are: 2
0
, ..., 2
1
, 2
k
, where k is
the popup menu value.
The scale values are the same as
those used for the discrete analysis.
This edit box allows you to specify
the scales used for the continuous
analysis, using MATLAB syntax
for the input.
W avelet 1-D Tool Features
B-15
Wavelet 1-D Tool Features
The Wavelet 1-D Tool has been al most compl etel y descri bed i n the secti on
One-Di mensi onal Anal ysi s Usi ng the Graphi cal I nter face on page 2- 22.
Her e ar e two exampl es of opti ons not cover ed pr evi ousl y.
Tree Mode
Thi s i s one of the di spl ay opti ons i n whi ch by sel ecti ng a node i n the tr ee you
can vi ew the cor respondi ng si gnal .
Her e on the l eft, the node d3 i s sel ected and the corr espondi ng detai l i s
di spl ayed under the ori gi nal si gnal .
More Display Options
Thi s opti on al l ows you to customi ze what i s di spl ayed and i s dependent on the
curr ent vi sual i zati on mode.
I n thi s exampl e for the Separate Mode, we have chosen not to di spl ay the
coeffi ci ents of appr oxi mati on for l evel s2 and 3, as wel l as the coeffi ci ents of
detai l for l evel s 4 and 5. The coeffi ci ents col or ati on mode has been changed,
B G UI Reference
B-16
and the synthesi zed si gnal i s di spl ayed i n the r i ght hand col umn, rather than
the ori gi nal si gnal .
W avelet 2-D Tool Features
B-17
Wavelet 2-D Tool Features
The Wavelet 2-D Tool has been al most compl etel y descri bed i n the secti on
Two-Di mensi onal Anal ysi s Usi ng the Graphi cal I nterface on page 2-52.
Her e i s an exampl e of an opti on that al l ows you to vi ew a sel ected part of the
wi ndow at a ful l wi ndow resol uti on.
B G UI Reference
B-18
Wavelet Packet Tool Features (1-D and 2-D)
The Wavelet Packet 1-D Tool and Wavelet Packet2-D Tool have been descr i bed
i n Chapter 5. They are al most i denti cal i n thei r l ayout and functi on. The onl y
di fference i nvol ves the extra col or ati on modes avai l abl e i n the Wavelet Packet
1-D tool , as wel l as the abi l i ty of the tool s to wor k wi th si gnal s or i mages as
appr opr i ate. Let us focus on the 1-D capabi l i ti es.
Coefficients coloration:
NAT or FRQ is for Natural or
Frequency order (see Wavelet
Packet Atoms on page 101 of
Chapter 6).
By level or Global is for a col-
oration made level by level or
taking all detail levels.
abs is used to take the absolute
values of coefficients.
Node Action:
When you select a node
in the tree, the selected
option is performed. A
complete description of
options is provided on
the next page.
Node Label:
The node labels may be
changed using the
pop-up menu. For exam-
ple, the Type option la-
bels the with (a) for
approximation and (d)
for detail.
Wavelet Packet Tool Features(1-D and 2-D)
B-19
Node Action Functionality
The avai l abl e opti ons i n the Node Action pop-up menu are:
Visualize: When you sel ect a node i n the wavel et packet tr ee the
corr espondi ng si gnal i s di spl ayed.
Split/Merge: I f a ter mi nal node i s sel ected i t i s spl i t, growi ng the wavel et
packet tree. Sel ecti ng other nodes, has the behavi or of mergi ng al l the nodes
bel ow i t i n the wavel et packet tree.
SPLI T
MERGE
B G UI Reference
B-20
Recons.: When you sel ect a node i n the wavel et packet tr ee, the corr espondi ng
reconstr ucted si gnal i s di spl ayed.
Select On/Off: When On, you can sel ect many nodes i n the wavel et packet tree
and then you can r econstruct a synthesi zed si gnal from the sel ected nodes
usi ng the Reconstruct push-button i n the mai n wi ndow. The Off sel ecti on i s
used to unsel ect al l the pr evi ous sel ected nodes.
Wavelet Packet Tool Features(1-D and 2-D)
B-21
Statistics: When you sel ect a node i n the wavel et packet tree, the Stati sti cs
Tool i s di spl ayed usi ng the si gnal cor respondi ng to the sel ected node.
View Col. Cfs.: When acti ve, thi s opti on r emoves al l the col ored coeffi ci ents
di spl ayed and l ets you redr aw onl y the cor respondi ng coeffi ci ents, by
sel ecti ng a node i n the wavel et packet tree.
B G UI Reference
B-22
Wavelet Display Tool
The Wavelet Display Tool i s menti oned i n the secti on An I ntr oducti on to the
Wavel et Fami l i es on page 30 of Chapter 1.
Here, the mai n wi ndow and the associ ated i nfor mati on wi ndows ar e di spl ayed
wi th some addi ti onal comments.
I nfor mati on on the sel ected wavel et
I nfor mati on on al l the wavel ets
This parameter decides the
precision used for the wave-
let computation. Here, func-
tions are computed over 2
8
points.
W avelet Packet Di splay Tool
B-23
Wavelet Packet Display Tool
The Wavelet Packet Display Tool i s very si mi l ar to the Wavelet Display Tool.
Her e, the mai n wi ndow and the associ ated i nfor mati on wi ndows ar e di spl ayed
wi th some addi ti onal comments.
This parameter decides the
precision used for the wave-
let computation. Here, func-
tions are computed over 2
8
points.
I nfor mati on on the sel ected wavel et I nformati on on wavel et packets
B G UI Reference
B-24
I-25
I ndex
A
Addi ng a new wavel et 7-2-7-16
Al gor i thm
Cascade 8-144
Coi fman-Wi ckerhauser 1-28, 6-112
Decomposi ti on 6-24-6-27, 6-29-6-30
Fast Wavel et Tr ansfor m (FWT) 6-21
Fi l ters 6-21-6-24
For bi or thogonal 6-29
Mal l at 1-16, 6-21
Rati onal e 6-29-6-33
Reconstr ucti on 6-26-6-29, 6-32-6-33
Al i asi ng 1-17
Anal ysi s
Bi or thogonal 6-29, 6-67-6-68
Case study 4-36-4-47
Conti nuous 1-10-1-15, 2-3-2-12, 6-15-6-16
Conti nuous or di screte 6-56
Di screte 1-16-1-19, 2-13-??, 6-15-6-16
I l l ustr ated exampl es 4-3-4-35
Local 1-5
Local and gl obal 6-16
Mul ti scal e 4-35, 4-36
One-di mensi onal di screte wavel et 2-13-??
One-di mensi onal wavel et packet 5-6-??
Or thogonal 6-21, 6-31, 6-62, 6-64
Redundant 6-16
Ti me-scal e 1-5, 1-12, 6-16
Two-di mensi onal di scr ete wavel et ??-2-65
Two-di mensi onal wavel et packet ??-5-25
Wavel et 1-5, 1-7
Wavel et Packet 5-2-??
anal ysi s
Di screte ??-2-65
Two-di mensi onal di scr ete wavel et 2-43-??
Appr oxi mati on 1-16-1-18, 6-5, 6-18-6-20
Coeffi ci ents 2-17, 2-47, 6-24-6-25
Defi ni ti on 6-3, 6-19
Qual i ty 6-18
Reconstructi on 1-21-1-22, 2-17
B
Basi s 6-29-6-32, 6-104
Bi or thogonal wavel ets 1-32, 6-67-6-68
See al so Anal ysi s
Border di storti on 6-46
Boundary val ue r epl i cati on 6-46
Peri odi c extensi on 6-46
Peri odi zed Wavel et Transform 6-55
Smooth paddi ng 6-47, 6-51, 6-55
Symmetr i c extensi on 6-49, 6-54
Symmetr i zati on 6-46
Zer o-paddi ng 6-47, 6-49, 6-52
Breakdown 3-6, 4-18-4-23, 4-25, 4-27, 4-35
Frequency 3-3-3-4, 4-10-4-11
C
Chi rp 5-7, 6-97, 6-102
Coeffi ci ents
Appr oxi mati on 2-17, 2-47, 6-24-6-25
Conti nuous Wavel et 2-5
Detai l 2-17, 2-47, 6-24-6-25
Di scr ete Wavel et 2-41, 2-64
Load 2-41, 2-64
Save 2-12, 2-39, 2-60, 5-27, 5-28
Coi fl ets 1-33, 6-66
Col orati on mode 2-11, A-3, A-6
col ormap (matr i x)
RGB components 2-66
Compressi on 2-14, 2-50, 2-58, 3-21-3-22, 5-23,
6-90
Index
I-26
Defaul t val ues 5-4, 6-93
Di fference wi th de-noi si ng 6-90
Procedur e 5-5, 6-90
Conti nuous Wavel et Transform
See Anal ysi s, Transfor m
CWT
See Tr ansfor m
D
Daubechi es wavel ets 1-31, 6-63
Decomposi ti on 1-19, 1-25, 2-24, 2-27, 6-25-6-27,
6-34, 6-41-6-42
Best 6-112
Best-l evel 6-112
Entr opy-based cr i ter i a 6-105-6-110
Hi er archi cal or gani zati on 6-11
Mul ti -step 1-25
Opti cal compari son 6-5
Opti mal 6-105-6-112
Save 2-61, 5-28
Structur e 2-64, 5-27-??, 6-34, 6-111, 6-113
Wavel et Packet 6-111
See al so Tree
Defaul t val ues
See De-noi si ng, Compr essi on
De-noi si ng 2-14, 2-19-2-21, 2-30-2-33, 3-18-3-20,
6-113
Basi c model 6-80, 6-88
Defaul t val ues 5-4, 6-93
Fi xed form thr eshol d 6-82
Geometri cal i mages 6-88
I mage 6-88
Mi ni max per for mance 6-82
Noi se si ze esti mate 6-84
Non-whi te noi se 6-84
Procedur e 5-5, 6-80
SURE esti mate 6-82
Whi te noi se 6-79
Detai l 1-16-1-18, 6-5, 6-18-6-20
Coeffi ci ents 2-17, 2-47, 6-24-6-25
Decomposi ti on 6-95-6-96
Defi ni ti on 6-3, 6-19
Ori entati on 6-27
Reconstr ucti on 1-21-1-22, 2-17
Di l ati on 1-9, 6-21
Di sconti nui ty 1-5, 3-3-3-6, 4-10, 4-20, 4-22, 6-49
See al so breakdown
Di scr ete Wavel et Tr ansfor m
See Anal ysi s, Tr ansfor m
Downsampl i ng 1-17, 6-25, 6-27
DWT
See Transform
E
Edge effects
See Border di storti on
Entr opy 1-28, 6-106-6-110
Expor ti ng fr om the GUI
Conti nuous Wavel et 2-11
Di scr ete Wavel et 2-59
F
Fast mul ti pl i cati on of l arge matr i ces 4-48
Fast Wavel et Transform (FWT)
See Transform
Fi l ter
Banks 1-16
Decomposi ti on 6-25
FI R 6-21, 6-60, 6-68, 6-73, 7-5
Hi gh-pass 6-24
Low-pass 6-24
Index
I-27
Mi ni mum phase 6-65
Quadr atur e mi r ror 1-21, 1-25, 6-23
Reconstr ucti on 1-21, 6-25
Scal i ng 6-21
Fi nger pri nt 3-21-3-22
Fouri er 1-3, 1-8
Anal ysi s 4-9, 4-11, 6-17, 6-60
Shor t-ti me anal ysi s (STFT) 1-4-1-5
Wi ndowed anal ysi s 4-11
Fractal 3-11, 6-16
Frequency 1-4-1-5, 1-13, 1-16, 2-19, 3-12
Parameter 6-102
See al so Fouri er
FWT
See Tr ansfor m
G
GUI 2-2, 5-2, 8-149, A-2-A-23
Col or ati on mode 2-11, A-3, A-6, A-8
Conti nuous wavel et 2-7
Scal e mode A-14
Customi zi ng gr aphi cal objects A-8
Ful l wi ndow resol uti on A-17
Usi ng menus A-11
Usi ng the mouse A-4
Wavel et Di spl ay A-22
Wavel et one-di mensi onal 2-22
Ful l decomposi ti on mode 2-28
More di spl ay opti ons 2-30, A-15
Separate mode 2-28
Show and scrol l mode 2-29
Super i mpose mode 2-28
Tree mode 2-28, A-15
Wavel et Packet 5-6
Coeffi ci ents col or ati on A-18
Node acti on A-18-??
Node l abel A-18
Wavel et Packet Di spl ay A-23
Wavel et two-di mensi onal 2-52
Squar e mode 2-55
Tree mode 2-56
H
Haar wavel et 1-31, 6-64
Hei senberg uncer tai nty pri nci pl e 6-17
Hi stor y 1-29
I
I DWT
See Tr ansfor m
I mage 2-62
i mage types
i ndexed 2-66
I mpor ti ng i n the GUI
Conti nuous Wavel et 2-11
Di scr ete Wavel et 2-38, 2-59
Wavel et Packet 5-26
i ndexed i mage 2-66
matri x i ndi ces, shi fti ng 2-67
L
Level 1-19, 1-22, 1-27, 2-16, 2-24, 2-27, 2-54,
6-2-6-3, 6-5
See al so Mul ti -l evel
See al so Wavel et Packet, Best l evel
Load
Coeffi ci ents 2-41, 2-64, 5-30
Index
I-28
I mage 2-62
Si gnal 2-11, 2-40, 5-29
Local
See Anal ysi s
Long-ter m evol uti on 3-8, 4-9, 4-11, 4-25, 4-27,
4-31, 4-35
M
Mathemati cal conventi ons 6-2
Mer ge
See Wavel et Packet
Mexi can hat 1-34, 6-71
Meyer wavel ets 1-35, 6-69
Mi ni max 6-82
Mi ssi ng data 4-47
Mor l et wavel et 1-34, 6-72
Mul ti -l evel 2-16, 2-18, 2-27, 2-47-2-50
Mul ti r esol uti on 6-21, 6-29-6-31
Mul ti -step 1-25
N
Noi se 2-30, 4-24-4-29, 4-32, 4-43
ARMA 4-15
Col ored 4-26
Gaussi an 6-77, 6-80
Processi ng 4-13, 4-15, 4-25, 4-27, 4-29, 6-77
Suppressi ng 3-15-3-17
See al so De-noi si ng
Unscal ed 6-84
Whi te 4-12, 4-16, 4-24, 4-28, 6-79
O
Outl i er s 4-46
P
Packet
See Wavel et Packet
Paddi ng
See Border di storti on
Per i odi zed Wavel et Tr ansfor m
See Border di storti on
Posi ti ons 1-16
Q
Quadrature mi rr or fi l ter s (QMF) 1-21, 1-25, 6-23
R
Reconstr ucti on 1-20-1-23, 1-25, 6-26, 6-29, 6-34
Approxi mati on 1-21
Detai l 1-21
Fi l ter s 1-21
Mul ti -step 1-25
Redundancy 6-56
Regul ar i ty 6-73
Defi ni ti on 6-57
Resembl ance i ndex 3-10
S
Save
Coeffi ci ents 2-12, 2-39, 2-60, 5-27-5-28
Decomposi ti on 2-61, 5-28
Synthesi zed i mage 2-60, 5-27
Synthesi zed si gnal 2-38, 5-26
Scal e 1-9, 1-14
And frequency 1-13
Choosi ng 2-6
Dyadi c 1-16, 6-2, 6-4
Scal i ng fi l ter 6-4, 6-21
Index
I-29
Scal i ng functi on 1-25, 6-3, 6-6, 6-8
Sel f-si mi l ari ty 1-6, 3-10
Shi ft 1-9-1-10
See al so Transl ati on
Shri nk
See Thr eshol di ng
Si gnal -end effects
See Bor der di stor ti on
Spl i ne 6-29, 6-63, 6-70
Spl i t
See Wavel et Packet
STFT
See Four i er
Support
See Wavel et Fami l i es
Syml ets 1-33, 6-65
Symmetr y
See Wavel et Fami l i es
Synthesi s 1-20, 6-17
T
Thr eshol di ng 2-20
Har d 6-81-6-82
Rul es 6-82-6-83
Soft 6-81
See al so De-noi si ng
Ti me-scal e
See Anal ysi s
Transform
Conti nuous ver sus di screte 6-16
Conti nuous Wavel et (CWT) 1-8, 1-10-1-12, 1-15,
6-73
Di screte Wavel et (DWT) 1-16, 6-24-6-25, 6-27,
6-73
Fast Wavel et (FWT) 6-21
I nverse (I DWT) 1-20, 6-17, 6-26, 6-29
Peri odi zed 6-55
Transi ent 1-3
See al so Breakdown
Transl ati on 6-10-6-11, A-5
Dyadi c 6-2
See al so Shi ft
Tree
Best 5-10
Best-l evel 6-112
Decomposi ti on 1-27-1-28
Mode 2-28, 2-56, A-15
Wavel et 1-19, 1-27, 6-29
Wavel et Packet 1-27, 6-95, 6-104, 6-111
Trend 1-3
See Long-term evol uti on
Twi n-scal e r el ati on 6-21, 6-31, 6-32, 6-59
U
Upsampl i ng 1-20, 6-26, 6-29
V
Vani shi ng moments 3-17, 6-57, 6-73
W
Wavel et 6-3, 6-6, 6-8
Add new 7-2-7-16
Appl i cati ons 3-1-3-22
Associ ated fami l y 6-4, 6-8-6-13
Battl e-Lemar i e 6-70
Bi or thogonal 1-32, 6-67
Candi date to be a 6-59
Coeffi ci ents 1-8
Coi fl ets 1-33, 6-66
Daubechi es 1-31, 6-63
Index
I-30
Haar 1-31, 6-64
Hi stor y of 1-29
Mexi can hat 1-34, 6-71
Meyer 1-35, 6-69
Mor l et 1-34, 6-72
One-di mensi onal capabi l i ti es 2-13, 6-34-6-39
Or der 7-4
Or gani zati on 6-13
Rel ati onshi p of fi l ters to 1-23
Shapes 6-6
Syml ets 1-33, 6-65
Transl ati on 6-2, 6-10-6-11
See al so Shi ft
Tree 1-19, 1-27, 2-28, 5-10, 6-29, 6-110
Two-di mensi onal 6-8
Two-di mensi onal capabi l i ti es 2-43, 6-40-6-45
Type 7-4
Vani shi ng moments 3-17, 6-57, 6-62, 6-73
Wavel et Fami l i es 1-30, 6-3, 6-62, 6-73
Add new 7-3
Ful l name 7-3
Proper ti es 6-73
Regul ar i ty 6-57, 6-62
Shor t name 7-3
Suppor t 6-62
Symmetry 6-62
Vani shi ng moments 6-62, 6-73, 6-74
Wavel et Packet 1-27, 5-1, 6-95-6-113
Atoms 6-101
Best l evel 1-28, 5-4, 6-112
Best tree 1-28, 5-4, 5-10, 5-17
Bui l di ng 6-98
Compr essi on 5-11, 6-113
Decomposi ti on 6-111, 6-113
De-noi si ng 5-14-??
Frequency order 6-102
From wavel ets to 6-95
Mer ge 6-105
Natural or der 6-102
Organi zati on 6-104
Spl i t 6-105
Tr ee 1-27, 6-95, 6-104, 6-111
Z
Zoom 2-9, 2-26, 2-57, 6-58

Вам также может понравиться