TheWavelet Tutorial Part 2

来源:互联网 发布:图片排版软件 编辑:程序博客网 时间:2024/05/01 19:59

转载自:http://users.rowan.edu/~polikar/WAVELETS/WTpart2.html

ROBI POLIKAR


FUNDAMENTALS:

THE FOURIER TRANSFORM
AND
THE SHORT TERM FOURIER TRANSFORM

FUNDAMENTALS

Let's have a short review of the first part.
We basically need Wavelet Transform (WT) to analyze non-stationary signals,i.e., whose frequency response varies in time. I have written that FourierTransform (FT) is not suitable for non-stationary signals, and I have shownexamples of it to make it more clear. For a quick recall, let me give thefollowing example.

Suppose we have two different signals. Also suppose that they both have thesame spectral components, with one major difference. Say one of the signalshave four frequency components at all times, and the other have the same fourfrequency components at different times. The FT of both of the signals would bethe same, as shown in the example in part 1 of this tutorial. Although the twosignals are completely different, their (magnitude of) FT are the SAME!.This, obviously tells us that we can not use the FT for non-stationary signals.

But why does this happen? In other words, how come both of thesignals have the same FT?HOW DOES FOURIER TRANSFORM WORK ANYWAY?

An Important Milestone in Signal Processing:

THE FOURIER TRANSFORM

I will not go into the details of FT for two reasons:
1. It is too wide of a subject to discuss in this tutorial.
2. It is not our main concern anyway.
However, I would like to mention a couple important points again for tworeasons:
1. It is a necessary background to understand how WT works.
2. It has been by far the most important signal processing tool for many (and Imean many many) years.

In 19th century (1822*, to be exact, but you do not need to know the exacttime. Just trust me that it is far before than you can remember), the Frenchmathematician J. Fourier, showed that any periodic function can be expressed asan infinite sum of periodic complex exponential functions. Many years after hehad discovered this remarkable property of (periodic) functions, his ideas weregeneralized to first non-periodic functions, and then periodic or non-periodicdiscrete time signals. It is after this generalization that it became a verysuitable tool for computer calculations. In 1965, a new algorithm called fastFourier Transform (FFT) was developed and FT became even more popular.

(* I thank Dr. Pedregal for the valuable information he has provided)

Now let us take a look at how Fourier transform works:
FT decomposes a signal to complex exponential functions of differentfrequencies. The way it does this, is defined by the following two equations:

Figure 2.1

In the above equation, t stands for time, f stands forfrequency, andx denotes the signal at hand. Note thatx denotesthe signal in time domain and theX denotes the signal in frequencydomain. This convention is used to distinguish the two representations of thesignal. Equation (1) is called theFourier transform of x(t), andequation (2) is called the inverse Fourier transform of X(f), which isx(t).

For those of you who have been using the Fourier transform are alreadyfamiliar with this. Unfortunately many people use these equations withoutknowing the underlying principle.

Please take a closer look at equation (1):

The signal x(t), is multiplied with an exponential term, at some certainfrequency "f", and then integrated overALL TIMES !!!(The key words here are "all times" , as will explained below).

Note that the exponential term in Eqn. (1) can also be written as:

Cos(2.pi.f.t)+j.Sin(2.pi.f.t).......(3)

The above expression has a real part of cosine of frequency f, and animaginary part of sine of frequencyf. So what we are actually doing is,multiplying the original signal with a complex expression which has sines andcosines of frequencyf. Then we integrate this product. In other words,we add all the points in this product. If the result of this integration (whichis nothing but some sort of infinite summation) is a large value, then we saythat :the signal x(t), has a dominant spectral component at frequency"f". This means that, a major portion of this signal is composedof frequencyf. If the integration result is a small value, than thismeans that the signal does not have a major frequency component off init. If this integration result is zero, then the signal does not contain thefrequency "f" at all.

It is of particular interest here to see how this integration works: Thesignal is multiplied with the sinusoidal term of frequency "f". Ifthe signal has a high amplitude component of frequency "f", then thatcomponent and the sinusoidal term will coincide, and the product of them willgive a (relatively) large value. This shows that, the signal"x", has a major frequency component of "f".

However, if the signal does not have a frequency component of "f",the product will yield zero, which shows that, the signal does not have afrequency component of "f". If the frequency "f", is not amajor component of the signal "x(t)", then the product will give a(relatively) small value. This shows that, the frequency component"f" in the signal "x", has a small amplitude, in otherwords, it is not a major component of "x".

Now, note that the integration in the transformation equation (Eqn. 1) isover time. The left hand side of (1), however, is a function of frequency.Therefore, the integral in (1), is calculated for every value off.

