Professional Documents
Culture Documents
Contents 1. Analysis and Synthesis of Signals 2. Time-Frequency Analysis 2.1 The Short Time Fourier Transform 2.2 The spectrogram 2.3 An Orthgonal Basis of Functions 3. Time-Scale Analysis 3.1 The Continuous Wavelet Transform 3.2 Comparision with STFT 3.3 The Scalogram 3.4 Examples of Wavelets 3.5 Analysis and Synthesis with Wavelets 3.6 The Haar Wavelet 4. Multiresolution Analysis 4.1 The Scaling Function 4.2 The Discrete Wavelet Transform 5. Filter Banks and the Discrete Wavelet Transform 5.1 Analysis: From Fine Scale to Coarser Scale 5.1.1 Filtering and Downsampling 5.1.2 The One-Stage Analysis Filter Bank 5.1.3 The Analysis Filter Bank 5.2 Synthesis: From Course Scale to Fine Scale 5.2.1 Upsampling and Filtering 5.2.2 The One-Stage Synthesis Filter Bank 5.2.3 Perfect Reconstruction Filter Bank 5.2.4 The Synthesis Filter Bank 5.2.5 Approximations and Details 5.3 Numerical Complexity of the Discrete Wavelet Transform 5.4 Matlab Examples 5.4.1 One-Stage Perfect Reconstruction 5.4.2 Approximations and Details 5.4.3 A Useful Function 5.5 Initialization of the Discrete Wavelet Transform 6. Properties of the Filters, and the Scale and Wavelet Functions 6.1 Double Shift Orthogonality of the Filters 6.2 Frequency Domain Formulas 6.3 Support of the Scale Function 6.4 The Cascade Algorithm 7. Designing Wavelets 7.1 Short Filters 7.1.1 Length 2 Filter
http://www.engmath.dal.ca/courses/engm6610/notes/notes.html
24-04-2006
Pgina Web 2 de 2
7.1.2 Length 4 Filter 7.1.3 Length 6 Filter 7.2 K-Regular Scaling Filters 7.2.1 The db2 Wavelet 7.2.2 The db3 Wavelet 7.3 Characterizing K-Regular Filters 7.4 The Daubechies Maximally Flat Polynomial 7.4.1 Factoring the Daubechie Maximally Flat Polynomial 7.5 Coiflets 7.5.1 Coif1 7.5.2 Coif2 About this document ...
http://www.engmath.dal.ca/courses/engm6610/notes/notes.html
24-04-2006
Pgina Web 1 de 1
Next: 1. Analysis and Synthesis Up: Wavelets and Filter Banks Previous: Wavelets and Filter Banks
Contents
Contents 1. Analysis and Synthesis of Signals 2. Time-Frequency Analysis 2.1 The Short Time Fourier Transform 2.2 The spectrogram 2.3 An Orthgonal Basis of Functions 3. Time-Scale Analysis 3.1 The Continuous Wavelet Transform 3.2 Comparision with STFT 3.3 The Scalogram 3.4 Examples of Wavelets 3.5 Analysis and Synthesis with Wavelets 3.6 The Haar Wavelet 4. Multiresolution Analysis 4.1 The Scaling Function 4.2 The Discrete Wavelet Transform 5. Filter Banks and the Discrete Wavelet Transform 5.1 Analysis: From Fine Scale to Coarser Scale 5.2 Synthesis: From Course Scale to Fine Scale 5.3 Numerical Complexity of the Discrete Wavelet Transform 5.4 Matlab Examples 5.5 Initialization of the Discrete Wavelet Transform 6. Properties of the Filters, and the Scale and Wavelet Functions 6.1 Double Shift Orthogonality of the Filters 6.2 Frequency Domain Formulas 6.3 Support of the Scale Function 6.4 The Cascade Algorithm 7. Designing Wavelets 7.1 Short Filters 7.2 K-Regular Scaling Filters 7.3 Characterizing K-Regular Filters 7.4 The Daubechies Maximally Flat Polynomial 7.5 Coiflets
http://www.engmath.dal.ca/courses/engm6610/notes/node1.html
24-04-2006
Pgina Web 1 de 7
Next: 2. Time-Frequency Analysis Up: Wavelets and Filter Banks Previous: Contents Contents
This should remind us of vectors. In fact if we take samples of the signal at times
times
as a sort of dot product of the two signals. . We define the inner product of
Note that the analogy is not exact except in the limit where two signals as:
If
and
in computing the
inner product:
Note that in the wedge bracket notation for the inner product the variable is not necessary as the integration is over the variable . We use this notation so that we can write things like . In analogy with the length of a vector we define the norm of a the signal to be:
Note that the square of the norm of a signal is the energy in the siganl (think of the signal as a voltage driving a 1 ohm resistor).
http://www.engmath.dal.ca/courses/engm6610/notes/node2.html
24-04-2006
Pgina Web 2 de 7
and
to be orthogonal if
Orthogonal Vectors in the Plane There is a simple formula for resolving a vector, vectors and . Recall that we can project , in the plane in terms of a a pair of orthogonal
and
obtaining multiples
and
This geometric construction can be obtained through dot products. By taking the dot product of first with we have:
with
we have:
http://www.engmath.dal.ca/courses/engm6610/notes/node2.html
24-04-2006
Pgina Web 3 de 7
Recall that we say that the vectors plane. When we compute the coefficients the basis and .
and
and
in terms of
When we express the vector as the basis. That is, we have two processes going on:
Orthogonal Basis of Signals In the case of signals we say that a set of signals values like from to
(where
1. The signals are mutually orthgonal. That is, 2. The signals are complete in the sense that the only signal, is the zero signal. That is, if for all
Generalized Analysis and Synthesis Given an orthogonal basis of signals and synthesize the signal back again:
http://www.engmath.dal.ca/courses/engm6610/notes/node2.html
24-04-2006
Pgina Web 4 de 7
equation is called the Generalized Fourier Series. To see that the Generalized Fourier Series does converge to the original signal let's call the signal which it does converge to . That is,
Parseval's Theorem The energy in the signal can be obtained from the Generalized Fourier Coefficents just as in the case of Fourier Series.
That is,
where
http://www.engmath.dal.ca/courses/engm6610/notes/node2.html
24-04-2006
Pgina Web 5 de 7
The functions
Note that the functions . Example: Cosine Basis If we have defined on orthgonal basis of functions on
http://www.engmath.dal.ca/courses/engm6610/notes/node2.html
24-04-2006
Pgina Web 6 de 7
completes
cycles on the
Example: 1/4 Cycle Cosine Basis Given defined on we can extend extend oddly across Series ( and
evenly to
terms of even frequency have zero amplitude. This gives an orthogonal basis of functions on given by:
Note that
completes 1/4 of a cycle on the interval. To simplify the notation let's define:
completes
cycles on
http://www.engmath.dal.ca/courses/engm6610/notes/node2.html
24-04-2006
Pgina Web 7 de 7
Example: Sinc Basis The Shannon Sampling Theorem gives an orthogonal basis of sinc functions. Recall that if band limited to Hz and we take samples of with a sampling interval then
is
To see that this is the Analysis/Synthesis formula in terms of inner products, recall that we have the Fourier Transform pair:
So,
Using the fact that the Fourier Transform preserves inner products we can show that the sinc functions are orthogonal.
Next: 2. Time-Frequency Analysis Up: Wavelets and Filter Banks Previous: Contents Contents Dr. W. J. Phillips 2003-04-03
http://www.engmath.dal.ca/courses/engm6610/notes/node2.html
24-04-2006
Pgina Web 1 de 8
Next: 3. Time-Scale Analysis Up: Wavelets and Filter Banks Previous: 1. Analysis and Synthesis Contents Subsections 2.1 The Short Time Fourier Transform 2.2 The spectrogram 2.3 An Orthgonal Basis of Functions
2. Time-Frequency Analysis
In many applications such as speech processing, we are interested in the frequency content of a signal locally in time. That is, the signal parameters (frequency content etc.) evolve over time. Such signals are called non-stationary. For a non-stationary signal, , the standard Fourier Transform is not useful for analyzing the signal. Information which is localized in time such as spikes and high frequency bursts cannot be easily detected from the Fourier Transform. Time-localization can be achieved by first windowing the signal so as to cut off only a well-localized slice of and then taking its Fourier Transform. This gives rise to the Short Time Fourier Transform, (STFT) or Windowed Fourier Transform. The magnitude of the STFT is called the spectrogram. By restricting to a discrete range of frequencies and times we can obtain an orthogonal basis of functions.
the usual Fourier Transform of the product function width 1/2 then we have (see the Matlab m-file fig1.m):
http://www.engmath.dal.ca/courses/engm6610/notes/node3.html
24-04-2006
Pgina Web 2 de 8
In the frequency domain we can use the convolution theorem to recognize convolution of with the Fourier transform of (which is ).
as the
is a box of width
, that is,
then
are at multiple of
In the case where the signal is a pure sinusoid of frequency sinc function shifted by has frequency
the windowed
transform will be the superposition of two shifted sinc functions. The individual frequencies cannot
http://www.engmath.dal.ca/courses/engm6610/notes/node3.html
24-04-2006
Pgina Web 3 de 8
be resolved unless .
. Hz and
In the following figure a signal is the sum of two sinusoids with frequencies Hz. The window size is (see fig2.m).
In the case where the signal consists of two spikes close together in time we can resolve the spikes if the window size is smaller that the time difference between the spikes. This analysis shows the ``trade-off'' between time resolution and frequency resolution: if we use a window of length then we have a ``time-resolution'' of but our frequency resolution is .
http://www.engmath.dal.ca/courses/engm6610/notes/node3.html
24-04-2006
Pgina Web 4 de 8
plots. In the following example, (see fig3.m) a signal and window width of ms (
http://www.engmath.dal.ca/courses/engm6610/notes/node3.html
24-04-2006
Pgina Web 5 de 8
we can can resolve both the sinusoids and the impulses. Now suppose that we move the two frequencies closer together. Let's use a signal sum of two sinusoids of frequencies ms and and which is the
As the spectrograms now show we cannot resolve the frequencies but we can still resolve the spikes.
http://www.engmath.dal.ca/courses/engm6610/notes/node3.html
24-04-2006
Pgina Web 6 de 8
Now suppose that we change the window size to ms. As the spectrograms below show, we can resolve the frequencies but not the spikes (see fig4cd.m).
http://www.engmath.dal.ca/courses/engm6610/notes/node3.html
24-04-2006
Pgina Web 7 de 8
http://www.engmath.dal.ca/courses/engm6610/notes/node3.html
24-04-2006
Pgina Web 8 de 8
Then we have:
Since functions.
Because we have analysis and synthesis on each interval analysis and synthesis in general. That is:
to
In summary, if we restrict the STFT calculation to a discrete set of frequencies and times we can regard the STFT values as the coordinates of our signal with respect to an orthogonal basis. Hence we can recover our signal from these STFT values.
Next: 3. Time-Scale Analysis Up: Wavelets and Filter Banks Previous: 1. Analysis and Synthesis Contents Dr. W. J. Phillips 2003-04-03
http://www.engmath.dal.ca/courses/engm6610/notes/node3.html
24-04-2006
Pgina Web 1 de 13
Next: 4. Multiresolution Analysis Up: Wavelets and Filter Banks Previous: 2. Time-Frequency Analysis Contents Subsections 3.1 The Continuous Wavelet Transform 3.2 Comparision with STFT 3.3 The Scalogram 3.4 Examples of Wavelets 3.5 Analysis and Synthesis with Wavelets 3.6 The Haar Wavelet
3. Time-Scale Analysis
The Continous Wavelet Transform (CWT) provides a time-scale description similar to the STFT with a few important differences: Frequency is related to scale which may have a better relationship to the problem at hand. The CWT is able to resolve both time and scale (frequency) events better than the STFT. By restricting to a discrete set of paramaters we get the Discrete Wavelet Transform (DWT) which corresponds to an orthogonal basis of functions all derived from a single function called the mother wavelet. The basis functions in the DWT are not solutions of differential equations as in the Fourier case. The basis functions are ``near optimal'' for a wide class of problems. This means that the analysis coefficients drop off rapidly. There is a connection and equivalence to filter bank theory from DSP which leads to a computationally efficient algorithm. The computational complexity of the FFT is while that of the DWT is .
and
is called the (mother) wavelet. It is taken to be a ``small wave''. For example, the
http://www.engmath.dal.ca/courses/engm6610/notes/node4.html
24-04-2006
Pgina Web 2 de 13
Haar wavelet is a single cycle of the square wave of period 1. The morlet wavelet has formula:
by a the factor
, called the
scale, and shifting in time by . The time-shifted and time-scaled wavelet is sometimes called a baby wavelet. The figure below shows a signal shifts (see fig5.m). The subsequent figure shows a signal (see fig6.m). along with the morelet wavelet at three scales and shifts along with the Haar wavelet with two different scales and
http://www.engmath.dal.ca/courses/engm6610/notes/node4.html
24-04-2006
Pgina Web 3 de 13
We can think of the CWT in different ways: 1. The CWT is the inner product or cross correlation of the signal shifted wavelet with the scaled and time
between signal and the scaled and shifted wavelet. It is this point of view that is illustrated in the figures above. 2. For a fixed scale, wavelet , the CWT is the convolution of the signal . with the time reversed
That is, the CWT is the output when we feed our signal to the filter with with impulse response .
It is this filter point of view which will show the connection to STFT
http://www.engmath.dal.ca/courses/engm6610/notes/node4.html
24-04-2006
Pgina Web 4 de 13
We use the variable, , for frequency so that later when we take the Fourier Transform we avoid confusing this frequency variable with the usual one in the transform. Aside from the initial phase factor, , this last equation is the convolution of the signal, . That is, ,
To understand the significance of the filter interpretations of CWT and STFT we can consider the case of the Morlet wavelet, , and the STFT with gaussian window function, . The Fourier Transform of the gaussian window function is: . Note that this
is a window function in the frequency domain. It is a low pass filter which blocks all frquencies above
http://www.engmath.dal.ca/courses/engm6610/notes/node4.html
24-04-2006
Pgina Web 5 de 13
The frequency response of the filter in the STFT is this transform shifted by frequency . That is, . This is a band pass filter centered at frquency and of approximate width 1 Hz. That is, computing the spectrogram of a signal using a Gaussian window function is the same as passing the signal through a series of bandpass filters of constant bandwidth 1 Hz. In the case of the CWT the frequency repsonse of the filter when the scale, , is: This is a band pass filter centered at frquency Hz with bandwidth 1 Hz. At scale the frequency response is with a bandwidth of Hz. . This is band pass
http://www.engmath.dal.ca/courses/engm6610/notes/node4.html
24-04-2006
Pgina Web 6 de 13
That is, computing the CWT of a signal using the Morlet wavelet is the same as passing the . signal through a series of bandpass filters centered at with constant Q of This shows the essential difference between the STFT and the CWT. In the STFT the frquency bands have a fixed width (1 Hz for Gaussian). In the CWT the frequency bands grow and shrink with the frequency (scale) being used. This allows good frequency resolution at low frequencies and good time resolution at high frequencies.
http://www.engmath.dal.ca/courses/engm6610/notes/node4.html
24-04-2006
Pgina Web 7 de 13
to frequency,
. We can make a
To see clearly that the frequencies are resolved by the scalograms we can make a 3 dimensional plot.
http://www.engmath.dal.ca/courses/engm6610/notes/node4.html
24-04-2006
Pgina Web 8 de 13
http://www.engmath.dal.ca/courses/engm6610/notes/node4.html
24-04-2006
Pgina Web 9 de 13
The Haar Wavelet The Haar wavelet and its Fourier Transform are:
The Mexican Hat Wavelet The Mexican Hat wavelet and its Fourier Transform are:
http://www.engmath.dal.ca/courses/engm6610/notes/node4.html
24-04-2006
Pgina Web 10 de 13
The Shannon Wavelet The Shannon wavelet and its Fourier Transform are:
Pgina Web 11 de 13
Recall that with the STFT we obtained an orthogonal basis of functions by choosing equally spaced frequency and time samples . This does not apply in general. To ensure the orthogonality we chose the window function to be the box of width .
In some cases we can get an orthogonal basis of functions in the CWT case by choosing the scales to be powers of 2 and the times to be an integer multiple of the scales. That is, for integers and we consider:
To simplify the notation we define a doubly indexed set of baby wavelets as follows:
There is a large class of wavelet functions for which the the set of baby wavelets is an orthogonal basis. These are the orthogonal wavelets. the simplest of these is the Haar wavelet. In the case of an orthogonal wavelet the analysis formula is called the Discrete Wavelet Transform.
The recovery of the signal through the synthesis formula is called the Inverse Discrete Wavelet Transform.
Note that the Time-Scale Diagram for the Discrete Wavelet Transform is a a set of samples of the Time-Scale Diagram for the Continuous Wavelet Transform. The samples are quite ``sparse'' for large scale and more ``dense'' for small scale.
http://www.engmath.dal.ca/courses/engm6610/notes/node4.html
24-04-2006
Pgina Web 12 de 13
Then,
is to make the energy of the signal 1. is a single cycle of a square wave extending from time and to of the same scale, .
From this description it is easy to see that baby Haar wavelets, , but different positions and
http://www.engmath.dal.ca/courses/engm6610/notes/node4.html
24-04-2006
Pgina Web 13 de 13
It is also true that Haar baby wavelets of differnt scales are orthogonal. To see this it is best to first consider the case of and . Since positive to negative while it follows (see the figure below) that completes its cycle from
and
cycle from 1 to -1 while the other is constant. This shows that these two are orthogonal. The other property of an orthogonal basis is that of completeness. We will see later that the Haar baby wavelets are complete.
Next: 4. Multiresolution Analysis Up: Wavelets and Filter Banks Previous: 2. Time-Frequency Analysis Contents Dr. W. J. Phillips 2003-04-03
http://www.engmath.dal.ca/courses/engm6610/notes/node4.html
24-04-2006
Pgina Web 1 de 13
Next: 5. Filter Banks and Up: Wavelets and Filter Banks Previous: 3. Time-Scale Analysis Contents Subsections 4.1 The Scaling Function 4.2 The Discrete Wavelet Transform
4. Multiresolution Analysis
We would like to find wavelets, wavelets, , with the same properties as the Haar case. That is, The baby , for all and , form an orthogonal basis. This implies that we
Such wavelets give rise to a Multiresolution Analysis derived as follows. Define to be set of all signals, , which can be synthesized from the baby wavelets ,
. These spaces are orthogonal to each other and we can synthesize any (energy) signal, as (Note that in the following formula is in the space ):
There is another way to express this idea. Define synthesized from the baby wavelets where
, which can be
. That is
http://www.engmath.dal.ca/courses/engm6610/notes/node5.html
24-04-2006
Pgina Web 2 de 13
The spaces
As As
goes to infinity
).
shrinks down to only the zero signal. is a sum of a signal in and because:
are the differences (in the subspace sense) between adjacent spaces
and
as follows:
The term Multiresolution Analysis refers to analyzing signals in relation to this nested sequence of subspaces. To get a better idea of multiresolution analysis, let's decompose a signal, We can use the breakdown: , in a few times.
http://www.engmath.dal.ca/courses/engm6610/notes/node5.html
24-04-2006
Pgina Web 3 de 13
Where at level .
, in
and
, in
Example: This decompostion can be carried out in Matlab using the wavemenu interface. There are a number of sample signals which can be used for a demo analysis. The signal sumsin is a sum of two sine waves. In the following figures we decompose the signal 4 times as above.
http://www.engmath.dal.ca/courses/engm6610/notes/node5.html
24-04-2006
Pgina Web 4 de 13
http://www.engmath.dal.ca/courses/engm6610/notes/node5.html
24-04-2006
Pgina Web 5 de 13
Note that different aspects of the signal appear in the details and the approximations. The spaces have a very important property related to time compression by factors of 2. is in the space if and only if
Investigation of the multiresolution analysis leads to a scaling function, a pair of discrete time filters, and a perfect reconstruction filter bank which can be used to calculate the DWT quickly.
where
and
Just as for the wavelet, the ``scale'' of We want to find functions Since the spaces ,
In the Haar case the scaling function is the unit box delayed by
http://www.engmath.dal.ca/courses/engm6610/notes/node5.html
24-04-2006
Pgina Web 6 de 13
Then
to note that:
By a similar formula we can synthesize The Two Scale Equation and the Filters
from
There is an important formula connecting the scale function to itself at two different time scales. This fundamental formula is called the Two Scale Equation and it gives rise to one of the filters. There are discrete time filter coefficients such that:
This follows trivially from the assumption that equation involving the scale function. Since is also a subset of
there is another two scale equation for the wavelet which gives rise
to another filter
, such that:
Example: Haar Case In the Haar case, the scale function is the box of width 1 extending from time 0 to time 1. It follows that is the box of width 1/2 extending from time 0 to time 1/2.
http://www.engmath.dal.ca/courses/engm6610/notes/node5.html
24-04-2006
Pgina Web 7 de 13
Similarily,
is the box of width 1/2 extending from time 1/2 to time 1. . That is,
http://www.engmath.dal.ca/courses/engm6610/notes/node5.html
24-04-2006
Pgina Web 8 de 13
Assuming the existence of a scaling function, Since the spaces are getting larger and larger as
we can now modify this defintion as follows. goes to we can approximate any signal, using the
http://www.engmath.dal.ca/courses/engm6610/notes/node5.html
24-04-2006
Pgina Web 9 de 13
After this approximation our signal is now in and with their bases
and we can decompose it using the subspaces and . Note that the scale is getting larger
in
and
in
we have:
As before, we call the signals We call the coefficients at level 1. We can further decompose and
and
the approximation and detail at level 1. the approximation coefficients and the detail coeffients
to get:
and and
the approximation and detail at level 2. the approximation coefficients and the detail coeffients
http://www.engmath.dal.ca/courses/engm6610/notes/node5.html
24-04-2006
Pgina Web 10 de 13
We can continue in this way to decompose our signal further and further. In terms of coefficients we have (using [...] to indicate vectors as in Matlab):
The calculations of the coefficients can be carried out in Matlab using the dwt (Discrete Wavelet Transform) command. The signal can be recovered from the coefficinets using the idwt (Inverse Discrete Wavelet Transform) command. The Matlab implementation uses the filters is done in the next section. The continuous time meaning of the decomposition can be visualized as follows: and previously mentioned. We shall see how this
Matlab Example: The Matlab routines used in this example will be discussed in the next section. In this example we will decompose a speech signal using the Haar wavelet and a 4 level decomposition. This signal is the word ``two'' sampled at 8000 samples per second.
http://www.engmath.dal.ca/courses/engm6610/notes/node5.html
24-04-2006
Pgina Web 11 de 13
http://www.engmath.dal.ca/courses/engm6610/notes/node5.html
24-04-2006
Pgina Web 12 de 13
http://www.engmath.dal.ca/courses/engm6610/notes/node5.html
24-04-2006
Pgina Web 13 de 13
Next: 5. Filter Banks and Up: Wavelets and Filter Banks Previous: 3. Time-Scale Analysis Contents Dr. W. J. Phillips 2003-04-03
http://www.engmath.dal.ca/courses/engm6610/notes/node5.html
24-04-2006
Pgina Web 1 de 21
Next: 6. Properties of the Up: Wavelets and Filter Banks Previous: 4. Multiresolution Analysis Contents Subsections 5.1 Analysis: From Fine Scale to Coarser Scale 5.1.1 Filtering and Downsampling 5.1.2 The One-Stage Analysis Filter Bank 5.1.3 The Analysis Filter Bank 5.2 Synthesis: From Course Scale to Fine Scale 5.2.1 Upsampling and Filtering 5.2.2 The One-Stage Synthesis Filter Bank 5.2.3 Perfect Reconstruction Filter Bank 5.2.4 The Synthesis Filter Bank 5.2.5 Approximations and Details 5.3 Numerical Complexity of the Discrete Wavelet Transform 5.4 Matlab Examples 5.4.1 One-Stage Perfect Reconstruction 5.4.2 Approximations and Details 5.4.3 A Useful Function 5.5 Initialization of the Discrete Wavelet Transform
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 2 de 21
We start with the coefficients and coefficients index at scale index and
at scale index
(Analysis). Alternately, we can start with the two sets of and produce the coefficients at scale
at scale index
(Synthesis).
We can show that the two operations of Analysis and Synthesis are produced by certain filter banks. As the wavelets and the scales at each index level are orthogonal we can compute the coefficients and by the usual inner product formula:
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 3 de 21
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 4 de 21
To understand the approximation and detail formulas it will help to define the time reversed filters and . We temporarily use to see the convolution.
If we follow this filter by the downsampler we get the approximation coefficients at the next level.
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 5 de 21
The same calculation holds for the detail coefficients. That is, convolution with the time reversed filter followed by downsampling produces the detail coefficients at the next level.
The dwt command in the Wavelet toolbox of Matlab carries out the calculations in this one stage filter bank. The syntax is:
[cA, cD] = dwt(x, Lo, Hi); = dwt(x, 'wname');
Note that the number of data values produced by the filter bank is about the same as the number of data values entering the system. To see this let, be the length of the input vector and assume that the filters both have length . The length of the convolution is so that the lengths of and are . The overall size of the data emerging from the filterbank is
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 6 de 21
to get:
to get:
The coefficients,
and
form
the single stage filter bank to obtain a multiple stage filter bank.
The wavedec command in the Wavelet toolbox of Matlab carries out the calculations in the multistage filter bank. The syntax is:
[C, L] = wavedec(x, N, Lo, Hi); = wavedec(x, N, 'wname');
The vector is the set of details coefficients at each level together with the approximation coefficients at the final level.
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 7 de 21
The vector is the vector of lengths of each of the entries in wavedec reference page).
(see the
Matlab provides functions, appcoef and detcoef compute any of the approximation or detail coefficients from the output of the wavedec command.
we have:
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 8 de 21
look like convolutions but upsampling is involved. Upsampling of a discrete time signal consists of inserting zeros between the values. We can think about a system with input output for even values of and for odd values of . and
and
The idwt command in the Wavelet toolbox of Matlab carries out the calculations in this one stage filter bank. The syntax is:
x = idwt(cA, cD, Lo, Hi); = idwt(cA, cD, 'wname');
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 9 de 21
bank then we get the original coefficients back. We say the we have a perfect reconstruction filter bank.
Note that the non-causal nature of the Analysis Bank filters is does not cause a problem in practice as we are dealing with FIR filters. This means that we can apply a fixed delay, to each filter to make it causal before applying the input signal. This is the same as delaying the input signal by before applying it to the filter bank. To make things simple, assume that the filters delay the time reversed filter Denote the reversed filters by the same a delaying the signal by by and both have length . If we . is
then filtering by
Hence, we can have a filter bank consisting of causal filters which gives perfect reconstruction with an overall delay of . The analysis filters are and while the synthesis filters are and .
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 10 de 21
shown:
As
and
are in
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 11 de 21
That is, we obtain the approximation coefficients at level 0 by upsampling the approximation coefficients, at level 1 and then filtering with the low pass filter . Similarily, we obtain the detail coefficients at level 0 by upsampling the detail coefficients, at level 1 and then filtering with the high pass filter .
We can also count the number of floating point operations involved. Assume that we are feeding in operations. coefficients and the filter have length . Each convolution takes approximately So, the system requires total floating point operations.
Now if we use two-stage filter bank then the input to the next bank has length (approximately) so that the second stage adds only operations to the first stage operations.
That is, the computational complexity of the algorithm is linear in the size of the data.
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 12 de 21
much of this apparent computational advantage as we know the CWT reflects a logarithmic division of frequency while the FFT uses equally spaced frequency divisions. The point is that for some applcations the logarithmic frquency divisions are sufficent for analyzing the situation so that the DWT has a computational advantage is these cases.
x=randn(p,1); % white noise % first handle the analysis bank y0 = conv(rh0',x); y1 = conv(rh1',x);
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 13 de 21
v0 = dyaddown(y0); v1 = dyaddown(y1); % print them out [y0 y1] ans = -0.0381 0.2389 -0.1457 -1.0255 0.4057 1.4370 0.2355 0.8709 1.2926 -1.1244 -1.8471 -0.2182 0.2758 [v0 v1] ans = 0.2389 -1.0255 1.4370 0.8709 -1.1244 -0.2182 0.8916 0.0748 -1.4494 1.7159 -1.2863 0.0585 -0.1422 0.8916 -1.5287 0.0748 1.7050 -1.4494 0.0570 1.7159 -1.0294 -1.2863 1.0070 0.0585 -0.0739
% now do the synthesis bank u0 = dyadup(v0); u1 = dyadup(v1); w0 = conv(h0,u0); w1 = conv(h1,u1); % print them out [u0 u1] ans = 0 0.2389 0 -1.0255 0 1.4370 0 0.8709 0 -1.1244 0 -0.2182 0 [w0 w1] 0 0.8916 0 0.0748 0 -1.4494 0 1.7159 0 -1.2863 0 0.0585 0
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 14 de 21
ans = 0 0.1154 0.1998 -0.4417 -0.8888 0.4642 1.3348 0.7427 0.5426 -0.3478 -1.0533 -0.3574 -0.0370 -0.0489 0.0282 0 0 -0.1154 -0.1998 0.7362 -0.4474 0.2502 0.2887 -1.4345 0.3154 1.6018 -0.5404 -1.0836 0.6081 0.0489 -0.0282 0
% now add up the streams z = w0 + w1; % to compare x to z we pad the end with zeros cx = [x ; zeros(2*(len-1),1)]; [cx z] ans = 0.2944 -1.3362 0.7143 1.6236 -0.6918 0.8580 1.2540 -1.5937 -1.4410 0.5711 0 0 0 0 0 0 >> diary off 0 0.0000 -0.0000 0.2944 -1.3362 0.7143 1.6236 -0.6918 0.8580 1.2540 -1.5937 -1.4410 0.5711 -0.0000 0.0000 0
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 15 de 21
plot(x); title('original signal');axis([0 1000 -5 5]); plot(C); title('wavelet decomposition');axis([0 1000 -5 5]);
orient landscape; print wavdemofig1.eps % Now cA3 = cD3 = cD2 = cD1 = extract the coefficients appcoef(C, L, 'db2', 3); detcoef(C, L, 3); detcoef(C, L, 2); detcoef(C, L, 1);
-5 -5 -5 -5
% Now compute the reconstructed coefficients A3 = wrcoef('a', C, L, 'db2', 3); D3 = wrcoef('d', C, L, 'db2', 3); D2 = wrcoef('d', C, L, 'db2', 2); D1 = wrcoef('d', C, L, 'db2', 1); % plot these subplot(4,2,2); subplot(4,2,4); subplot(4,2,6); subplot(4,2,8); plot(A3); plot(D3); plot(D2); plot(D1); title('A3');axis([0 title('D3');axis([0 title('D2');axis([0 title('D1');axis([0 1000 1000 1000 1000 -5 -5 -5 -5 5]); 5]); 5]); 5]);
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 16 de 21
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 17 de 21
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 18 de 21
end % compute the approximation coeff at various levels for i=1:N temp = appcoef(C,L,wname,i); lena(i)=length(temp); cA(1:lena(i),i) = temp; end % compute the details at various levels for i=1:N D(:,i) = wrcoef('d',C,L,wname,i); end % compute the detail coeff at various levels for i=1:N temp = detcoef(C,L,i); lend(i)=length(temp); cD(1:lend(i),i) = temp; end % make plots figure; subplot(N+1,1,1); plot(x); title(['Signal and approximations 1 to ', num2str(N)]); for i=1:N subplot(N+1,1,i+1); plot(A(:,i)); end figure; subplot(N+1,1,1); plot(x); title(['Signal and approximation coef 1 to ', num2str(N)]); for i=1:N subplot(N+1,1,i+1); plot(cA(1:lena(i),i)); end figure; subplot(N+1,1,1); plot(x); title(['Signal and details 1 to ', num2str(N)]); for i=1:N subplot(N+1,1,i+1); plot(D(:,i)); end figure; subplot(N+1,1,1); plot(x); title(['Signal and detail coef 1 to ', num2str(N)]); for i=1:N subplot(N+1,1,i+1); plot(cD(1:lend(i),i)); end
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 19 de 21
This shows that we obtain the coordinates of the projection of through the filter with impulse response
by passing .
, we can recognize the projection coefficents in terms of a discrete time filtering process.
Assume that we have sampled a band limited signal at 20% above the Nyquist rate. After normalization we can assume that the sampling rate is 1Hz so that our signal contains only frequencies below 0.5/1.2 = 0.417. That is, we can represent our signal as
, of
is zero for
. . After rearranging
We can now pass this signal into the above filter to find the projection onto the summation and itegration we find:
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 20 de 21
, filtered by
and the phase response is linear. That is, the filter acts as a delay on our signal
and so aside from that delay, we may use the samples of the signal as the scaling coefficients. Example: The m-file initdwt.m can be used to investigate the filter
% % % % % % % % % % %
This m file investigates the filter which carries out the projection of a band limited signal into V0 This filter is alpha(n) = sinc(r) * phi(-r), at r = n alpha(n) = integral phi(-s) sinc(n-s) ds = integral phi(t) sinc(t+n) dt Since the support of phi(t) is 0 <= t <= N-1 the values of this integral will become quite small outside the interval -2N <= n <= 2N-1. So, we approximate alpha(n) by an FIR filter of length 4N.
iter = 10; dt = 1/2^iter; wave = 'db7'; [f0 f1 h0 h1] = wfilters(wave); [phi, psi, t] = wavefun(wave,iter); N = length(h0); alpha = zeros(1,4*N); for n=(-2*N:(2*N-1)) alpha(n+2*N+1) = sinc(t + n) * phi' * dt; end subplot(3,1,1) ;stem(alpha); title(['Projection Filter for ' wave]); [Alpha,W]=freqz(alpha); subplot(3,1,2); plot(W/(2*pi), abs(Alpha)); axis([0 0.5 0 1.2]); title('Magnitude Response'); subplot(3,1,3); plot(W/(2*pi), unwrap(angle(Alpha)));
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 21 de 21
title('Phase Response');
Next: 6. Properties of the Up: Wavelets and Filter Banks Previous: 4. Multiresolution Analysis Contents Dr. W. J. Phillips 2003-04-03
http://www.engmath.dal.ca/courses/engm6610/notes/node6.html
24-04-2006
Pgina Web 1 de 11
Next: 7. Designing Wavelets Up: Wavelets and Filter Banks Previous: 5. Filter Banks and Contents Subsections 6.1 Double Shift Orthogonality of the Filters 6.2 Frequency Domain Formulas 6.3 Support of the Scale Function 6.4 The Cascade Algorithm
The fact that the scale function and the low pass filter satisfy this equation has some remarkable consequences. Keep in mind that we are making a number of assumptions: 1. Orthogonality for the Wavelet: The baby wavelets are orthgonal and to have unit energy.
, .
http://www.engmath.dal.ca/courses/engm6610/notes/node7.html
24-04-2006
Pgina Web 2 de 11
The two-scale equation shows that coordinates of the filter coefficients If we delay .
are
(i.e.
Since the integer time shifts of the wavelet and the scale are orthogonal we have:
These equations are called the double shift orthogonality relations of the filters. They lead to a number of other properties of the filters. 1. If we take in the equations above we get:
http://www.engmath.dal.ca/courses/engm6610/notes/node7.html
24-04-2006
Pgina Web 3 de 11
For a proof of this equation see Proof 3 in Appendix A, page 247 of the textbook (WWT). 4. The filter such that: is an alternating flip of the filter . That is, there is an odd integer
For a proof of this fact see Proof 10 in Appendix A, page 250 of the textbook (WWT). Example To illustrate these equations we can use the m-file dshift.m as follows:
[h0 h1] = wfilters('db3','r') h0 = 0.3327 h1 = 0.0352 sum(h0) ans = 1.4142 sum(h1) 0.0854 -0.1350 -0.4599 0.8069 -0.3327 0.8069 0.4599 -0.1350 -0.0854 0.0352
http://www.engmath.dal.ca/courses/engm6610/notes/node7.html
24-04-2006
Pgina Web 4 de 11
h0odd = dyaddown(h0,0) h0odd = 0.8069 sum(h0even) ans = 0.7071 sum(h0odd) ans = 0.7071 h1even = dyaddown(h1,1) h1even = 0.0352 -0.1350 0.8069 -0.1350 0.0352
h1odd = dyaddown(h1,0) h1odd = 0.0854 sum(h1even) ans = 0.7071 sum(h1odd) ans = -0.7071 p0 = conv(h0,wrev(h0)) p0 = Columns 1 through 7 0.0117 -0.0000 -0.0977 0.0000 0.5859 1.0000 0.5859 -0.4599 -0.3327
http://www.engmath.dal.ca/courses/engm6610/notes/node7.html
24-04-2006
Pgina Web 5 de 11
p1 = conv(h1, wrev(h1)) p1 = Columns 1 through 7 -0.0117 -0.0000 0.0977 0.0000 -0.5859 1.0000 -0.5859
This is proven by taking the Fourier Transform of both sides of the two-scale equation. Note that this is a very unique equation because is the discrete time Transform. 2. If we iterate the previous equation we get: is the continuous time transform while
3.
and
. That is,
response is zero at the highest (normalized) frequency 4. and . That is, . is a mirror of
http://www.engmath.dal.ca/courses/engm6610/notes/node7.html
24-04-2006
Pgina Web 6 de 11
Notice that the double shift orthognality shows that is, is a centered, symmetric half-band filter.
and
for
. That
In the frequency domain we have . The filter with frequency response . We therefore have:
Frequency Domain P(f) <----> [ . . . p(-3) P(f+1/2) <----> [ . . .-p(-3) sum <----> [ . . . 0
is the filter
Time Domain 0 p(-1) 0 -p(-1) 0 0 1 p(1) 1 -p(1) 2 0 0 p(3) 0 -p(3) 0 0 0 p(5) . . . ] 0 -p(5) . . . ] 0 0
http://www.engmath.dal.ca/courses/engm6610/notes/node7.html
24-04-2006
Pgina Web 7 de 11
xlabel('Frequency'); axis([0 0.5 0 2.1]); subplot(2,2,2); plot(W/(2*pi), abs(H1)); title('High Pass Filter Response H_{1}(f)'); xlabel('Frequency'); axis([0 0.5 0 2.1]); subplot(2,2,3); plot(W/(2*pi), abs(P0),W/(2*pi),abs(P0shift)); title('P_{0}(f) and P_{0}(f + 1/2)'); xlabel('Frequency'); axis([0 0.5 0 2.1]); subplot(2,2,4); plot(W/(2*pi), abs(P0)+abs(P0shift)); title('P_{0}(f) + P_{0}(f + 1/2)'); xlabel('Frequency'); axis([0 0.5 0 2.1]); %orient landscape; %print -depsc 'dshiftf.eps';
The two-scale equation imposes a restriction on the support of the scale function.
http://www.engmath.dal.ca/courses/engm6610/notes/node7.html
24-04-2006
Pgina Web 8 de 11
It follows that the largest possible support for the sum is and . Hence and .
. That is
As a numerical algorithm we start with estimates Then, the first iteration produces an approximation to
of
. via:
and so on.
http://www.engmath.dal.ca/courses/engm6610/notes/node7.html
24-04-2006
Pgina Web 9 de 11
If we carry out this algorithm for M steps then we get approximate values of where ranges over . That is, the times range from
at points up to .
Once we have an estimate for the scale function we can produce an estimate of the wavelet function from it and the high pass filter . This algorithm can be implemented directly in Matlab but it is somewhat slow to carry out as Matlab is an interprted language. This slowness is a general Matlab problem for any algorithm involving many nested for loops. If we can formulate our algorithm to use built in vector operations rather than for loops it will be much faster. There is a vector version of the algorithm which we can derive as follows. We know that the subspaces using the basis functions That is, any function basis in : in , . can be written in terms of the basis in and also in terms of the , , ..., give a finer and finer decomposition of functions
through
Now recall that the coordinates of the scale function, coefficents, coefficients, , and the coordinates of the wavelet, .
, in
Hence we should upsample and low pass filter these two sets of coefficents coefficients in . . We know that
http://www.engmath.dal.ca/courses/engm6610/notes/node7.html
24-04-2006
Pgina Web 10 de 11
So we can estimate this function by a box of height might as well center this box in the interval . Define . Then
we get that
http://www.engmath.dal.ca/courses/engm6610/notes/node7.html
24-04-2006
Pgina Web 11 de 11
psi = conv(h0,psi); end % scale the answers and pad with zeros on both ends to account for the offset % note that the last x sample is exactly N - 1/2^iter. offset = (N-1)/2; pad = zeros(1,offset); %pad=[]; phi=2^(iter/2)*[pad phi pad]; psi=2^(iter/2)*[pad psi pad]; % compute the grid x nf=length(phi); % same for all %x = linspace(0, (nf-1)/2^iter,nf); x = (0:(nf-1))/2^iter;
Example The m-file ocascadedemo.m demonstrates the use the this m-file.
Next: 7. Designing Wavelets Up: Wavelets and Filter Banks Previous: 5. Filter Banks and Contents Dr. W. J. Phillips 2003-04-03
http://www.engmath.dal.ca/courses/engm6610/notes/node7.html
24-04-2006
Pgina Web 1 de 17
Next: About this document ... Up: Wavelets and Filter Banks Previous: 6. Properties of the Contents Subsections 7.1 Short Filters 7.1.1 Length 2 Filter 7.1.2 Length 4 Filter 7.1.3 Length 6 Filter 7.2 K-Regular Scaling Filters 7.2.1 The db2 Wavelet 7.2.2 The db3 Wavelet 7.3 Characterizing K-Regular Filters 7.4 The Daubechies Maximally Flat Polynomial 7.4.1 Factoring the Daubechie Maximally Flat Polynomial 7.5 Coiflets 7.5.1 Coif1 7.5.2 Coif2
7. Designing Wavelets
The properties of the low pass filter, , shown in the previous section can be used as design criteria. Once we have found a filter with the desired properties we can derive the scale and wavelet functions using the cascade algorithm provided that the algorithm converges for this filter. The minimal properties on the filter 1. Normalization: . are:
for
3. Low Pass:
http://www.engmath.dal.ca/courses/engm6610/notes/node8.html
24-04-2006
Pgina Web 2 de 17
function.
do not lead to a useful wavelet. The Daubechies wavelet with filter length 4 arises
Most values of the two parameters do not lead to useful wavelets. The m-file twoparam.m can be used to explore the various wavelets arising from these filters.
http://www.engmath.dal.ca/courses/engm6610/notes/node8.html
24-04-2006
Pgina Web 3 de 17
for alpha=(-1:0.1:1)*pi for beta=(-1:0.1:1)*pi h0=h246(alpha,beta); % frequency responses [H0,W]=freqz(h0); F=W/(2*pi); %figure(1); axis; subplot(3,1,1); plot(F,abs(H0)); title(['Frequency Response, alpha = ', num2str(alpha), ... ', beta = ', num2str(beta)]); % roots r=roots(h0); subplot(3,1,2); zplane(r); title('roots'); % wavelet and scale [phi,w,t]=ocascade(h0,8); subplot(3,1,3); plot(t,phi,t,w); title('scale and wavelet functions'); pause; end end
transform terms
. In this case we say that the filter is regular. th derivative of evaluated at is:
is at
-regular if:
http://www.engmath.dal.ca/courses/engm6610/notes/node8.html
24-04-2006
Pgina Web 4 de 17
. .
start = zeros(len,1); % starting guess for the filter start(2)=1; % the file db2eqns.m has the system of non-linear equations % Now call fsolve for this function [h,info]= fsolve('db2eqns',start); % convert to a row vector h = h'; % compare to the wavelet toolbox values h0 = wfilters('db2','r'); [h' h0'] % now construct h1 by the alternating flip h1 = fliplr(h); h1(1:2:length(h1)) = -h1(1:2:length(h1)); [H,W] = freqz(h); [H1,W] = freqz(h1); figure(1); plot(W/(2*pi),abs(H),W/(2*pi),abs(H1)) xlabel('frequency'); title('db2 Filters');
http://www.engmath.dal.ca/courses/engm6610/notes/node8.html
24-04-2006
Pgina Web 5 de 17
[phi,psi,x] = ocascade(h,8); figure(2); plot(x,phi,x,psi); xlabel('time'); title('db2 wavelet and scale'); function y = db2eqns(h) y=zeros(4,1); % norm is 1 y(1) = h(1)*h(1) + h(2)*h(2) + h(3)*h(3) + h(4)*h(4) - 1.0; % double shift orthogonality y(2) = h(3)*h(1) + h(4)*h(2); % H(1/2) = 0 y(3) = h(1) - h(2) + h(3) - h(4); % H'(1/2) = 0 y(4) = -h(2) + 2.0*h(3) - 3.0*h(4);
and
Again, we will use the Matlab numerical solver function fsolve.m. The equations above have been coded as db3eqns.m along with the driver program daub3.m.
http://www.engmath.dal.ca/courses/engm6610/notes/node8.html
24-04-2006
Pgina Web 6 de 17
, and
as follows:
When we combine the 2-scale equation with these defintions we find (see page 75 of WWT) the following relationships between the discrete and continuous momments.
These equations can be used to calculate any continuous moment as a convolution like formula involving the discrete moments and the lower order continuous moments. In particular, if the discrete moments, of the high pass filter, then follows that the continuous moments of the wavelet, more is true. See page 75 of WWT. Equivalent Characterization of 1. The filter is -Regular Filters The following conditions are all equivalent. , are zero for are zero for it . Much
-regular.
http://www.engmath.dal.ca/courses/engm6610/notes/node8.html
24-04-2006
Pgina Web 7 de 17
2. order
at
. That is,
This is just a restatment of condition 1. 3. The ``alternating moments'' zero. This condition arises by noting that aside from mutiples of , is just the 4. The moments th derivative of , at . are zero. , the alternating moment, , for , are
This follows from the fact that the wavelet filter filter . ,
5. The moments
of the wavelet,
, are zero.
This follows from the relationship above between discrete and continuous moments. 6. All polynomials of degree up to translates of the scaling function. This condition follows by noting that zero then it follows that the space . for all . So, that if all these moments are . Hence, the polynomial must be ``in'' can be expressed as a linear combination of integer
When we consider the number of equations that the coefficients of the largest possible value of is .
This is the case since the double shift orthgonality conditions amount to normalization adds one equation leaving at most The form of must therefore be: other equations.
http://www.engmath.dal.ca/courses/engm6610/notes/node8.html
24-04-2006
Pgina Web 8 de 17
is a filter of length
is called the Daubechie maxmimally flat filter. Note that the length is .
and define
. Then we
consists of terms of the Binomial series expansion of (see Theorem 23 on page 76 of WWT). That is,
Hence,
http://www.engmath.dal.ca/courses/engm6610/notes/node8.html
24-04-2006
Pgina Web 9 de 17
Solving for
in terms of
occur in pairs (
The m-file daubpoly.m implements the computation of the polynomial and its roots.
function [p, z] = daubpoly(K) %[p, z] = daubpoly(K) %Function to compute the Daubechie polynomial of order 4K-2 %as per the discussion on pages 76-78 of the book WWT %Not accruate for n > 20. %Input: K where the filter has length 4K-1 %Output: Daubechie Max Flat Polynomial p and its roots z % As stated on pages 76 to 78 (also see pages 166 to 169 of Strang): % % % n n % ( 1+1/z ) ( 1+z ) % P(z) = 2( ----- ) ( ----- ) L(y) % ( 2 ) ( 2 ) % % The relationship between z, y, and frequency f is: % % 2 % y = sin(pi f) % % y = (1 - cos(2pi f))/2 = (2 - z - 1/z)/4 % % then 1 - y = (1 + cos(2pi f))/2 = (2 + z + 1/z)/4
http://www.engmath.dal.ca/courses/engm6610/notes/node8.html
24-04-2006
Pgina Web 10 de 17
% % rearranging the last equation gives a quadratic: % % ( z^2 - 2(1-2y)z + 1) = 0. To solve the quadratic equation: % % Let x = 1 - 2y and u = sqrt(x^2-1) then % % z = x + u and z = x - u are the two roots of M(z) for each root y of P(y) % % Note that x - u = 1/(x + u). That is, we have roots and their inverses % % % L(y) = binonmial series for (1-y)^(-n) up to K terms i.e. % up to the power y^(K-1) % % K - 1 % _____ % \ ( K-1+k ) k % P(y) = ( ) y % / ( k ) % ----% k = 0 % % That is, % % K - 1 % _____ % K \ ( K-1+k ) k % M(z) = (1-y) | ( ) y % / ( k ) % ----% k = 0 % % % coef is the vector of coefficients of P(y/4) (lowest to highest power). % dividing by 4 makes the computation more stable. coef = zeros(1,K); coef(1) = 1; %keep in mind that coef(k) is the coefficient of y^(k-1) for k = 2:K, coef(k) = coef(k-1)*0.25*(k+K-2)/(k-1); end y=roots( fliplr(coef) )/4; x=1-2*y; u = sqrt(x.^2-1); z=[x+u; x-u]; z = [-ones(2*K,1); z]; p = poly(z); p = 2*p /sum(p);
. That is,
http://www.engmath.dal.ca/courses/engm6610/notes/node8.html
24-04-2006
Pgina Web 11 de 17
We can factor
to obtain a has
of length and
. other roots
To carry out the factorization we note that which occur in pairs ( other has and
roots outside the unit circle. roots at we have and other roots. These roots occur in conjugate pairs.
complex roots and one real rootin the first quadrant . For or is a root of . This leads to
other roots
may have ``better'' filters. The m-file daubdemo.m shows how the choice of roots can affect the phase response of the filter for the case .
% File: daubdemo.m % This m-file shows that by choosing the roots of the Daubechie maxflat % polynomial we can get close to linear phase filters % K=6; [p,z] = daubpoly(K); % db6 z1 = z(20); z2=z(18); z3=z(21); r=[-ones(6,1);z1;z2;conj(z2);z3;conj(z3)]; h=poly(r); h=sqrt(2)*h/sum(h); [phi,w,t]=ocascade(h,8); figure; subplot(3,1,1); zplane(r); title('roots'); subplot(3,1,2); plot(t,phi,t,w); title('scale and wavelet'); [H,W]=freqz(h); subplot(3,1,3); plot(W/(2*pi),unwrap(angle(H))); title('phase response'); z1 = z(20); z2=1/z(18); z3=z(21); r=[-ones(6,1);z1;z2;conj(z2);z3;conj(z3)]; h=poly(r); h=sqrt(2)*h/sum(h); [phi,w,t]=ocascade(h,8); figure; subplot(3,1,1); zplane(r); title('roots'); subplot(3,1,2); plot(t,phi,t,w); title('scale and wavelet'); [H,W]=freqz(h); subplot(3,1,3); plot(W/(2*pi),unwrap(angle(H))); title('phase response'); z1 = z(20); z2=z(18); z3=1/z(21); r=[-ones(6,1);z1;z2;conj(z2);z3;conj(z3)]; h=poly(r);
http://www.engmath.dal.ca/courses/engm6610/notes/node8.html
24-04-2006
Pgina Web 12 de 17
h=sqrt(2)*h/sum(h); [phi,w,t]=ocascade(h,8); figure; subplot(3,1,1); zplane(r); title('roots'); subplot(3,1,2); plot(t,phi,t,w); title('scale and wavelet'); [H,W]=freqz(h); subplot(3,1,3); plot(W/(2*pi),unwrap(angle(H))); title('phase response'); z1 = z(20); z2=1/z(18); z3=1/z(21); r=[-ones(6,1);z1;z2;conj(z2);z3;conj(z3)]; h=poly(r); h=sqrt(2)*h/sum(h); [phi,w,t]=ocascade(h,8); figure; subplot(3,1,1); zplane(r); title('roots'); subplot(3,1,2); plot(t,phi,t,w); title('scale and wavelet'); [H,W]=freqz(h); subplot(3,1,3); plot(W/(2*pi),unwrap(angle(H))); title('phase response');
7.5 Coiflets
The Daubechie filters have the property that they are maximally flat. That is, if the length of the low pass filter, , is then the largest possible order of the zero of at is . In terms of conditons on the filter coefficients we have: 1. Normalization: (1 condition) .
conditions)
3.
-Regular: (
conditions)
for
The most
can be is
. If we allow
to be less than
condtions on the filter. To obtain the filters and wavelets commonly known as coiflets we require fewer alternating moments to be zero but require some (usual) moments to be zero. That is: 1. Normalization: (1 condition) .
conditions)
http://www.engmath.dal.ca/courses/engm6610/notes/node8.html
24-04-2006
Pgina Web 13 de 17
3.
conditions)
for
4.
conditons)
for
. Hence with this last condtion we are asking that the be very flat although we know that . at .
There is a simplifying result which comes from computing the derivatives of After some manipulation (see page 91 of WWT) it can be shown that:
even,
This has an important outcome. If the odd moments are zero for are zero. condtions in item 4 above is actually then if follows that . condtions and we have: then all the even moments are zero
too so that all the moments up to order Hence, what originally appeared to be (assuming that
1. Normalization: (1 condition)
conditions)
3.
conditions)
for
http://www.engmath.dal.ca/courses/engm6610/notes/node8.html
24-04-2006
Pgina Web 14 de 17
4.
conditons)
for
with
zero
We can solve these equations using the numerical solving technique previously discussed. These equations are easy to express in Matlab. If we represent the filter as the column vector h in Matlab then the equations become: 1. Normalization: (1 condition) h'*h -1 = 0 2. Double Shift Orthogonality: (
= 0
conditions) dyaddown(conv(h,flipud(h))
3.
2, 3, ...,(N-1)],let alter be the row vector [1, -1, 1, -1, ... ] and let A by N matrix whose kth row is alter .* n.^ (k-1). Then we require A*h = 0
4.
we must advance the filter by 2L. This is reflected in the moments as follows. Let m be the row vector [0,1,2,...,(N-1)] - 2L and let B be the L by N matrix whose kth row is m .(2k-1). Then we require B*h = 0.
7.5.1 Coif1
If we choose
coif1eqns.m
, of length wavelet.
% m file to generate the coif1 low pass filter L = 1; N = 6*L; % which coif filters to use % filter length
start = [0 0 0 1 0 0]'; % starting guess for the filter % the file coif1eqns.m has the system of non-linear equations % Now call fsolve for this function [h,info]= fsolve('coif1eqns',start); % convert to a row vector h = h' % compare to the wavelet toolbox values h0 = wfilters('coif1','r');
http://www.engmath.dal.ca/courses/engm6610/notes/node8.html
24-04-2006
Pgina Web 15 de 17
[h' h0'] % now construct h1 by the alternating flip h1 = fliplr(h); h1(2:2:length(h1)) = -h1(2:2:length(h1)); [H,W] = freqz(h); [H1,W] = freqz(h1); figure(1); plot(W/(2*pi),abs(H),W/(2*pi),abs(H1)) xlabel('frequency'); title('coif1 Filters'); [phi,psi,x] = ocascade(h,8); figure(2); plot(x,phi,x,psi); xlabel('time'); title('coif1 wavelet and scale'); function y = coif1eqns(h) L=1; N=6*L; n = (0 : (N-1)); m = ((-2*L) : (N-1-2*L)); % advance by 2L % norm of h is 1 norm2 = h'*h - 1.0; % double shifts of h are orthogonal temp = conv(h, flipud(h)); dblshift = temp(2:2:(N-1)); % 2L derivatives at freq 1/2 (alternating moments of h) are 0 alter = ones(1,N); alter(2:2:N) = -alter(2:2:N); A = [alter; alter .* n]; % L odd derivatives at f = 0 (moments of h) are 0 B = [m]; y = [norm2; dblshift; A * h; B * h];
7.5.2 Coif2
If we choose
coif2eqns.m
, of length wavelet.
% m file to generate the coif2 low pass filter L = 2; N = 6*L; % which coif filters to use % filter length
http://www.engmath.dal.ca/courses/engm6610/notes/node8.html
24-04-2006
Pgina Web 16 de 17
start(5)=1; start(6)=1; % the file coif12eqns.m has the system of non-linear equations % Now call fsolve for this function [h,info]= fsolve('coif2eqns',start); info % convert to a row vector h = h'; % compare to the wavelet toolbox values h0 = wfilters('coif2', 'r'); [h0' h'] % now construct h1 by the alternating flip h1 = fliplr(h); h1(1:2:length(h1)) = -h1(1:2:length(h1)); [H,W] = freqz(h); [H1,W] = freqz(h1); figure(1); plot(W/(2*pi),abs(H),W/(2*pi),abs(H1)) xlabel('frequency'); title('coif2 Filters'); [phi,psi,t] = ocascade(h,8); figure(2); plot(t,phi,t,psi); xlabel('time'); title('coif2 wavelet and scale'); function y = coif2eqns(h) L=2; N=6*L; n = (0 : (N-1)); m = ((-2*L) : (N-1-2*L)); % norm of h is 1 norm2 = h'*h - 1.0; % double shifts of h are orthogonal (5 equations) temp = conv(h, flipud(h)); dblshift = temp(2:2:(N-1)); % 2L derivatives at freq 1/2 (alternating moments of h) are 0 alter = ones(1,N); alter(2:2:N) = -alter(2:2:N); A = [alter; alter .* n; alter .* n .* n; alter .* n .* n .* n]; alter .* n .* n .* n .* n; alter .* n .* n .* n .* n .* n]; % L odd derivatives at f = 0 (moments of h) are 0 % see page 91 of WWT, if moments 1 and 3 are zero then so are 2 and 4 B = [m; m .* m .* m]; y = [norm2;
% %
http://www.engmath.dal.ca/courses/engm6610/notes/node8.html
24-04-2006
Pgina Web 17 de 17
dblshift; A * h; B * h];
Next: About this document ... Up: Wavelets and Filter Banks Previous: 6. Properties of the Contents Dr. W. J. Phillips 2003-04-03
http://www.engmath.dal.ca/courses/engm6610/notes/node8.html
24-04-2006
Pgina Web 1 de 1
http://www.engmath.dal.ca/courses/engm6610/notes/node9.html
24-04-2006