您的位置:首页 > 其它

TheWavelet Tutorial Part 2

2012-12-22 19:43 330 查看

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

TheWaveletTutorial(大家一起看看哦)

Part2

by

ROBIPOLIKAR



FUNDAMENTALS:

THEFOURIERTRANSFORM

AND

THESHORTTERMFOURIERTRANSFORM



FUNDAMENTALS

Let'shaveashortreviewofthefirstpart.

WebasicallyneedWaveletTransform(WT)toanalyzenon-stationarysignals,i.e.,whosefrequencyresponsevariesintime.IhavewrittenthatFourierTransform(FT)isnotsuitablefornon-stationarysignals,andIhaveshownexamplesofittomakeitmoreclear.
Foraquickrecall,letmegivethefollowingexample.

Supposewehavetwodifferentsignals.Alsosupposethattheybothhavethesamespectralcomponents,withonemajordifference.Sayoneofthesignalshavefourfrequencycomponentsatalltimes,andtheotherhavethesamefourfrequencycomponentsatdifferent
times.TheFTofbothofthesignalswouldbethesame,asshownintheexampleinpart1ofthistutorial.Althoughthetwosignalsarecompletelydifferent,their(magnitudeof)FTaretheSAME!.This,obviouslytellsusthatwecannotuse
theFTfornon-stationarysignals.

Butwhydoesthishappen?Inotherwords,howcomebothofthesignalshavethesameFT?HOWDOESFOURIERTRANSFORMWORKANYWAY?

AnImportantMilestoneinSignalProcessing:

THEFOURIERTRANSFORM

IwillnotgointothedetailsofFTfortworeasons:

1.Itistoowideofasubjecttodiscussinthistutorial.

2.Itisnotourmainconcernanyway.

However,Iwouldliketomentionacoupleimportantpointsagainfortworeasons:

1.ItisanecessarybackgroundtounderstandhowWTworks.

2.Ithasbeenbyfarthemostimportantsignalprocessingtoolformany(andImeanmanymany)years.

In19thcentury(1822*,tobeexact,butyoudonotneedtoknowtheexattime.Justtrustmethatitisfarbeforethanyoucanremember),theFrenchmathematicianJ.Fourier,showedthatanyperiodicfunctioncanbeexpressedasaninfinitesumofperiodic
complexexponentialfunctions.Manyyearsafterhehaddiscoveredthisremarkablepropertyof(periodic)functions,hisideasweregeneralizedtofirstnon-periodicfunctions,andthenperiodicornon-periodicdiscretetimesignals.Itisafterthisgeneralization
thatitbecameaverysuitabletoolforcomputercalculations.In1965,anewalgorithmcalledfastFourierTransform(FFT)wasdevelopedandFTbecameevenmorepopular.

(*IthankDr.Pedregalforthevaluableinformationhehasprovided)

NowletustakealookathowFouriertransformworks:

FTdecomposesasignaltocomplexexponentialfunctionsofdifferentfrequencies.Thewayitdoesthis,isdefinedbythefollowingtwoequations:


傅里叶变换对

Figure2.1
Intheaboveequation,tstandsfortime,fstandsforfrequency,andxdenotesthesignalathand.NotethatxdenotesthesignalintimedomainandtheXdenotesthesignal
infrequencydomain.Thisconventionisusedtodistinguishthetworepresentationsofthesignal.Equation(1)iscalledtheFouriertransformofx(t),andequation(2)iscalledtheinverseFouriertransformofX(f),which
isx(t).

ForthoseofyouwhohavebeenusingtheFouriertransformarealreadyfamiliarwiththis.Unfortunatelymanypeopleusetheseequationswithoutknowingtheunderlyingprinciple.

Pleasetakeacloserlookatequation(1):

Thesignalx(t),ismultipliedwithanexponentialterm,atsomecertainfrequency"f",andthenintegrated
overALLTIMES!!!(Thekeywordshereare"alltimes",aswillexplainedbelow).

NotethattheexponentialterminEqn.(1)canalsobewrittenas:

[b]Cos(2.pi.f.t)-j.Sin(2.pi.f.t).......(3)

