To my wife, and the memory of my mother ©1999 CRC Press LLC Contents 1 Haar Wavelets 1.1TheHaartransform 1.2Conservationandcompactionofenergy 1.3Haarwavelets 1.4Multiresolutionanalysis 1.5 Compressionofaudiosignals 1.6Removingnoisefromaudiosignals 1.7Notesandreferences 2 Daub echies wavelets 2.1TheDaub4wavelets 2.2Conservationandcompactionofenergy 2.3OtherDaubechieswavelets 2.4Compressionofaudiosignals 2.5 Quantization,entropy,andcompression 2.6Denoisingaudiosignals 2.7Two-dimensionalwavelettransforms 2.8Compressionofimages 2.9Fingerprintcompression 2.10Denoisingimages 2.11Sometopicsinimageprocessing 2.12Notesandreferences 3 Frequency analysis 3.1DiscreteFourieranalysis 3.2DefinitionoftheDFTanditsproperties 3.3Frequencydescriptionofwaveletanalysis 3.4Correlationandfeaturedetection 3.5 Objectdetectionin2Dimages 3.6Creatingscalingsignalsandwavelets 3.7Notesandreferences ©1999 CRC Press LLC 4 Beyond wavelets 4.1Waveletpackettransforms 4.2Applicationsofwaveletpackettransforms 4.3Continuouswavelettransforms 4.4Gaborwaveletsandspeechanalysis 4.5 Notesandreferences A Software for wavelet analysis A.1Descriptionofthebook’ssoftware A.2Installingthebook’ssoftware A.3Othersoftware References ©1999 CRC Press LLC Preface “Wavelet theory” is the result of a multidisciplinary effort that broughttogethermathematicians,physicistsandengineers...this connectionhascreatedaflowofideasthatgoeswellbeyondthe construction of new bases or transforms. St´ephane Mallat1 The past decade has witnessed an explosion of activity in wavelet anal- ysis. Thousands of research papers have been published on the theory and applications of wavelets. Wavelets provide a powerful and remark- ably flexible set of tools for handling fundamental problems in science and engineering. For an idea of the wide range of problems that are being solved using wavelets, here is a list of some of the problems discussed in this book: • Audio denoising: Long distance telephone messages often contain significant amounts of noise. How do we remove this noise in order to clarify the messages? • Signal compression: The efficient transmission of large amounts of data, over the Internet for example, requires some kind of compres- sion. Are there ways we can compress this data as much as possible without losing significant information? • Objectdetection: Whatmethodscanweusetopickoutasmallimage, sayofanaircraft,fromthemidstofalargermorecomplicatedimage? • Fingerprint compression: TheFBIhas25millionfingerprintrecords. If these fingerprint records were digitized without any compression, 1Mallat’squoteisfrom[MAL]. ©1999 CRC Press LLC theywouldgobbleup250 trillion bytesofstoragecapacity.Isthere awaytocompresstheserecordsto amanageablesize,withoutlosing anysignificantdetailsinthefingerprints? • Imagedenoising: Imagesformedbyelectronmicroscopesandbyop- ticallasersareoftencontaminatedbylargeamountsofunwanted clutter(referredtoas noise).Canthisnoiseberemovedinorderto clarifytheimage? • Imageenhancement: Whenanopticalmicroscopeimageisrecorded, itoftensuffersfromblurring.Howcantheappearanceoftheobjects intheseimagesbesharpened? • Imagerecognition: Howdohumansrecognizefaces?Canweteach machinestodoit? • Diagnosingheartt rouble: Isthereawaytodetectabnormalheart- beats,hiddenwithinacomplicatedelectrocardiogram? • Speechrecognition: Whatfactorsdistinguishconsonantsfromvowels? Howd ohumansrecognizedifferentvoices? Alloftheseproblemscanbetackledusingwavelets.Wewillshowhow duringthecourseofthisbook. InChapter1weintroducethesimplestwavelets,theHaarwavelets. Wealsointroducemanyofthebasicconcepts—wavelettransforms,en- ergyconservationandcompaction,multiresolutionanalysis,compression anddenoising—thatwillbeusedintheremainderofthebook.Forthis reason,wedevotemorepagestothetheoryofHaarwaveletsthanperhaps theydeservealone;keepinmindthatthismaterialwillbeamplifiedand generalizedthroughouttheremainderofthebook. Chapter2istheheartofthebook.Inthischapterwedescribethe Daubechieswavelets,whichhaveplayedakeyroleintheexplosionofactiv- ity in wavelet analysis. After a simple introduction to their mathematical properties we then describe several applications of these wavelets. First, we explain in detail how they can be used to compress audio signals—this application is vital to the fields of telephony and telecommunications. Sec- ond, we describe how a method known as thresholding provides a powerful technique for removing random noise (static) from audio signals. Remov- ing random noise is a fundamental necessity when dealing with all kinds of data in science and engineering. The threshold method, which is anal- ogous to how our nervous system responds only to inputs above certain thresholds, provides a nearly optimal method for removing random noise. Besides random noise, Daubechies wavelets can also be used to remove isolated “pop-noise” from audio. ©1999 CRC Press LLC Waveletanalysiscanalsobeappliedtoimages.Weshallexaminecom- pressionofimages,includingfingerprintcompression,anddenoisingo fim- ages.Theimagedenoisingexamplesthatweexamineincludesomeexam- plesmotivatedby magneticresonanceimaging (MRI)andlaserimaging. Chapter2concludeswithsomeexamplesfromimageprocessing.Wedis- cussedgedetection,andthesharpeningofblurredimages,andanexample fromcomputervisionwherewaveletmethodscanbeusedtoenormously increasethes peedofidentificationofanimage. Chapter3relateswaveletanalysistofrequencyanalysis.Frequencyanal- ysis,alsoknownas Fourieranalysis, haslongbeenoneofthecornerstones ofthemathematicsofscienceandengineering.Weshallbrieflydescribe howwaveletsarecharacterizedintermsoftheireffectsonthefrequency contentofsignals.Oneapplicationthatwediscussisobjectidentification— locatingasmallobjectwithinacomplicatedscene—wherewaveletanalysis inconcertwithFourieranalysisprovidesapowerfulapproach. Inthefinalchapterwedealwithsomeextensionswhichreachbeyondthe fundamentalsofwavelets.Wedescribe ageneralizationofwavelettrans- formsknownas waveletpackettransforms. Weapplythesewaveletpacket transformstocompressionofaudiosignals,images,andfingerprints.Then weturntothesubjectof continuouswavelettransforms ,astheyareimple- mentedinadiscreteformonacomputer.Continuouswavelettransforms arewidelyusedinseismologyandh avealsobeenusedveryeffectivelyfor analyzingspeechandelectrocardiograms. Thegoalofthisprimeristoguidethereaderthroughthemainideasof waveletanalysistofacilitateaknowledgeablereadingofthepresentresearch literature,especiallyi ntheappliedfieldsofaudioandimageprocessingand biomedicine.Althoughthereareseveralexcellentbooksonthetheoryof wavelets,thesebooksarefocusedontheconstructionofwaveletsandtheir mathematicalproperties.Furthermore,theyareallwrittenat agraduate schoollevelofmathematicaland/orengineeringexpertise.Thereis areal needforasimpleintroduction,a primer,whichusesonlyelementaryalgebra andasmidgenofcalculustoexplaintheunderlyingideasbehindwavelet analysis,anddevotesthemajorityofitspagest oexplaininghowthese underlyingideascanbeappliedtosolvesignificantproblemsinaudioand imageprocessingandinbiologyandmedicine. Tokeepthemathematicssimple,wefocuso nthediscretetheory— technicallyknownas subbandcoding. Itisinthecontinuoustheoryof waveletanalysiswherethemostdifficultmathematicslies;yetwhenthis continuoustheoryisapplieditisalmostalwaysconvertedintothediscrete approachthatwedescribeinthisprimer.Focusing onthediscretecasewill allowustoconcentrateontheapplicationsofwaveletanalysiswhileatthe sametimekeepingthemathematicsundercontrol.O ntherareoccasions whenweneedtousemoreadvancedmathematics,weshallmarkthesedis- cussionsofffromthemaintextbyputtingthemintosubsectionsthatare ©1999 CRC Press LLC marked by asterisks in their titles. An effort has been made to ensure that subsequent discussions do not rely on this more advanced material. Without question the best way, perhaps the only way, to learn about applications of wavelets is to experiment with making such applications. This experimentation is typically done on a computer. In order to simplify this computer experimentation, I have created software, called FAWAV, whichcanbedownloadedovertheInternet—seeAppendixA.FAWAVruns under WINDOWSTM 95, 98, and NT 4.0, and requires no programming to use. Further details about FAWAV can be found in Appendix A; suffice it for now to say that it is designed to allow the reader to duplicate all of the applications described in this primer and to experiment with other ideas. Thisprimerisonlyafirstintroductiontowaveletsandtheirscientificap- plications. Forthatreasonwelimitourselvestodescribingwhatareknown technically as periodic orthogonal wavelets. Other types of wavelets— biorthogonalwavelets,splinewavelets,multiwavelets,etc.—arealsousedin applications,butwefeelthattheseotherwaveletscanbeunderstoodmuch more easily if the periodic orthogonal ones are studied first. In the Notes and references sections that conclude each chapter, we provide the reader with ample references where further information on these other wavelets and many other topics can be found. Acknowledgments Itisapleasuretothankeveryonewhohasassistedmeduringthewriting of this book. First, let me mention my Executive Editor at CRC Press, Bob Stern, who first suggested the idea of this book to me and helped me to pursue it. My Series Editor, Steve Krantz, supplied several helpful crit- icisms and some much appreciated encouragement when I really needed it. GregSmethells,aformerstudentofmine,suppliedmanyhelpfulcomments on both the book manuscript and FAWAV. The students of my fall 1997 Fourier Optics course deserve recognition for putting up with some of the early versions of the image processing applications described in this book. I think their many questions and suggestions have improved my presenta- tion of these ideas. C.L. Tondo, TEX wizard, helped me overcome several difficultieswiththeLATEXsystemusedtotypesetthebook. MimiWilliams saved me from committing several grammatical errors. Beeneet Kothari, Walter Reid, and Robb Sloan provided some useful opinions on writing style. At last, a big “shei shei” to my dear wife Angela (Ching-Shiow) for hermeticulousproofreading,andforherunderstandingandsupportduring the many long days and nights spent writing this book. James S. Walker Eau Claire, Wisconsin October 28, 1998 ©1999 CRC Press LLC Chapter 1 Haar Wavelets The purpose of computing is insight, not numbers. Richard W. Hamming The purpose of computing is insight, not pictures. Lloyd N. Trefethen1 A Haar wavelet is the simplest type of wavelet. In discrete form, Haar waveletsarerelatedtoamathematicaloperationcalledtheHaartransform. The Haar transform serves as a prototype for all other wavelet transforms. Studying the Haar transform in detail will provide a good foundation for understanding the more sophisticated wavelet transforms which we shall describeinthenextchapter. InthischapterweshalldescribehowtheHaar transformcanbeusedforcompressingaudiosignalsandforremovingnoise. Ourdiscussionoftheseapplicationswillsetthestageforthemorepowerful wavelet transforms to come and their applications to these same problems. OnedistinctivefeaturethattheHaartransformenjoysisthatitlendsitself easily to simple hand calculations. We shall illustrate many concepts by both simple hand calculations and more involved computer computations. 1.1 The Haar transform In this section we shall introduce the basic notions connected with the Haar transform, which we shall examine in more detail in later sections. 1Hamming’squoteisfrom[HAM].Trefethen’squoteisfrom[TRE]. ©1999 CRC Press LLC First, we need to define the type of signals that we shall be analyzing with the Haar transform. Throughout this book we shall be working extensively with discrete sig- nals. A discrete signal is a function of time with values occurring at dis- crete instants. Generally we shall express a discrete signal in the form f =(f1,f2,...,fN), whereN isapositiveevenintegerwhichweshallrefer toasthelength off. Thevalues off aretheN realnumbersf1,f2,...,fN. These values are typically measured values of an analog signal g, measured at the time values t=t1,t2,...,tN. That is, the values of f are f1 =g(t1), f2 =g(t2), ..., fN =g(tN). (1.1) For simplicity, we shall assume that the increment of time that separates each pair of successive time values is always the same. We shall use the phraseequallyspacedsamplevalues,orjustsamplevalues,whenthediscrete signal has its values defined in this way. An important example of sample values is the set of data values stored in a computer audio file, such as a .wav file. Another example is the sound intensity values recorded on a compact disc. A non-audio example, where the analog signal g is not a sound signal, is a digitized electrocardiogram. Like all wavelet transforms, the Haar transform decomposes a discrete signal into two subsignals of half its length. One subsignal is a running average or trend; the other subsignal is a running difference or fluctuation. Let’s begin by examining the trend subsignal. The first trend subsignal, a1 = (a1,a2,...,aN/2), for the signal f is computed by taking a running average in the following way. Its first value, a1, is computed by taking the ave√rage of the first pair of value√s of f: (f1+f2)/2, and then multiplying it by 2. Thatis,a1 =(f1+f2)/ 2. Similarly,itsnextvaluea2 iscomputed by taking the aver√age of the next pair of values√of f: (f3+f4)/2, and then multiplying it by 2. That is, a2 =(f3+f4)/ 2. Continuing in this way, allofthevaluesofa1 areproducedbytakingaverage√sofsuccessivepairsof values of f, and then multiplying these averages by 2. A precise formula for the values of a1 is am = f2m−√1+f2m , (1.2) 2 for m=1,2,3,...,N/2. For example, suppose f is defined by eight values, say f =(4,6,10,12,8,6,5,5); √ √ √ √ then its first trend subsignal is a1 = (5 2,11 2,7 2,5 2). This result can be obtained using Formula (1.2). Or it can be calculated as indicated ©1999 CRC Press LLC