IMPORTANT(!) The information provided by the integral, corresponds toall time instances, since the integration is from minus infinity to plusinfinity over time. It follows that no matter where in time the component withfrequency "f" appears, it will affect the result of the integrationequally as well. In other words, whether the frequency component "f"appears at time t1 or t2 , it will have the same effect on the integration.This is whyFourier transform is not suitable if the signal has time varyingfrequency, i.e., the signal isnon-stationary. If only the signalhas the frequency component "f" at all times (for all "t"values), then the result obtained by the Fourier transform makes sense.

Note that the Fourier transform tells whether a certain frequencycomponent exists or not. This information is independent of where in timethis component appears. It is therefore very important to know whether a signalis stationary or not, prior to processing it with the FT.

The example given in part one should now be clear. I would like to give ithere again:

Look at the following figure, which shows the signal:

x(t)=cos(2*pi*5*t)+cos(2*pi*10*t)+cos(2*pi*20*t)+cos(2*pi*50*t)

that is , it has four frequency components of 5, 10, 20, and 50 Hz., alloccurring at all times.

Figure 2.2

And here is the FT of it. The frequency axis has been cut here, buttheoretically it extends to infinity (for continuous Fourier transform (CFT).Actually, here we calculate the discrete Fourier transform (DFT), in which casethe frequency axis goes up to (at least) twice the sampling frequency of thesignal, and the transformed signal is symmetrical. However, this is not thatimportant at this time.)

Figure 2.3

Note the four peaks in the above figure, which correspond to four differentfrequencies.

Now, look at the following figure: Here the signal is again the cosinesignal, and it has the same four frequencies. However, these components occuratdifferent times.

Figure 2.4

And here is the Fourier transform of this signal:

Figure 2.5

What you are supposed to see in the above figure, is it is (almost) samewith the previous FT figure. Please look carefully and note the major four peakscorresponding to 5, 10, 20, and 50 Hz. I could have made this figure look verysimilar to the previous one, but I did not do that on purpose. The reason ofthe noise like thing in between peaks show that, those frequencies also existin the signal. But the reason they have a small amplitude , is because,theyare not major spectral components of the given signal, and the reason wesee those, is because of the sudden change between the frequencies. Especiallynote how time domain signal changes at around time 250 (ms) (With some suitablefiltering techniques, the noise like part of the frequency domain signal can becleaned, but this has not nothing to do with our subject now. If you needfurther information please send me an e-mail).

By this time you should have understood the basic concepts of Fouriertransform, when we can use it and we can not. As you can see from the aboveexample, FT cannot distinguish the two signals very well. To FT, both signalsare the same, because they constitute of the same frequency components.Therefore, FT is not a suitable tool for analyzing non-stationary signals,i.e., signals with time varying spectra.

Please keep this very important property in mind. Unfortunately, many peopleusing the FT do not think of this. They assume that the signal they have isstationary where it is not in many practical cases. Of course if you are notinterested in at what times these frequency components occur, but onlyinterested in what frequency components exist, then FT can be a suitable toolto use.