[/b]
Theaboveexpressionhasarealpartofcosineoffrequencyf,andanimaginarypartofsineoffrequencyf.Sowhatweareactuallydoingis,multiplyingtheoriginalsignalwithacomplexexpressionwhichhassinesand
cosinesoffrequencyf.Thenweintegratethisproduct.Inotherwords,weaddallthepointsinthisproduct.Iftheresultofthisintegration(whichisnothingbutsomesortofinfinitesummation)isalargevalue,thenwesaythat:the
signalx(t),hasadominantspectralcomponentatfrequency"f"
.Thismeansthat,amajorportionofthissignaliscomposedoffrequencyf.Iftheintegrationresultisasmallvalue,thanthismeansthatthesignaldoesnothavea
majorfrequencycomponentoffinit.Ifthisintegrationresultiszero,thenthesignaldoesnotcontainthefrequency"f"atall.

Itisofparticularinterestheretoseehowthisintegrationworks:Thesignalismultipliedwiththesinusoidaltermoffrequency"f".Ifthesignalhasahighamplitude
componentoffrequency"f",thenthatcomponentandthesinusoidaltermwillcoincide,andtheproductofthemwillgivea(relatively)largevalue.Thisshowsthat,thesignal"x",hasamajorfrequencycomponentof"f".(自己觉得相位信息也有的一说,不过自己想法还不成熟,就不献丑啦



However,ifthesignaldoesnothaveafrequencycomponentof"f",theproductwillyieldzero,whichshowsthat,thesignaldoesnothaveafrequencycomponentof"f".Ifthefrequency"f",isnotamajorcomponentofthesignal"x(t)",thentheproductwill
givea(relatively)smallvalue.Thisshowsthat,thefrequencycomponent"f"inthesignal"x",hasasmallamplitude,inotherwords,itisnotamajorcomponentof"x".

Now,notethattheintegrationinthetransformationequation(Eqn.1)isovertime.Thelefthandsideof(1),however,isafunctionoffrequency.Therefore,theintegralin(1),iscalculatedforeveryvalueoff.

IMPORTANT(!)Theinformationprovidedbytheintegral,correspondstoalltimeinstances,sincetheintegrationisfromminusinfinitytoplusinfinityovertime.It
followsthatnomatterwhereintimethecomponentwithfrequency"f"appears,itwillaffecttheresultoftheintegrationequallyaswell.Inotherwords,whetherthefrequencycomponent"f"appearsattimet1ort2,itwillhavethesameeffecton
theintegration.ThisiswhyFouriertransformisnotsuitableifthesignalhastimevaryingfrequency,i.e.,thesignalisnon-stationary.Ifonlythesignalhasthefrequencycomponent"f"atalltimes(forall"t"values),
thentheresultobtainedbytheFouriertransformmakessense.

NotethattheFouriertransformtellswhetheracertainfrequencycomponentexistsornot.Thisinformationisindependentofwhereintimethiscomponentappears.Itisthereforeveryimportanttoknowwhetherasignalisstationaryornot,
priortoprocessingitwiththeFT.

Theexamplegiveninpartoneshouldnowbeclear.Iwouldliketogiveithereagain:

Lookatthefollowingfigure,whichshowsthesignal:

x(t)=cos(2*pi*5*t)+cos(2*pi*10*t)+cos(2*pi*20*t)+cos(2*pi*50*t)
thatis,ithasfourfrequencycomponentsof5,10,20,and50Hz.,alloccurringatalltimes.



Figure2.2
AndhereistheFTofit.Thefrequencyaxishasbeencuthere,buttheoreticallyitextendstoinfinity(forcontinuousFouriertransform(CFT).Actually,herewecalculatethediscreteFouriertransform(DFT),inwhichcasethefrequencyaxisgoesupto(at
least)twicethesamplingfrequencyofthesignal,andthetransformedsignalissymmetrical.However,thisisnotthatimportantatthistime.)



Figure2.3
Notethefourpeaksintheabovefigure,whichcorrespondtofourdifferentfrequencies.

Now,lookatthefollowingfigure:Herethesignalisagainthecosinesignal,andithasthesamefourfrequencies.However,thesecomponentsoccuratdifferenttimes.



Figure2.4
AndhereistheFouriertransformofthissignal:



Figure2.5
Whatyouaresupposedtoseeintheabovefigure,isitis(almost)samewiththepreviousFTfigure.Pleaselookcarefullyandnotethemajorfourpeakscorrespondingto5,10,20,and50Hz.Icouldhavemadethisfigurelookverysimilartotheprevious
one,butIdidnotdothatonpurpose.Thereasonofthenoiselikethinginbetweenpeaksshowthat,thosefrequenciesalsoexistinthesignal.Butthereasontheyhaveasmallamplitude,isbecause,theyarenotmajorspectralcomponentsofthegiven
signal
,andthereasonweseethose,isbecauseofthesuddenchangebetweenthefrequencies.Especiallynotehowtimedomainsignalchangesataroundtime250(ms)(Withsomesuitablefilteringtechniques,thenoise
likepartofthefrequencydomainsignalcanbecleaned,butthishasnotnothingtodowithoursubjectnow.Ifyouneedfurtherinformationpleasesendmeane-mail).

BythistimeyoushouldhaveunderstoodthebasicconceptsofFouriertransform,whenwecanuseitandwecannot.Asyoucanseefromtheaboveexample,FTcannotdistinguishthetwosignalsverywell.ToFT,bothsignalsarethesame,becausetheyconstitute
ofthesamefrequencycomponents.Therefore,FTisnotasuitabletoolforanalyzingnon-stationarysignals,i.e.,signalswithtimevaryingspectra.

Pleasekeepthisveryimportantpropertyinmind.Unfortunately,manypeopleusingtheFTdonotthinkofthis.Theyassumethatthesignaltheyhaveisstationarywhereitisnotinmanypracticalcases.Ofcourseifyouarenotinterestedinatwhat
timesthesefrequencycomponentsoccur
,butonlyinterestedinwhatfrequencycomponentsexist,thenFTcanbeasuitabletooltouse.

So,nowthatweknowthatwecannotuse(well,wecan,butweshouldn't)FTfornon-stationarysignals,whatarewegoingtodo?

Rememberthat,Ihavementionedthatwavelettransformisonly(about)adecadeold.Youmaywonderifresearchersnoticedthisnon-stationaritybusinessonlytenyearsagoornot.

Obviouslynot.

Apparentlytheymusthavedonesomethingaboutitbeforetheyfiguredoutthewavelettransform....?

Well...,theysuredid...

Theyhavecomeupwith...

LINEARTIMEFREQUENCYREPRESENTATIONS(嘿嘿,刚看了徐峥的搞定岳父大人,太好玩了,写在这儿放松下,别建议啊,看好徐峥哦!)

THESHORTTERMFOURIERTRANSFORM

So,howarewegoingtoinsertthistimebusinessintoourfrequencyplots?Let'slookattheprobleminhandlittlemorecloser.

WhatwaswrongwithFT?Itdidnotworkfornon-stationarysignals.Let'sthinkthis:Canweassumethat,someportionofanon-stationarysignalisstationary?

Theanswerisyes.

Justlookatthethirdfigureabove.Thesignalisstationaryevery250timeunitintervals.

Youmayaskthefollowingquestion?

Whatifthepartthatwecanconsidertobestationaryisverysmall?

Well,ifitistoosmall,itistoosmall.Thereisnothingwecandoaboutthat,andactually,thereisnothingwrongwiththateither.Wehavetoplaythisgamewiththephysicists'rules.

Ifthisregionwherethesignalcanbeassumedtobestationaryistoosmall,thenwelookatthatsignalfromnarrowwindows,加窗narrowenoughthattheportionofthesignalseenfromthesewindows
areindeedstationary.


ThisapproachofresearchersendedupwitharevisedversionoftheFouriertransform,so-called:TheShortTimeFourierTransform(STFT).短时傅里叶变换

ThereisonlyaminordifferencebetweenSTFTandFT.InSTFT,thesignalisdividedintosmallenoughsegments,wherethesesegments(portions)ofthesignalcanbeassumedtobestationary.Forthispurpose,awindowfunction"w"ischosen.
Thewidthofthiswindowmustbeequaltothesegmentofthesignalwhereitsstationarityisvalid.

Thiswindowfunctionisfirstlocatedtotheverybeginningofthesignal.Thatis,thewindowfunctionislocatedatt=0.Let'ssupposethatthewidthofthewindowis"T"s.Atthistimeinstant(t=0),thewindow
functionwilloverlapwiththefirstT/2seconds(Iwillassumethatalltimeunitsareinseconds).Thewindowfunctionandthesignalarethenmultiplied.Bydoingthis,onlythefirstT/2secondsofthesignalisbeingchosen,withtheappropriate
weightingofthewindow(ifthewindowisarectangle,withamplitude"1",thentheproductwillbeequaltothesignal).Thenthisproductisassumedtobejustanothersignal,whoseFTistobetaken.Inotherwords,FTofthisproductistaken,justastaking
theFTofanysignal.

TheresultofthistransformationistheFTofthefirstT/2secondsofthesignal.Ifthisportionofthesignalisstationary,asitisassumed,thentherewillbenoproblemandtheobtainedresultwillbeatruefrequencyrepresentation
ofthefirstT/2secondsofthesignal.

Thenextstep,wouldbeshiftingthiswindow(forsomet1seconds)toanewlocation,multiplyingwiththesignal,andtakingtheFToftheproduct.Thisprocedureisfollowed,untiltheendofthesignalisreachedbyshiftingthewindowwith"t1"seconds
intervals.

ThefollowingdefinitionoftheSTFTsummarizesalltheaboveexplanationsinoneline:(MATHisthetoolthatshowtheidea,whatweshouldcareistheideabehinditbutnottheoutersymbolbywhich
ituses,onlymyideas,heihei)




Figure2.6
Pleaselookattheaboveequationcarefully.x(t)isthesignalitself,w(t)isthewindowfunction,and*isthecomplexconjugate.Asyoucanseefromtheequation,theSTFTofthesignalisnothingbut
theFTofthesignalmultipliedbyawindowfunction.

Foreveryt'andfanewSTFTcoefficientiscomputed(Correction:The"t"intheparenthesisofSTFTshouldbe"t'".Iwillcorrectthissoon.IhavejustnoticedthatIhavemistyped
it).上面的公示在这儿作者已有更正了哦!

我看第一眼时也



Thefollowingfiguremayhelpyoutounderstandthisalittlebetter:



Figure2.7
TheGaussian-likefunctionsincolorarethewindowingfunctions.Theredoneshowsthewindowlocatedatt=t1',theblueshowst=t2',andthegreenoneshowsthewindowlocatedatt=t3'.ThesewillcorrespondtothreedifferentFTsatthreedifferenttimes.
Therefore,wewillobtainatruetime-frequencyrepresentation(TFR)ofthesignal.

Probablythebestwayofunderstandingthiswouldbelookingatanexample.Firstofall,sinceourtransformisafunctionofbothtimeandfrequency(unlikeFT,whichisafunctionoffrequencyonly),thetransformwouldbetwodimensional(three,ifyou
counttheamplitudetoo).Let'stakeanon-stationarysignal,suchasthefollowingone:



Figure2.8
Inthissignal,therearefourfrequencycomponentsatdifferenttimes.Theinterval0to250msisasimplesinusoidof300Hz,andtheother250msintervalsaresinusoidsof200Hz,100Hz,and50Hz,respectively.Apparently,thisisanon-stationary
signal.Now,let'slookatitsSTFT:



Figure2.9
Asexpected,thisistwodimensionalplot(3dimensional,ifyoucounttheamplitudetoo).The"x"and"y"axesaretimeandfrequency,respectively.Please,ignorethenumbersontheaxes,sincetheyarenormalizedinsomerespect,whichisnotofanyinterest
tousatthistime.Justexaminetheshapeofthetime-frequencyrepresentation.

Firstofall,notethatthegraphissymmetricwithrespecttomidlineofthefrequencyaxis.Rememberthat,althoughitwasnotshown,FTofarealsignalisalwayssymmetric,sinceSTFTisnothing
butawindowedversionoftheFT,itshouldcomeasnosurprisethatSTFTisalsosymmetricinfrequency.Thesymmetricpartissaidtobeassociatedwithnegativefrequencies,anoddconceptwhichisdifficulttocomprehend,fortunately,itisnotimportant;
itsufficestoknowthatSTFTandFTaresymmetric.

Whatisimportant,arethefourpeaks;notethattherearefourpeakscorrespondingtofourdifferentfrequencycomponents.Alsonotethat,unlikeFT,thesefourpeaksarelocatedatdifferenttimeintervalsalongthetimeaxis.Rememberthat
theoriginalsignalhadfourspectralcomponentslocatedatdifferenttimes.

Nowwehaveatruetime-frequencyrepresentationofthesignal.Wenotonlyknowwhatfrequencycomponentsarepresentinthesignal,butwealsoknowwheretheyarelocatedintime.

Itisgrrrreeeaaatttttt!!!!Right?

Well,notreally!

Youmaywonder,sinceSTFTgivestheTFRofthesignal,whydoweneedthewavelettransform.TheimplicitproblemoftheSTFTisnotobviousintheaboveexample.Ofcourse,anexamplethatwouldworknicelywaschosenonpurposetodemonstratetheconcept.

TheproblemwithSTFTisthefactwhoserootsgobacktowhatisknownasthe
HeisenbergUncertaintyPrinciple(海森堡不确定原理)
.Thisprincipleoriginallyappliedtothemomentumandlocationofmovingparticles,canbeappliedtotime-frequencyinformationofasignal.Simply,thisprinciplestatesthatonecannotknowtheexact
time-frequencyrepresentationofasignal,i.e.,onecannotknowwhatspectralcomponentsexistatwhatinstancesoftimes.Whatonecanknowarethe
timeintervalsinwhichcertainbandoffrequencies
exist,whichisaresolutionproblem.

TheproblemwiththeSTFThassomethingtodowiththewidth
ofthewindowfunctionthatisused.Tobetechnicallycorrect,thiswidthofthewindowfunctionisknownasthesupportofthewindow.Ifthewindowfunctionisnarrow,thanitisknownascompactlysupported.Thisterminology
ismoreoftenusedinthewaveletworld,aswewillseelater.

Hereiswhathappens:

RecallthatintheFTthereisnoresolutionprobleminthefrequencydomain,i.e.,weknowexactlywhatfrequenciesexist;similarlywethereisnotimeresolutionprobleminthetimedomain,sinceweknowthevalueofthesignalateveryinstantoftime.
Conversely,thetimeresolutionintheFT,andthefrequencyresolutioninthetimedomainarezero,sincewehavenoinformationaboutthem.WhatgivestheperfectfrequencyresolutionintheFTisthefactthatthewindowusedintheFTisitskernel,the
exp{jwt}function,whichlastsatalltimesfromminusinfinitytoplusinfinity.Now,inSTFT,ourwindowisoffinitelength,thusitcoversonlyaportionofthesignal,whichcausesthefrequencyresolutiontogetpoorer.
WhatImeanbygettingpooreristhat,wenolongerknowtheexactfrequencycomponentsthatexistinthesignal,butweonlyknowabandoffrequenciesthatexist:

InFT,thekernelfunction,allowsustoobtainperfectfrequencyresolution,becausethekernelitselfisawindowofinfinitelength.InSTFTiswindowisoffinitelength,andwenolongerhaveperfectfrequencyresolution.Youmayask,whydon'twemake
thelengthofthewindowintheSTFTinfinite,justlikeasitisintheFT,togetperfectfrequencyresolution?Well,thanyoulooseallthetimeinformation,youbasicallyendupwiththeFTinsteadofSTFT.Tomakealongstoryrealshort,wearefacedwith
thefollowingdilemma:

Ifweuseawindowofinfinitelength,wegettheFT,whichgivesperfectfrequencyresolution,butnotimeinformation.Furthermore,inordertoobtainthestationarity,wehavetohaveashortenoughwindow,inwhichthesignalisstationary.Thenarrower
wemakethewindow,thebetterthetimeresolution,andbettertheassumptionofstationarity,butpoorerthefrequencyresolution:

Narrowwindow===>goodtimeresolution,poorfrequencyresolution.

Widewindow===>goodfrequencyresolution,poortimeresolution
.(重点)

Inordertoseetheseeffects,let'slookatacoupleexamples:Iwillshowfourwindowsofdifferentlength,andwewillusethesetocomputetheSTFT,andseewhathappens:

ThewindowfunctionweuseissimplyaGaussianfunctionintheform:

w(t)=exp(-a*(t^2)/2);
whereadeterminesthelengthofthewindow,(你可以吧a当成方差的倒数,a越小,方差越大,宽度越大)and
tisthetime.Thefollowingfigureshowsfourwindowfunctionsofvaryingregionsofsupport,determinedbythevalueofa.Pleasedisregardthenumericvaluesofa
sincethetimeintervalwherethisfunctioniscomputedalsodeterminesthefunction.Justnotethelengthofeachwindow.Theaboveexamplegivenwascomputedwiththesecondvalue,a=0.001.IwillnowshowtheSTFTofthesamesignal
givenabovecomputedwiththeotherwindows.



Figure2.10
Firstlet'slookatthefirstmostnarrowwindow.WeexpecttheSTFTtohaveaverygoodtimeresolution,butrelativelypoorfrequencyresolution:



Figure2.11
TheabovefigureshowsthisSTFT.Thefigureisshownfromatopbird-eye(鸟瞰)viewwithanangleforbetterinterpretation.Notethatthefourpeaksarewellseparatedfromeachotherintime.
Alsonotethat,infrequencydomain,everypeakcoversarangeoffrequencies,insteadofasinglefrequencyvalue.
Nowlet'smakethewindowwider,andlookatthethirdwindow
[/u](thesecondonewasalreadyshowninthefirstexample).



Figure2.12
Notethatthepeaksarenotwellseparatedfromeachotherintime,unlikethepreviouscase,however,infrequencydomaintheresolutionismuchbetter.Nowlet'sfurtherincreasethewidthofthewindow,andseewhathappens:



Figure2.13时间精度变得很差了,频率精度确实很高
Well,thisshouldbeofnosurprisetoanyonenow,sincewewouldexpectaterrible(andImeanabsolutelyterrible)timeresolution.

TheseexamplesshouldhaveillustratedtheimplicitproblemofresolutionoftheSTFT.
AnyonewhowouldliketouseSTFTisfacedwiththisproblemofresolution.Whatkindofawindowtouse?Narrowwindowsgivegoodtimeresolution,butpoorfrequencyresolution.
Widewindowsgivegoodfrequencyresolution,butpoortimeresolution;furthermore,
widewindowsmayviolatetheconditionofstationarity.Theproblem,ofcourse,isaresultofchoosingawindowfunction,onceandforall,andusethatwindowintheentireanalysis.Theanswer,of
course,isapplicationdependent:(这是与应用相关的)Ifthefrequencycomponentsarewellseparatedfromeachotherintheoriginalsignal,thanwemaysacrificesomefrequencyresolutionandgoforgoodtimeresolution,sincethespectralcomponentsarealreadywell
separatedfromeachother.However,ifthisisnotthecase,thenagoodwindowfunction,couldbemoredifficultthanfindingagoodstocktoinvestin.(一些指导性意见)

Bynow,youshouldhaverealizedhowwavelettransformcomesintoplay.TheWavelettransform(WT)solvesthedilemmaofresolutiontoacertainextent,aswewillseeinthenextpart.(哈哈,这个尴尬铸就了小波的诞生)

ThiscompletesPartIIofthistutorial.ThecontinuouswavelettransformisthesubjectofthePartIIIofthistutorial.Ifyoudidnothavemuchtroubleincomingthisfar,andwhathavebeenwrittenabovemakesensetoyou,youarenowreadytotake
theultimatechallengeinunderstandingthebasicconceptsofthewavelettheory.





                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: