Published on

Wavelet transform examples

Published in: Technology


  1. 1. % Load original 1-D signal.  load sumsin; s = sumsin;  % Perform the decomposition of s at level 5, using coif3.  w = coif3  [c,l] = wavedec(s,5,w);  % Reconstruct the approximation signals and detail signals at % levels 1 to 5, using the wavelet decomposition structure [c,l]. for i = 1:5  A(i,:) = wrcoef(a,c,l,w,i);  D(i,:) = wrcoef(d,c,l,w,i); end   % Plots.  t = 100:900;  subplot(6,2,1); plot(t,s(t),r);  title(Orig. signal and approx. 1 to 5.);  subplot(6,2,2); plot(t,s(t),r);  title(Orig. signal and details 1 to 5.);  for i = 1:5,  subplot(6,2,2*i+1); plot(t,A(5-i+1,t),b);  subplot(6,2,2*i+2); plot(t,D(5-i+1,t),g);  end 
  2. 2. DWT Single-level discrete 1-D wavelet transform. DWT performs a single-level 1-D wavelet decomposition with respect to either a particular wavelet (wname, see WFILTERS for more information) or particular wavelet filters (Lo_D and Hi_D) that you specify. [CA,CD] = DWT(X,wname) computes the approximation coefficients vector CA and detail coefficients vector CD, obtained by a wavelet decomposition of the vector X. wname is a string containing the wavelet name. [CA,CD] = DWT(X,Lo_D,Hi_D) computes the wavelet decomposition as above given these filters as input: Lo_D is the decomposition low-pass filter. Hi_D is the decomposition high-pass filter. Lo_D and Hi_D must be the same length.
  3. 3. Let LX = length(X) and LF = the length of filters; then length(CA) = length(CD) = LA where LA = CEIL(LX/2), if the DWT extension mode is set to periodization. LA = FLOOR((LX+LF-1)/2) for the other extension modes. For the different signal extension modes, see DWTMODE. [CA,CD] = DWT(...,mode,MODE) computes the wavelet decomposition with the extension mode MODE you specify. MODE is a string containing the extension mode. Example: x = 1:8; [ca,cd] = dwt(x,db1,mode,sym)
  4. 4. The MATLAB® code needed to generate s, cD, and cA iss = sin(20.*linspace(0,pi,1000)) + 0.5.*rand(1,1000);[cA,cD] = dwt(s,db2);where db2 is the name of the wavelet we want to use for theanalysis.Notice that the detail coefficients cD are small and consist mainly ofa high-frequency noise, while the approximation coefficients cAcontain much less noise than does the original signal.[length(cA) length(cD)] ans = 501 501
  5. 5. You may observe that the actual lengths ofthe detail and approximation coefficientvectors are slightly more than half the lengthof the original signal. This has to do with thefiltering process, which is implemented byconvolving the signal with a filter. Theconvolution "smears" the signal, introducingseveral extra samples into the result.
  6. 6. Multistep Decomposition andReconstruction
  7. 7. This process involves two aspects: breaking up a signal to obtain the wavelet coefficients, and reassembling the signal from thecoefficients. Weve already discussed decomposition and reconstruction at somelength. Of course, there is no point breaking up a signal merely tohave the satisfaction of immediately reconstructing it. We maymodify the wavelet coefficients before performing the reconstructionstep. We perform wavelet analysis because the coefficients thusobtained have many known uses, de-noising and compression beingforemost among them.But wavelet analysis is still a new and emerging field. No doubt, many uncharted uses of the wavelet coefficients lie in wait. Thetoolbox can be a means of exploring possible uses and hithertounknown applications of wavelet analysis. Explore the toolboxfunctions and see what you discover.
  8. 8. Wavelet Packet AnalysisThe wavelet packet method is a generalization of wavelet decomposition that offers a richer range ofpossibilities for signal analysis. In wavelet analysis, a signal is split into anapproximation and a detail. The approximation is thenitself split into a second-level approximation and detail,and the process is repeated. For an n-leveldecomposition, there are n+1 possible ways todecompose or encode the signal.
  9. 9. In wavelet packet analysis, the detailsas well as the approximations can besplit.
  10. 10. For instance, wavelet packet analysis allows the signal S to be represented as A1 + AAD3 + DAD3 +DD2. This is an example of a representation that isnot possible with ordinary wavelet analysis.Choosing one out of all these possible encodingspresents an interesting problem. In this toolbox, weuse an entropy-based criterion to select the mostsuitable decomposition of a given signal. This meanswe look at each node of the decomposition tree andquantify the information to be gained by performingeach split.
  11. 11. Simple and efficient algorithms exist for both waveletpacket decomposition and optimal decompositionselection. This toolbox uses an adaptive filteringalgorithm, based on work by Coifman andWickerhauser (see [CoiW92] in References), with directapplications in optimal signal coding and datacompression.Such algorithms allow the Wavelet Packet 1-D andWavelet Packet 2-D tools to include "Best Level" and"Best Tree" features that optimize the decompositionboth globally and with respect to each node.
  12. 12. Introduction to the Wavelet FamiliesSeveral families of wavelets that haveproven to be especially useful areincluded in this toolbox. What followsis an introduction to some waveletfamilies.
  13. 13. HaarDaubechiesBiorthogonal CoifletsSymletsMorletMexican Hat MeyerOther Real Wavelets Complex Wavelets
  14. 14. HaarAny discussion of wavelets beginswith Haar wavelet, the first andsimplest. Haar wavelet isdiscontinuous, and resembles a stepfunction. It represents the samewavelet as Daubechies db1. See Haarfor more detail.
  15. 15. >> mkdir C:worksl_hdlcoder_work>> [cA1,cD1] = dwt(s,db4);>> [cA1,cD1] = dwt(s,db12);>> [cA2,cD2] = dwt(s,haar);>> plot(cA2)>> plot(cD2)
  16. 16. cA2 plot
  17. 17. cD2 plot
  18. 18. DaubechiesIngrid Daubechies, one of the brightest stars in theworld of wavelet research, invented what are calledcompactly supported orthonormal wavelets -- thusmaking discrete wavelet analysis practicable.The names of the Daubechies family wavelets arewritten dbN, where N is the order, and db the"surname" of the wavelet. The db1 wavelet, asmentioned above, is the same as Haar wavelet. Hereare the wavelet functions psi of the next nine membersof the family:
  19. 19. You can obtain a survey of the main properties of this family by typingwaveinfo(db) from the MATLAB command line. See Daubechies Wavelets: dbN for more detail.
  20. 20. dbN
  21. 21. waveinfo(db)General characteristics: Compactly supported wavelets with extremal phase and highest number of vanishing moments for a given support width. Associated scaling filters are minimum-phase filters. Family Daubechies Short name db Order N N strictly positive integer Examples db1 or haar, db4, db15 Orthogonal yes Biorthogonal yes Compact support yes DWT possible CWT possible
  22. 22. BiorthogonalThis family of wavelets exhibits theproperty of linear phase, which isneeded for signal and imagereconstruction. By using twowavelets, one for decomposition (onthe left side) and the other forreconstruction (on the right side)instead of the same single one,interesting properties are derived.
  23. 23. You can obtain a survey of the main properties of this family by typingwaveinfo(bior) from the MATLAB command line. See Biorthogonal Wavelet Pairs: biorNr.Nd for more detail.
  24. 24. CoifletsBuilt by I. Daubechies at the request of R.Coifman. The wavelet function has 2Nmoments equal to 0 and the scaling functionhas 2N-1 moments equal to 0. The twofunctions have a support of length 6N-1. Youcan obtain a survey of the main properties ofthis family by typing waveinfo(coif) from theMATLAB command line. See Coiflet Wavelets:coifN for more detail.
  25. 25. SymletsThe symlets are nearly symmetricalwavelets proposed by Daubechies asmodifications to the db family. Theproperties of the two wavelet familiesare similar. Here are the waveletfunctions psi.
  26. 26. You can obtain a survey of the main properties of this family by typingwaveinfo(sym) from the MATLAB command line. See Symlet Wavelets: symN for more detail.
  27. 27. MorletThis wavelet has no scaling function,but is explicit.
  28. 28. You can obtain a survey of the mainproperties of this family by typingwaveinfo(morl) from the MATLABcommand line. See Morlet Wavelet:morl for more detail.
  29. 29. Mexican HatThis wavelet has no scaling functionand is derived from a function that isproportional to the second derivativefunction of the Gaussian probabilitydensity function.
  30. 30. You can obtain a survey of the main properties of this family by typingwaveinfo(mexh) from the MATLAB command line. See Mexican Hat Wavelet: mexh for more information.
  31. 31. MeyerThe Meyer wavelet and scalingfunction are defined in the frequencydomain.
  32. 32. You can obtain a survey of the main properties of this family by typingwaveinfo(meyer) from the MATLAB command line. See Meyer Wavelet: meyr for more detail.
  33. 33. Other Real WaveletsSome other real wavelets areavailable in the toolbox:Reverse BiorthogonalGaussian derivatives familyFIR based approximation of the MeyerwaveletSee Additional Real Wavelets for moreinformation.
  34. 34. Complex WaveletsSome complex wavelet families areavailable in the toolbox:Gaussian derivativesMorletFrequency B-SplineShannonSee Complex Wavelets for moreinformation.