So, now that we know that we can not use (well, we can, but we shouldn't) FTfor non-stationary signals, what are we going to do?

Remember that, I have mentioned that wavelet transform is only (about) adecade old. You may wonder if researchers noticed this non-stationaritybusiness only ten years ago or not.

Obviously not.

Apparently they must have done something about it before they figured outthe wavelet transform....?

Well..., they sure did...

They have come up with ...

LINEAR TIME FREQUENCYREPRESENTATIONS

THE SHORT TERM FOURIER TRANSFORM

So, how are we going to insert this time business into our frequency plots?Let's look at the problem in hand little more closer.

What was wrong with FT? It did not work for non-stationary signals. Let'sthink this:Can we assume that , some portion of a non-stationary signal isstationary?

The answer is yes.

Just look at the third figure above. The signal is stationary every 250 timeunit intervals.

You may ask the following question?

What if the part that we can consider to be stationary is very small?

Well, if it is too small, it is too small. There is nothing we can do aboutthat, and actually, there is nothing wrong with that either. We have to playthis game with the physicists' rules.

If this region where the signal can be assumed to be stationary is toosmall, then we look at that signal from narrow windows, narrow enough that theportion of the signal seen from these windows are indeed stationary.

This approach of researchers ended up with a revised version of theFourier transform, so-called : The Short Time Fourier Transform (STFT) .

There is only a minor difference between STFT and FT. In STFT, the signal isdivided into small enough segments, where these segments (portions) of thesignal can be assumed to be stationary. For this purpose, a window function"w"is chosen. The width of this window must be equal to the segment of the signalwhere its stationarity is valid.

This window function is first located to the very beginning of the signal.That is, the window function is located at t=0. Let's suppose that the width ofthe window is"T" s. At this time instant (t=0), the windowfunction will overlap with the firstT/2 seconds (I will assume that alltime units are in seconds). The window function and the signal are thenmultiplied. By doing this, only the first T/2 seconds of the signal is beingchosen, with the appropriate weighting of the window (if the window is arectangle, with amplitude "1", then the product will be equal to thesignal). Then this product is assumed to be just another signal, whose FT is tobe taken. In other words, FT of this product is taken, just as taking the FT ofany signal.

The result of this transformation is the FT of the first T/2 secondsof the signal. If this portion of the signal is stationary, as it is assumed,then there will be no problem and the obtained result will be a true frequencyrepresentation of the first T/2 seconds of the signal.

The next step, would be shifting this window (for some t1 seconds) to a newlocation, multiplying with the signal, and taking the FT of the product. Thisprocedure is followed, until the end of the signal is reached by shifting thewindow with "t1" seconds intervals.

The following definition of the STFT summarizes all the above explanationsin one line:

Figure 2.6

Please look at the above equation carefully. x(t) is the signalitself,w(t) is the window function, and* is the complexconjugate. As you can see from the equation, the STFT of the signal is nothingbut the FT of the signal multiplied by a window function.

For every t' and f a new STFT coefficient is computed(Correction: The "t" in the parenthesis of STFT should be"t'". I will correct this soon. I have just noticed that I havemistyped it).

The following figure may help you to understand this a little better:

Figure 2.7

The Gaussian-like functions in color are the windowing functions. The redone shows the window located at t=t1', the blue shows t=t2', and the green oneshows the window located at t=t3'. These will correspond to three different FTsat three different times. Therefore, we will obtain a true time-frequencyrepresentation (TFR) of the signal.

Probably the best way of understanding this would be looking at an example.First of all, since our transform is a function of both time and frequency (unlikeFT, which is a function of frequency only), the transform would be twodimensional (three, if you count the amplitude too). Let's take anon-stationary signal, such as the following one:

Figure 2.8

In this signal, there are four frequency components at different times. Theinterval 0 to 250 ms is a simple sinusoid of 300 Hz, and the other 250 msintervals are sinusoids of 200 Hz, 100 Hz, and 50 Hz, respectively. Apparently,this is a non-stationary signal. Now, let's look at its STFT:

Figure 2.9

As expected, this is two dimensional plot (3 dimensional, if you count theamplitude too). The "x" and "y" axes are time andfrequency, respectively. Please, ignore the numbers on the axes, since they arenormalized in some respect, which is not of any interest to us at this time.Just examine the shape of the time-frequency representation.

First of all, note that the graph is symmetric with respect to midline ofthe frequency axis. Remember that, although it was not shown, FT of a realsignal is always symmetric, since STFT is nothing but a windowed version of theFT, it should come as no surprise that STFT is also symmetric in frequency. Thesymmetric part is said to be associated with negative frequencies, an oddconcept which is difficult to comprehend, fortunately, it is not important; itsuffices to know that STFT and FT are symmetric.

What is important, are the four peaks; note that there are four peakscorresponding to four different frequency components. Also note that, unlikeFT,these four peaks are located at different time intervals along the timeaxis. Remember that the original signal had four spectral componentslocated at different times.

Now we have a true time-frequency representation of the signal. We not onlyknow what frequency components are present in the signal, but we also knowwhere they are located in time.

It is grrrreeeaaatttttt!!!! Right?

Well, not really!

You may wonder, since STFT gives the TFR of the signal, why do we need thewavelet transform. The implicit problem of the STFT is not obvious in the aboveexample. Of course, an example that would work nicely was chosen on purpose todemonstrate the concept.

The problem with STFT is the fact whose roots go back to what is known asthe Heisenberg Uncertainty Principle . This principle originally appliedto the momentum and location of moving particles, can be applied totime-frequency information of a signal. Simply, this principle states that onecannot know the exact time-frequency representation of a signal, i.e., onecannot know what spectral components exist at what instances of times. What onecanknow are thetime intervals in which certain band offrequenciesexist, which is aresolution problem.

The problem with the STFT has something to do with the width of thewindow function that is used. To be technically correct, this width of thewindow function is known asthe supportof the window. If the windowfunction is narrow, than it is known ascompactly supported. Thisterminology is more often used in the wavelet world, as we will see later.

Here is what happens:

Recall that in the FT there is no resolution problem in the frequencydomain, i.e., we know exactly what frequencies exist; similarly we there is notime resolution problem in the time domain, since we know the value of thesignal at every instant of time. Conversely, the time resolution in the FT, andthe frequency resolution in the time domain are zero, since we have noinformation about them. What gives the perfect frequency resolution in the FTis the fact that the window used in the FT is its kernel, theexp{jwt}function,which lasts at all times from minus infinity to plus infinity. Now, in STFT,our window is of finite length, thus it covers only a portion of the signal,which causes the frequency resolution to get poorer. What I mean by gettingpoorer is that, we no longer know the exact frequency components that exist inthe signal, but we only know a band of frequencies that exist:

In FT, the kernel function, allows us to obtain perfect frequencyresolution, because the kernel itself is a window of infinite length. In STFTis window is of finite length, and we no longer have perfect frequencyresolution. You may ask, why don't we make the length of the window in the STFTinfinite, just like as it is in the FT, to get perfect frequency resolution?Well, than you loose all the time information, you basically end up with the FTinstead of STFT. To make a long story real short, we are faced with thefollowing dilemma:

If we use a window of infinite length, we get the FT, which gives perfectfrequency resolution, but no time information. Furthermore, in order to obtainthe stationarity, we have to have a short enough window, in which the signal isstationary. The narrower we make the window, the better the time resolution,and better the assumption of stationarity, but poorer the frequency resolution:

Narrow window ===>good time resolution, poor frequency resolution.
Wide window ===>good frequency resolution, poor time resolution.

In order to see these effects, let's look at a couple examples: I will showfour windows of different length, and we will use these to compute the STFT,and see what happens:

The window function we use is simply a Gaussian function in the form:

w(t)=exp(-a*(t^2)/2);

where a determines the length of the window, and t is thetime. The following figure shows four window functions of varying regions ofsupport, determined by the value ofa. Please disregard the numericvalues of a since the time interval where this function is computed alsodetermines the function. Just note the length of each window. The above examplegiven was computed with the second value,a=0.001. I will now show theSTFT of the same signal given above computed with the other windows.

Figure 2.10

First let's look at the first most narrow window. We expect the STFT to havea very good time resolution, but relatively poor frequency resolution:

Figure 2.11

The above figure shows this STFT. The figure is shown from a top bird-eyeview with an angle for better interpretation. Note that the four peaks are wellseparated from each other in time. Also note that, in frequency domain, everypeak covers a range of frequencies, instead of a single frequency value. Nowlet's make the window wider, and look at the third window (the second one wasalready shown in the first example).

Figure 2.12

Note that the peaks are not well separated from each other in time, unlikethe previous case, however, in frequency domain the resolution is much better.Now let's further increase the width of the window, and see what happens:

Figure 2.13

Well, this should be of no surprise to anyone now, since we would expect aterrible (and I mean absolutely terrible) time resolution.

These examples should have illustrated the implicit problem of resolution ofthe STFT. Anyone who would like to use STFT is faced with this problem ofresolution. What kind of a window to use? Narrow windows give good timeresolution, but poor frequency resolution. Wide windows give good frequencyresolution, but poor time resolution; furthermore, wide windows may violate thecondition of stationarity. The problem, of course, is a result of choosing awindow function, once and for all, and use that window in the entire analysis.The answer, of course, is application dependent: If the frequency componentsare well separated from each other in the original signal, than we maysacrifice some frequency resolution and go for good time resolution, since thespectral components are already well separated from each other. However, ifthis is not the case, then a good window function, could be more difficult thanfinding a good stock to invest in.

By now, you should have realized how wavelet transform comes into play. TheWavelet transform (WT) solves the dilemma of resolution to a certain extent, aswe will see in the next part.

This completes Part II of this tutorial. The continuous wavelet transform isthe subject of the Part III of this tutorial. If you did not have much troublein coming this far, and what have been written above make sense to you, you arenow ready to take the ultimate challenge in understanding the basic concepts ofthe wavelet theory.

polikar@rowan.edu
Send your comments / questions to: 
Wavelet Tutorial Main Page
Robi Polikar Home

The Wavelet Tutorial is hosted by RowanUniversity, College of Engineering Web Servers

AllRights Reserved. This tutorial is intended for educational purposes only.Unauthorized copying, duplicating and publishing is strictly prohibited.

RobiPolikar
136 Rowan Hall

Dept.of Electrical and Computer Engineering

Rowan University

Glassboro, NJ 08028

Phone:(856) 256 5372

E-Mail

polikar@rowan.edu


0 0