123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447 |
- //============================================================================
- // Name : 1D/2D Wavelet Transform
- // Author : Rafat Hussain
- // Version :
- // Copyright : GNU Lesser GPL License
- // Description : Wavelet Library
- //============================================================================
- /*Copyright (C) 2011 Rafat Hussain
-
- * This program is free software; you can redistribute it and/or modify it under the terms of
- * the GNU General Public License as published by the Free Software Foundation; version 2 or any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- *You should have received a copy of the GNU General Public License
- *along with this program; if not, write to the Free Software
- *Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
- #if defined(TARGET_HAS_ThirdPartyFFTW3)
-
- #include "wavelet2s.h"
- #include <iostream>
- #include <complex>
- #include <utility>
- #include <vector>
- #include <string>
- #include <cmath>
- #include <algorithm>
- #include <cstdlib>
- #include "fftw3.h"
-
- // extern "C" int _get_output_format( void ){ return 0; }
-
- fftw_plan plan_forward_inp, plan_forward_filt, plan_backward;
- static std::size_t fftTransientSize = 0;
-
-
- void* per_ext2d(std::vector<std::vector<double>>& signal, std::vector<std::vector<double>>& temp2, const int a)
- {
- const std::size_t rows = signal.size();
- const std::size_t cols = signal[0].size();
- const std::size_t cols2 = (cols % 2) != 0 ? cols + 1 : cols;
- std::vector<std::vector<double>> tempVec(rows, std::vector<double>(cols2 + 2 * a));
-
- for (std::size_t i = 0; i < rows; ++i)
- {
- std::vector<double> sig;
- for (std::size_t j = 0; j < cols; ++j)
- {
- double temp = signal[i][j];
- sig.push_back(temp);
- }
- per_ext(sig, a);
- for (std::size_t j = 0; j < sig.size(); ++j) { tempVec[i][j] = sig[j]; }
- }
- for (std::size_t j = 0; j < tempVec[0].size(); ++j)
- {
- std::vector<double> sig;
- for (std::size_t i = 0; i < rows; ++i)
- {
- double temp = tempVec[i][j];
- sig.push_back(temp);
- }
- per_ext(sig, a);
- for (std::size_t i = 0; i < sig.size(); ++i) { temp2[i][j] = sig[i]; }
- }
-
-
- return nullptr;
- }
-
- void* swt_2d(std::vector<std::vector<double>>& sig, int J, const std::string& nm, std::vector<double>& swtOutput)
- {
- std::size_t m = sig.size(); // No. of rows
- std::size_t n = sig[0].size(); //No. of columns
-
- //std::vector<std::vector<double>> sig2 = sig;
-
- std::size_t nRows = m;
- std::size_t nCols = n;
- std::vector<double> lp1, hp1, lp2, hp2;
- filtcoef(nm, lp1, hp1, lp2, hp2);
-
- for (std::size_t it = 0; it < std::size_t(J); ++it)
- {
- int U = int(pow(2.0, double(it)));
- std::vector<double> lowPass, highPass;
- if (it > 0)
- {
- upsamp(lp1, U, lowPass);
- upsamp(hp1, U, highPass);
- }
- else
- {
- lowPass = lp1;
- highPass = hp1;
- }
- int lf = lowPass.size();
-
- if ((sig.size() % 2) == 0) { nRows = sig.size(); }
- else { nRows = sig.size() + 1; }
-
- if ((sig[0].size() % 2) == 0) { nCols = sig[0].size(); }
- else { nCols = sig[0].size() + 1; }
-
- std::vector<std::vector<double>> signal(nRows + lf, std::vector<double>(nCols + lf));
- // per_ext2d(sig,signal,lf/2); Edit per_ext if you want to use per_ext2d. Remove
- // the even indexing.
-
- per_ext2d(sig, signal, lf / 2);
- std::size_t lenX = signal.size();
- std::size_t lenY = signal[0].size();
- std::vector<std::vector<double>> sigL(nRows + lf, std::vector<double>(nCols));
- std::vector<std::vector<double>> sigH(nRows + lf, std::vector<double>(nCols));
- std::vector<std::vector<double>> cA(nRows, std::vector<double>(nCols));
- std::vector<std::vector<double>> cH(nRows, std::vector<double>(nCols));
- std::vector<std::vector<double>> cV(nRows, std::vector<double>(nCols));
- std::vector<std::vector<double>> cD(nRows, std::vector<double>(nCols));
-
- for (std::size_t i = 0; i < lenX; ++i)
- {
- std::vector<double> tempRow;
- for (std::size_t j = 0; j < lenY; ++j) { tempRow.push_back(signal[i][j]); }
-
- // ------------------Low Pass Branch--------------------------
- std::vector<double> oup;
- convfftm(tempRow, lowPass, oup);
- oup.erase(oup.begin(), oup.begin() + lf);
- oup.erase(oup.begin() + nCols, oup.end());
-
- // ------------------High Pass Branch--------------------------
- std::vector<double> oup2;
- convfftm(tempRow, highPass, oup2);
- oup2.erase(oup2.begin(), oup2.begin() + lf);
- oup2.erase(oup2.begin() + nCols, oup2.end());
-
- tempRow.clear();
-
- for (std::size_t j = 0; j < oup.size(); ++j)
- {
- sigL[i][j] = oup[j];
- sigH[i][j] = oup2[j];
- }
- }
-
- for (std::size_t j = 0; j < nCols; ++j)
- {
- std::vector<double> tempRow;
- for (std::size_t i = 0; i < lenX; ++i) { tempRow.push_back(sigL[i][j]); }
-
- // ------------------Low Pass Branch--------------------------
-
-
- std::vector<double> oup;
- convfftm(tempRow, lowPass, oup);
- oup.erase(oup.begin(), oup.begin() + lf);
- oup.erase(oup.begin() + nRows, oup.end());
-
- // ------------------High Pass Branch--------------------------
-
- std::vector<double> oup2;
- convfftm(tempRow, highPass, oup2);
- oup2.erase(oup2.begin(), oup2.begin() + lf);
- oup2.erase(oup2.begin() + nRows, oup2.end());
-
- tempRow.clear();
-
-
- for (std::size_t i = 0; i < oup.size(); ++i) { cA[i][j] = oup[i]; }
- for (std::size_t i = 0; i < oup2.size(); ++i) { cH[i][j] = oup2[i]; }
- }
-
- for (std::size_t j = 0; j < nCols; ++j)
- {
- std::vector<double> tempRow;
- for (std::size_t i = 0; i < lenX; ++i) { tempRow.push_back(sigH[i][j]); }
-
- // ------------------Low Pass Branch--------------------------
- std::vector<double> oup;
- convfftm(tempRow, lowPass, oup);
- oup.erase(oup.begin(), oup.begin() + lf);
- oup.erase(oup.begin() + nRows, oup.end());
-
- // ------------------High Pass Branch--------------------------
- std::vector<double> oup2;
- convfftm(tempRow, highPass, oup2);
- oup2.erase(oup2.begin(), oup2.begin() + lf);
- oup2.erase(oup2.begin() + nRows, oup2.end());
-
- tempRow.clear();
-
-
- for (std::size_t i = 0; i < oup.size(); ++i) { cV[i][j] = oup[i]; }
- for (std::size_t i = 0; i < oup2.size(); ++i) { cD[i][j] = oup2[i]; }
- }
-
- sig = cA;
- std::vector<double> tempSig2;
-
- if (it == std::size_t(J - 1)) { for (std::size_t i = 0; i < nRows; ++i) { for (std::size_t j = 0; j < nCols; ++j) { tempSig2.push_back(cA[i][j]); } } }
- for (std::size_t i = 0; i < nRows; ++i) { for (std::size_t j = nCols; j < nCols * 2; ++j) { tempSig2.push_back(cH[i][j - nCols]); } }
- for (std::size_t i = nRows; i < nRows * 2; ++i) { for (std::size_t j = 0; j < nCols; ++j) { tempSig2.push_back(cV[i - nRows][j]); } }
- for (std::size_t i = nRows; i < nRows * 2; ++i) { for (std::size_t j = nCols; j < nCols * 2; ++j) { tempSig2.push_back(cD[i - nRows][j - nCols]); } }
-
- swtOutput.insert(swtOutput.begin(), tempSig2.begin(), tempSig2.end());
- }
-
- return nullptr;
- }
-
-
- void* per_ext(std::vector<double>& sig, const int a)
- {
- std::size_t len = sig.size();
- if ((len % 2) != 0)
- {
- sig.push_back(sig[len - 1]);
- len = sig.size();
- }
-
- for (std::size_t i = 0; i < std::size_t(a); ++i)
- {
- double temp1 = sig[2 * i];
- double temp2 = sig[len - 1];
- sig.insert(sig.begin(), temp2);
- sig.insert(sig.end(), temp1);
- }
-
- return nullptr;
- }
-
-
- void* iswt(std::vector<double>& swtop, int J, const std::string& nm, std::vector<double>& iswtOutput)
- {
- std::size_t n = swtop.size() / (J + 1);
-
- std::vector<double> lpd, hpd, lpr, hpr;
- filtcoef(nm, lpd, hpd, lpr, hpr);
-
- std::vector<double> appxSig;
-
- std::vector<double> lowPass = lpr;
- std::vector<double> highPass = hpr;
- int lf = lowPass.size();
-
- for (std::size_t iter = 0; iter < std::size_t(J); ++iter)
- {
- std::vector<double> detSig;
- if (iter == 0)
- {
- for (std::size_t i = 0; i < n; ++i)
- {
- double temp = swtop[i];
- appxSig.push_back(temp);
- double temp1 = swtop[(iter + 1) * n + i];
- detSig.push_back(temp1);
- }
- }
- else
- {
- for (std::size_t i = 0; i < n; ++i)
- {
- double temp1 = swtop[(iter + 1) * n + i];
- detSig.push_back(temp1);
- }
- }
-
-
- std::size_t value = std::size_t(pow(2.0, double(J - 1 - iter)));
- iswtOutput.assign(n, 0.0);
-
- for (std::size_t count = 0; count < value; ++count)
- {
- std::vector<double> appx1, det1;
- for (std::size_t index = count; index < n; index += value)
- {
- double temp = appxSig[index];
- appx1.push_back(temp);
- double temp1 = detSig[index];
- det1.push_back(temp1);
- }
- std::size_t len = appx1.size();
-
- // Shift = 0
-
- std::vector<double> appx2, det2;
-
- for (std::size_t i = 0; i < len; i += 2)
- {
- double temp = appx1[i];
- appx2.push_back(temp);
- double temp1 = det1[i];
- det2.push_back(temp1);
- }
-
- int U = 2; // Upsampling Factor
-
- std::vector<double> cL0, cH0;
- upsamp(appx2, U, cL0);
- upsamp(det2, U, cH0);
- per_ext(cL0, lf / 2);
- per_ext(cH0, lf / 2);
-
- std::vector<double> oup00L, oup00H, oup00;
- convfft(cL0, lowPass, oup00L);
- convfft(cH0, highPass, oup00H);
-
- oup00L.erase(oup00L.begin(), oup00L.begin() + lf - 1);
- oup00L.erase(oup00L.begin() + len, oup00L.end());
- oup00H.erase(oup00H.begin(), oup00H.begin() + lf - 1);
- oup00H.erase(oup00H.begin() + len, oup00H.end());
-
- vecsum(oup00L, oup00H, oup00);
-
- // Shift = 1
-
- std::vector<double> appx3, det3;
-
- for (std::size_t i = 1; i < len; i += 2)
- {
- double temp = appx1[i];
- appx3.push_back(temp);
- double temp1 = det1[i];
- det3.push_back(temp1);
- }
-
-
- std::vector<double> cL1, cH1;
- upsamp(appx3, U, cL1);
- upsamp(det3, U, cH1);
- per_ext(cL1, lf / 2);
- per_ext(cH1, lf / 2);
-
- std::vector<double> oup01L, oup01H, oup01;
- convfft(cL1, lowPass, oup01L);
- convfft(cH1, highPass, oup01H);
-
- oup01L.erase(oup01L.begin(), oup01L.begin() + lf - 1);
- oup01L.erase(oup01L.begin() + len, oup01L.end());
- oup01H.erase(oup01H.begin(), oup01H.begin() + lf - 1);
- oup01H.erase(oup01H.begin() + len, oup01H.end());
-
- vecsum(oup01L, oup01H, oup01);
- circshift(oup01, -1);
-
- // Continue
- std::size_t index2 = 0;
- for (std::size_t index = count; index < n; index += value)
- {
- double temp = oup00[index2] + oup01[index2];
- iswtOutput.at(index) = temp / 2;
- index2++;
- }
- }
- appxSig = iswtOutput;
- }
- return nullptr;
- }
-
- void* swt(std::vector<double>& signal1, const int J, const std::string& nm, std::vector<double>& swtOutput, int& length)
- {
- std::vector<double> lpd, hpd, lpr, hpr;
- std::vector<double> sig = signal1;
-
- const std::size_t n = sig.size();
- length = int(n);
-
- filtcoef(nm, lpd, hpd, lpr, hpr);
-
- for (std::size_t iter = 0; iter < std::size_t(J); ++iter)
- {
- std::vector<double> lowPass;
- std::vector<double> highPass;
- if (iter > 0)
- {
- const int m = int(pow(2.0, iter));
- upsamp(lpd, m, lowPass);
- upsamp(hpd, m, highPass);
- }
- else
- {
- lowPass = lpd;
- highPass = hpd;
- }
-
- const std::size_t lenFilt = lowPass.size();
- per_ext(sig, int(lenFilt / 2));
-
- std::vector<double> cA;
- convfft(sig, lowPass, cA);
- std::vector<double> cD;
- convfft(sig, highPass, cD);
- // Resize cA and cD
- cA.erase(cA.begin(), cA.begin() + lenFilt);
- cA.erase(cA.begin() + n, cA.end());
- cD.erase(cD.begin(), cD.begin() + lenFilt);
- cD.erase(cD.begin() + n, cD.end());
- // Reset signal value;
-
- sig = cA;
-
- if (iter == std::size_t(J - 1))
- {
- swtOutput.insert(swtOutput.begin(), cD.begin(), cD.end());
- swtOutput.insert(swtOutput.begin(), cA.begin(), cA.end());
- }
- else { swtOutput.insert(swtOutput.begin(), cD.begin(), cD.end()); }
- }
-
- return nullptr;
- }
-
- void* DwtOutputDimSym(std::vector<std::size_t>& length, std::vector<std::size_t>& length2, const int J)
- {
- const std::size_t sz = length.size();
- std::size_t rows = length[sz - 2];
- std::size_t cols = length[sz - 1];
- for (std::size_t i = 0; i < std::size_t(J); ++i)
- {
- rows = std::size_t(ceil(double(rows) / 2.0));
- cols = std::size_t(ceil(double(cols) / 2.0));
- }
- for (std::size_t i = 0; i < std::size_t(J + 1); ++i)
- {
- length2.push_back(rows);
- length2.push_back(cols);
- rows = rows * 2;
- cols = cols * 2;
- }
- return nullptr;
- }
-
- void* dwt_output_dim2(std::vector<std::size_t>& length, std::vector<std::size_t>& length2, const int j)
- {
- std::size_t row = length[0];
- std::size_t col = length[1];
-
- for (std::size_t i = 0; i < std::size_t(j + 1); ++i)
- {
- length2.push_back(row);
- length2.push_back(col);
- row = row * 2;
- col = col * 2;
- }
-
-
- return nullptr;
- }
-
- void* dispDWT(std::vector<double>& output, std::vector<std::vector<double>>& dwtdisp, std::vector<std::size_t>& length, std::vector<std::size_t>& length2, const int J)
- {
- std::size_t sum = 0;
-
- for (std::size_t it = 0; it < std::size_t(J); ++it)
- {
- const int dRows = int(length[2 * it] - length2[2 * it]);
- const int dCols = int(length[2 * it + 1] - length2[2 * it + 1]);
-
- const std::size_t nRows = length[2 * it];
- const std::size_t nCols = length[2 * it + 1];
- std::vector<std::vector<double>> oDwt(2 * nRows, std::vector<double>(2 * nCols));
- if (it == 0)
- {
- for (std::size_t i = 0; i < nRows; ++i) { for (std::size_t j = 0; j < nCols; ++j) { oDwt[i][j] = output[i * nCols + j]; } }
-
- for (std::size_t i = 0; i < nRows; ++i)
- {
- for (std::size_t j = nCols; j < nCols * 2; ++j) { oDwt[i][j] = output[nRows * nCols + i * nCols + (j - nCols)]; }
- }
-
- for (std::size_t i = nRows; i < nRows * 2; ++i)
- {
- for (std::size_t j = 0; j < nCols; ++j) { oDwt[i][j] = output[2 * nRows * nCols + (i - nRows) * nCols + j]; }
- }
-
-
- for (std::size_t i = nRows; i < nRows * 2; ++i)
- {
- for (std::size_t j = nCols; j < nCols * 2; ++j) { oDwt[i][j] = output[3 * nRows * nCols + (i - nRows) * nCols + (j - nCols)]; }
- }
- }
- else
- {
- for (std::size_t i = 0; i < nRows; ++i) { for (std::size_t j = nCols; j < nCols * 2; ++j) { oDwt[i][j] = output[sum + i * nCols + (j - nCols)]; } }
-
- for (std::size_t i = nRows; i < nRows * 2; ++i)
- {
- for (std::size_t j = 0; j < nCols; ++j) { oDwt[i][j] = output[sum + nRows * nCols + (i - nRows) * nCols + j]; }
- }
-
-
- for (std::size_t i = nRows; i < nRows * 2; ++i)
- {
- for (std::size_t j = nCols; j < nCols * 2; ++j) { oDwt[i][j] = output[sum + 2 * nRows * nCols + (i - nRows) * nCols + (j - nCols)]; }
- }
- }
-
- const std::size_t rowsX = length2[2 * it];
- const std::size_t colsX = length2[2 * it + 1];
-
- const int dCols2 = int(ceil(double(dCols - 1) / 2.0));
- const int dRows2 = int(ceil(double(dRows - 1) / 2.0));
- if (it == 0)
- {
- for (std::size_t i = 0; i < rowsX; ++i)
- {
- for (std::size_t j = 0; j < colsX; ++j)
- {
- if (i + dRows - 1 < 0) { dwtdisp[i][j] = 0; }
- else if (j + dCols - 1 < 0) { dwtdisp[i][j] = 0; }
- else { dwtdisp[i][j] = oDwt[i + dRows - 1][j + dCols - 1]; }
- }
- }
- }
- for (std::size_t i = 0; i < rowsX; ++i)
- {
- for (std::size_t j = colsX; j < colsX * 2; ++j)
- {
- if (i + dRows2 < 0) { dwtdisp[i][j] = 0; }
- else if (int(j + 2 * (dCols - 1) + 1) > signed(oDwt[0].size()) - 1) { dwtdisp[i][j] = 0; }
- else { dwtdisp[i][j] = oDwt[i + dRows2][j + 2 * (dCols - 1) + 1]; }
- }
- }
-
- for (std::size_t i = rowsX; i < rowsX * 2; ++i)
- {
- for (std::size_t j = 0; j < colsX; ++j)
- {
- if (int(i + 2 * (dRows - 1) + 1) > signed(oDwt.size()) - 1) { dwtdisp[i][j] = 0; }
- else if (j + dCols2 < 0) { dwtdisp[i][j] = 0; }
- else { dwtdisp[i][j] = oDwt[i + 2 * (dRows - 1) + 1][j + dCols2]; }
- }
- }
-
- for (std::size_t i = rowsX; i < rowsX * 2; ++i)
- {
- for (std::size_t j = colsX; j < colsX * 2; ++j)
- {
- if (int(i + (dRows - 1) + 1 + dRows2) > signed(oDwt.size()) - 1) { dwtdisp[i][j] = 0; }
- else if (int(j + (dCols - 1) + 1 + dCols2) > signed(oDwt[0].size()) - 1) { dwtdisp[i][j] = 0; }
- else { dwtdisp[i][j] = oDwt[i + (dRows - 1) + 1 + dRows2][j + (dCols - 1) + 1 + dCols2]; }
- }
- }
- if (it == 0) { sum += 4 * nRows * nCols; }
- else { sum += 3 * nRows * nCols; }
- }
-
- return nullptr;
- }
-
- void symm_ext2d(std::vector<std::vector<double>>& signal, std::vector<std::vector<double>>& temp2, const int a)
- {
- const std::size_t rows = signal.size();
- const std::size_t cols = signal[0].size();
- std::vector<std::vector<double>> tempVec(rows, std::vector<double>(cols + 2 * a));
-
- for (std::size_t i = 0; i < rows; ++i)
- {
- std::vector<double> sig;
- for (std::size_t j = 0; j < cols; ++j)
- {
- double temp = signal[i][j];
- sig.push_back(temp);
- }
- symm_ext(sig, a);
- for (std::size_t j = 0; j < sig.size(); ++j) { tempVec[i][j] = sig[j]; }
- }
- for (std::size_t j = 0; j < tempVec[0].size(); ++j)
- {
- std::vector<double> sig;
- for (std::size_t i = 0; i < rows; ++i)
- {
- double temp = tempVec[i][j];
- sig.push_back(temp);
- }
- symm_ext(sig, a);
- for (std::size_t i = 0; i < sig.size(); ++i) { temp2[i][j] = sig[i]; }
- }
- }
-
- void* circshift2d(std::vector<std::vector<double>>& signal, const int x, const int y)
- {
- const std::size_t rows = signal.size();
- const std::size_t cols = signal[0].size();
- std::vector<std::vector<double>> tempVec(rows, std::vector<double>(cols));
-
- for (std::size_t i = 0; i < rows; ++i)
- {
- std::vector<double> sig;
- for (std::size_t j = 0; j < cols; ++j)
- {
- double temp = signal[i][j];
- sig.push_back(temp);
- }
- circshift(sig, x);
- for (std::size_t j = 0; j < cols; ++j) { tempVec[i][j] = sig[j]; }
- }
-
- for (std::size_t j = 0; j < cols; ++j)
- {
- std::vector<double> sig;
- for (std::size_t i = 0; i < rows; ++i)
- {
- double temp = tempVec[i][j];
- sig.push_back(temp);
- }
- circshift(sig, y);
- for (std::size_t i = 0; i < rows; ++i) { signal[i][j] = sig[i]; }
- }
- return nullptr;
- }
-
- void* idwt_2d_sym(std::vector<double>& dwtop, std::vector<double>& flag, const std::string& nm, std::vector<std::vector<double>>& idwtOutput, std::vector<std::size_t>& length)
- {
- int J = int(flag[0]);
- std::size_t rows = length[0];
- std::size_t cols = length[1];
-
- std::size_t sumCoef = 0;
- std::vector<double> lp1, hp1, lp2, hp2;
- filtcoef(nm, lp1, hp1, lp2, hp2);
- std::size_t lf = lp1.size();
- std::vector<std::vector<double>> cLL(rows, std::vector<double>(cols));
-
-
- for (std::size_t it = 0; it < std::size_t(J); ++it)
- {
- std::size_t nRows = length[2 * it];
- std::size_t nCols = length[2 * it + 1];
-
- std::vector<std::vector<double>> cLH(nRows, std::vector<double>(nCols));
- std::vector<std::vector<double>> cHL(nRows, std::vector<double>(nCols));
- std::vector<std::vector<double>> cHH(nRows, std::vector<double>(nCols));
-
- for (std::size_t i = 0; i < nRows; ++i)
- {
- for (std::size_t j = 0; j < nCols; ++j)
- {
- if (it == 0)
- {
- cLL[i][j] = dwtop[sumCoef + i * nCols + j];
- cLH[i][j] = dwtop[sumCoef + nRows * nCols + i * nCols + j];
- cHL[i][j] = dwtop[sumCoef + 2 * nRows * nCols + i * nCols + j];
- cHH[i][j] = dwtop[sumCoef + 3 * nRows * nCols + i * nCols + j];
- }
- else
- {
- cLH[i][j] = dwtop[sumCoef + i * nCols + j];
- cHL[i][j] = dwtop[sumCoef + nRows * nCols + i * nCols + j];
- cHH[i][j] = dwtop[sumCoef + 2 * nRows * nCols + i * nCols + j];
- }
- }
- }
-
-
- // temp_A = cLL;
- // idwt2_sym(nm,idwtOutput2, cA, cH,cV,cD);
-
- std::size_t lenX = cLH.size();
- std::size_t lenY = cLH[0].size();
-
- // Row Upsampling and Column Filtering at the first LP Stage
- std::vector<std::vector<double>> cL(2 * lenX - lf + 2, std::vector<double>(lenY));
- std::vector<std::vector<double>> cH(2 * lenX - lf + 2, std::vector<double>(lenY));
-
- if (it == 0)
- {
- for (std::size_t j = 0; j < lenY; ++j)
- {
- std::vector<double> sigLL, sigLH, oup;
-
- for (std::size_t i = 0; i < lenX; ++i)
- {
- double temp1 = cLL[i][j];
- double temp2 = cLH[i][j];
- sigLL.push_back(temp1);
- sigLH.push_back(temp2);
- }
- idwt1_sym_m(nm, oup, sigLL, sigLH);
-
- for (std::size_t i = 0; i < oup.size(); ++i) { cL[i][j] = oup[i]; }
- }
- }
- else
- {
- std::size_t rows1 = cLH.size();
- std::size_t cols1 = cLH[0].size();
-
- for (std::size_t j = 0; j < cols1; ++j)
- {
- std::vector<double> tempL1, tempL2, oup;
- for (std::size_t i = 0; i < rows1; ++i)
- {
- double temp = cLL[i][j];
- tempL1.push_back(temp);
-
- double temp2 = cLH[i][j];
- tempL2.push_back(temp2);
- }
- idwt1_sym_m(nm, oup, tempL1, tempL2);
-
- for (std::size_t i = 0; i < oup.size(); ++i) { cL[i][j] = oup[i]; }
- }
- }
-
-
- for (std::size_t j = 0; j < lenY; ++j)
- {
- std::vector<double> sigHL, sigHH, oup2;
- for (std::size_t i = 0; i < lenX; ++i)
- {
- double temp3 = cHL[i][j];
- double temp4 = cHH[i][j];
- sigHL.push_back(temp3);
- sigHH.push_back(temp4);
- }
- idwt1_sym_m(nm, oup2, sigHL, sigHH);
-
- for (std::size_t i = 0; i < oup2.size(); ++i) { cH[i][j] = oup2[i]; }
- }
-
- std::vector<std::vector<double>> signal(2 * lenX - lf + 2, std::vector<double>(2 * lenY - lf + 2));
- for (std::size_t i = 0; i < 2 * lenX - lf + 2; ++i)
- {
- std::vector<double> sigL, sigH, oup;
- for (std::size_t j = 0; j < lenY; ++j)
- {
- double temp5 = cL[i][j];
- double temp6 = cH[i][j];
- sigL.push_back(temp5);
- sigH.push_back(temp6);
- }
- idwt1_sym_m(nm, oup, sigL, sigH);
-
- for (std::size_t j = 0; j < oup.size(); ++j) { signal[i][j] = oup[j]; }
- }
-
-
- idwtOutput = signal;
-
-
- if (it == 0) { sumCoef += 4 * nRows * nCols; }
- else { sumCoef += 3 * nRows * nCols; }
- cLL = signal;
- }
-
-
- return nullptr;
- }
-
-
- void* dwt2_sym(const std::string& name, std::vector<std::vector<double>>& signal, std::vector<std::vector<double>>& cLL, std::vector<std::vector<double>>& cLH,
- std::vector<std::vector<double>>& cHL, std::vector<std::vector<double>>& cHH)
- {
- //Analysis
- const std::size_t rows = signal.size();
- std::size_t cols = signal[0].size();
- const std::size_t colsLp1 = cLL[0].size();
- const std::size_t colsHp1 = cLL[0].size();
- std::vector<double> lp1, hp1, lp2, hp2;
- filtcoef(name, lp1, hp1, lp2, hp2);
- std::vector<std::vector<double>> lpDn1(rows, std::vector<double>(colsLp1));
- std::vector<std::vector<double>> hpDn1(rows, std::vector<double>(colsHp1));
-
- // Implementing row filtering and column downsampling in each branch.
- for (std::size_t i = 0; i < rows; ++i)
- {
- std::vector<double> tempRow, oupLp, oupHp;
- for (std::size_t j = 0; j < cols; ++j)
- {
- double temp = signal[i][j];
- tempRow.push_back(temp);
- }
- dwt1_sym_m(name, tempRow, oupLp, oupHp);
-
- for (std::size_t j = 0; j < oupLp.size(); ++j)
- {
- lpDn1[i][j] = oupLp[j];
- hpDn1[i][j] = oupHp[j];
- }
- }
-
-
- cols = colsLp1;
- // Implementing column filtering and row downsampling in Low Pass branch.
-
- for (std::size_t j = 0; j < cols; ++j)
- {
- std::vector<double> tempRow3, oupLp, oupHp;
- for (std::size_t i = 0; i < rows; ++i)
- {
- double temp = lpDn1[i][j];
- tempRow3.push_back(temp);
- }
- dwt1_sym_m(name, tempRow3, oupLp, oupHp);
-
- for (std::size_t i = 0; i < oupLp.size(); ++i)
- {
- cLL[i][j] = oupLp[i];
- cLH[i][j] = oupHp[i];
- }
- }
-
-
- // Implementing column filtering and row downsampling in High Pass branch.
-
- for (std::size_t j = 0; j < cols; ++j)
- {
- std::vector<double> tempRow5, oupLp, oupHp;
- for (std::size_t i = 0; i < rows; ++i)
- {
- double temp = hpDn1[i][j];
- tempRow5.push_back(temp);
- }
- dwt1_sym_m(name, tempRow5, oupLp, oupHp);
-
- for (std::size_t i = 0; i < oupLp.size(); ++i)
- {
- cHL[i][j] = oupLp[i];
- cHH[i][j] = oupHp[i];
- }
- }
- return nullptr;
- }
-
-
- void* dwt_2d_sym(std::vector<std::vector<double>>& origsig, const int J, const std::string& nm, std::vector<double>& dwtOutput, std::vector<double>& flag, std::vector<std::size_t>& length)
- {
- // flag will contain
-
- std::vector<std::vector<double>> sig = origsig;
- std::size_t nRows = sig.size(); // No. of rows
- std::size_t nCols = sig[0].size(); //No. of columns
- std::vector<std::vector<double>> originalCopy = sig;
- const int maxIter = std::min(int(ceil(log(double(sig.size())) / log(2.0))), int(ceil(log(double(sig[0].size())) / log(2.0))));
- if (maxIter < J)
- {
- std::cout << J << " Iterations are not possible with signals of this dimension " << std::endl;
- exit(1);
- }
- std::vector<double> lp1, hp1, lp2, hp2;
-
- flag.push_back(double(J));
-
-
- length.insert(length.begin(), nCols);
- length.insert(length.begin(), nRows);
-
-
- // Flag Values
- /*
- double temp = (double) (sig2.size() - sig.size()); // Number of zeropad rows
- flag.push_back(temp);
- double temp2 = (double) (sig2[0].size() - sig[0].size());// Number of zpad cols
- flag.push_back(temp2);
- flag.push_back((double) J); // Number of Iterations
- */
- std::size_t sumCoef = 0;
- for (std::size_t iter = 0; iter < std::size_t(J); ++iter)
- {
- filtcoef(nm, lp1, hp1, lp2, hp2);
- const std::size_t lf = lp1.size();
-
- nRows = std::size_t(floor(double(nRows + lf - 1) / 2));
- nCols = std::size_t(floor(double(nCols + lf - 1) / 2));
- length.insert(length.begin(), nCols);
- length.insert(length.begin(), nRows);
-
- std::vector<std::vector<double>> cA(nRows, std::vector<double>(nCols));
- std::vector<std::vector<double>> cH(nRows, std::vector<double>(nCols));
- std::vector<std::vector<double>> cV(nRows, std::vector<double>(nCols));
- std::vector<std::vector<double>> cD(nRows, std::vector<double>(nCols));
-
- if (iter == 0) { dwt2_sym(nm, originalCopy, cA, cH, cV, cD); }
- else { dwt2_sym(nm, originalCopy, cA, cH, cV, cD); }
- std::vector<double> tempSig2;
-
- originalCopy = cA;
- if (iter == std::size_t(J - 1))
- {
- for (std::size_t i = 0; i < nRows; ++i)
- {
- for (std::size_t j = 0; j < nCols; ++j)
- {
- double temp = cA[i][j];
- tempSig2.push_back(temp);
- }
- }
- }
- for (std::size_t i = 0; i < nRows; ++i)
- {
- for (std::size_t j = nCols; j < nCols * 2; ++j)
- {
- double temp = cH[i][j - nCols];
- tempSig2.push_back(temp);
- }
- }
-
- for (std::size_t i = nRows; i < nRows * 2; ++i)
- {
- for (std::size_t j = 0; j < nCols; ++j)
- {
- double temp = cV[i - nRows][j];
- tempSig2.push_back(temp);
- }
- }
-
- for (std::size_t i = nRows; i < nRows * 2; ++i)
- {
- for (std::size_t j = nCols; j < nCols * 2; ++j)
- {
- double temp = cD[i - nRows][j - nCols];
- tempSig2.push_back(temp);
- }
- }
-
- dwtOutput.insert(dwtOutput.begin(), tempSig2.begin(), tempSig2.end());
- sumCoef += 4 * nRows * nCols;
- }
- /*
- ofstream dwt2out("dwt2out.dat");
- for (std::size_t i= 0; i < dwtOutput.size(); ++i){ dwt2out << dwtOutput[i] <<endl; }
- */
-
- return nullptr;
- }
-
-
- void* idwt1_sym(const std::string& wname, std::vector<double>& x, std::vector<double>& app, std::vector<double>& detail)
- {
- std::vector<double> flag;
- std::vector<double> idwtOutput;
- std::vector<std::size_t> length;
- length[0] = app.size();
- length[1] = detail.size();
- std::vector<double> dwtop = app;
- dwtop.insert(dwtop.end(), detail.begin(), detail.end());
- flag.push_back(1);
- flag.push_back(0);
- idwt_sym(dwtop, flag, wname, idwtOutput, length);
- x = idwtOutput;
-
- return nullptr;
- }
-
- void* idwt1_sym_m(const std::string& wname, std::vector<double>& x, std::vector<double>& app, std::vector<double>& detail)
- {
- const int U = 2; // Upsampling Factor
- std::vector<double> lpd1, hpd1, lpr1, hpr1;
-
- filtcoef(wname, lpd1, hpd1, lpr1, hpr1);
- const std::size_t lf = lpr1.size();
-
- // Operations in the Low Frequency branch of the Synthesis Filter Bank
- std::vector<double> xLp, cAUp;
- upsamp(app, U, cAUp);
- cAUp.pop_back();
- convfftm(cAUp, lpr1, xLp);
-
-
- // Operations in the High Frequency branch of the Synthesis Filter Bank
- std::vector<double> xHp, cDUp;
- upsamp(detail, U, cDUp);
- cDUp.pop_back();
- convfftm(cDUp, hpr1, xHp);
-
-
- vecsum(xLp, xHp, x);
-
- x.erase(x.begin(), x.begin() + lf - 2);
- x.erase(x.end() - (lf - 2), x.end());
-
- return nullptr;
- }
-
-
- void* symm_ext(std::vector<double>& sig, const int a)
- {
- const std::size_t len = sig.size();
- for (std::size_t i = 0; i < std::size_t(a); ++i)
- {
- double temp1 = sig[i * 2];
- double temp2 = sig[len - 1];
- sig.insert(sig.begin(), temp1);
- sig.insert(sig.end(), temp2);
- }
-
- return nullptr;
- }
-
- void* idwt_sym(std::vector<double>& dwtop, std::vector<double>& flag, const std::string& nm, std::vector<double>& idwtOutput, std::vector<std::size_t>& length)
- {
- const int J = int(flag[1]);
-
- std::vector<double> app, detail;
- std::size_t appLen = length[0], detLen = length[1];
-
- const auto dwt = dwtop.begin();
- app.assign(dwt, dwtop.begin() + appLen);
- detail.assign(dwtop.begin() + appLen, dwtop.begin() + 2 * appLen);
-
- for (std::size_t i = 0; i < std::size_t(J); ++i)
- {
- const int U = 2; // Upsampling Factor
- std::vector<double> lpd1, hpd1, lpr1, hpr1;
-
- filtcoef(nm, lpd1, hpd1, lpr1, hpr1);
- const std::size_t lf = lpr1.size();
-
- // Operations in the Low Frequency branch of the Synthesis Filter Bank
- std::vector<double> xLp, cAUp;
- upsamp(app, U, cAUp);
- cAUp.pop_back();
- convfft(cAUp, lpr1, xLp);
-
- // Operations in the High Frequency branch of the Synthesis Filter Bank
- std::vector<double> xHp;
- std::vector<double> cDUp;
- upsamp(detail, U, cDUp);
- cDUp.pop_back();
- convfft(cDUp, hpr1, xHp);
-
- appLen += detLen;
- vecsum(xLp, xHp, idwtOutput);
-
- idwtOutput.erase(idwtOutput.begin(), idwtOutput.begin() + lf - 2);
- idwtOutput.erase(idwtOutput.end() - (lf - 2), idwtOutput.end());
-
- app.clear();
- detail.clear();
- if (i < std::size_t(J - 1))
- {
- detLen = length[i + 2];
- // detail.assign(dwtop.begin()+app_len, dwtop.begin()+ det_len);
-
- for (std::size_t l = 0; l < detLen; ++l)
- {
- double temp = dwtop[appLen + l];
- detail.push_back(temp);
- }
- }
- app = idwtOutput;
-
- for (std::size_t iter1 = 0; iter1 < app.size() - detLen; iter1++) { app.pop_back(); }
- }
-
-
- // Remove ZeroPadding
-
- const int zerop = int(flag[0]);
- idwtOutput.erase(idwtOutput.end() - zerop, idwtOutput.end());
- return nullptr;
- }
-
- void* dwt1_sym(const std::string& wname, std::vector<double>& signal, std::vector<double>& cA, std::vector<double>& cD)
- {
- std::vector<double> lp1, hp1, lp2, hp2;
-
- filtcoef(wname, lp1, hp1, lp2, hp2);
- const int d = 2; // Downsampling Factor is 2
- const int lf = int(lp1.size());
- symm_ext(signal, lf - 1);
-
- std::vector<double> cAUndec;
- //sig value
- convfft(signal, lp1, cAUndec);
- cAUndec.erase(cAUndec.begin(), cAUndec.begin() + lf);
- cAUndec.erase(cAUndec.end() - lf + 1, cAUndec.end());
- downsamp(cAUndec, d, cA);
- // cA.erase(cA.begin(),cA.begin()+(int) ceil(((double)lf-1.0)/2.0));
- // cA.erase(cA.end()-(int) ceil(((double)lf-1.0)/2.0),cA.end());
-
-
- //High Pass Branch Computation
-
- std::vector<double> cDUndec;
- convfft(signal, hp1, cDUndec);
- cDUndec.erase(cDUndec.begin(), cDUndec.begin() + lf);
- cDUndec.erase(cDUndec.end() - lf + 1, cDUndec.end());
- downsamp(cDUndec, d, cD);
- // cD.erase(cD.begin(),cD.begin()+(int) ceil(((double)lf-1.0)/2.0));
- // cD.erase(cD.end()-(int) ceil(((double)lf-1.0)/2.0),cD.end());
-
- filtcoef(wname, lp1, hp1, lp2, hp2);
-
- return nullptr;
- }
-
- void* dwt1_sym_m(const std::string& wname, std::vector<double>& signal, std::vector<double>& cA, std::vector<double>& cD)
- {
- std::vector<double> lp1, hp1, lp2, hp2;
-
- filtcoef(wname, lp1, hp1, lp2, hp2);
- const int d = 2; // Downsampling Factor is 2
- const int lf = int(lp1.size());
- symm_ext(signal, lf - 1);
-
- std::vector<double> cAUndec;
- //sig value
- convfftm(signal, lp1, cAUndec);
- cAUndec.erase(cAUndec.begin(), cAUndec.begin() + lf);
- cAUndec.erase(cAUndec.end() - lf + 1, cAUndec.end());
- downsamp(cAUndec, d, cA);
- // cA.erase(cA.begin(),cA.begin()+(int) ceil(((double)lf-1.0)/2.0));
- // cA.erase(cA.end()-(int) ceil(((double)lf-1.0)/2.0),cA.end());
-
-
- //High Pass Branch Computation
-
- std::vector<double> cDUndec;
- convfftm(signal, hp1, cDUndec);
- cDUndec.erase(cDUndec.begin(), cDUndec.begin() + lf);
- cDUndec.erase(cDUndec.end() - lf + 1, cDUndec.end());
- downsamp(cDUndec, d, cD);
- // cD.erase(cD.begin(),cD.begin()+(int) ceil(((double)lf-1.0)/2.0));
- // cD.erase(cD.end()-(int) ceil(((double)lf-1.0)/2.0),cD.end());
-
- filtcoef(wname, lp1, hp1, lp2, hp2);
-
- return nullptr;
- }
-
- void* dwt_sym(std::vector<double>& signal, const int J, const std::string& nm, std::vector<double>& dwtOutput, std::vector<double>& flag, std::vector<std::size_t>& length)
- {
- std::size_t tempLen = signal.size();
- if ((tempLen % 2) != 0)
- {
- const double temp = signal[tempLen - 1];
- signal.push_back(temp);
- flag.push_back(1);
- tempLen++;
- }
- else { flag.push_back(0); }
- length.push_back(tempLen);
- flag.push_back(double(J));
- // flag[2] contains symmetric extension length
-
-
- std::vector<double> appxSig, detSig;
- const std::vector<double> originalCopy = signal;
-
-
- // Storing Filter Values for GnuPlot
- std::vector<double> lp1, hp1, lp2, hp2;
- filtcoef(nm, lp1, hp1, lp2, hp2);
- for (std::size_t iter = 0; iter < std::size_t(J); ++iter)
- {
- dwt1_sym(nm, signal, appxSig, detSig);
- dwtOutput.insert(dwtOutput.begin(), detSig.begin(), detSig.end());
- std::size_t temp = detSig.size();
- length.insert(length.begin(), temp);
-
- if (iter == std::size_t(J - 1))
- {
- dwtOutput.insert(dwtOutput.begin(), appxSig.begin(), appxSig.end());
- length.insert(length.begin(), appxSig.size());
- }
-
- signal.clear();
- signal = appxSig;
- appxSig.clear();
- detSig.clear();
- }
- signal = originalCopy;
-
- return nullptr;
- }
-
-
- void* freq(std::vector<double>& sig, std::vector<double>& freqResp)
- {
- const std::size_t k = sig.size();
- const std::size_t n = std::size_t(pow(2.0, ceil(log10(double(k)) / log10(2.0))));
- std::vector<std::complex<double>> fftOup;
- for (std::size_t i = 0; i < sig.size(); ++i)
- {
- double temp = sig[i];
- fftOup.push_back(std::complex<double>(temp, 0));
- }
- fft(fftOup, 1, n);
-
- for (std::size_t i = 0; i < n; ++i)
- {
- double temp = abs(fftOup[i]);
- freqResp.push_back(temp);
- }
- circshift(freqResp, int(n) / 2);
- return nullptr;
- }
-
- double convfft(std::vector<double>& a, std::vector<double>& b, std::vector<double>& c)
- {
- const std::size_t sz = a.size() + b.size() - 1;
- fftw_complex* inpData = static_cast<fftw_complex*>(fftw_malloc(sizeof(fftw_complex) * sz));
- fftw_complex* filtData = static_cast<fftw_complex*>(fftw_malloc(sizeof(fftw_complex) * sz));
-
- fftw_complex* inpFFT = static_cast<fftw_complex*>(fftw_malloc(sizeof(fftw_complex) * sz));
- fftw_complex* filtFFT = static_cast<fftw_complex*>(fftw_malloc(sizeof(fftw_complex) * sz));
-
- fftw_complex* tempData = static_cast<fftw_complex*>(fftw_malloc(sizeof(fftw_complex) * sz));
- fftw_complex* tempIfft = static_cast<fftw_complex*>(fftw_malloc(sizeof(fftw_complex) * sz));
-
- fftw_plan plan_forward_inp = fftw_plan_dft_1d(int(sz), inpData, inpFFT, FFTW_FORWARD, FFTW_ESTIMATE);
- fftw_plan plan_forward_filt = fftw_plan_dft_1d(int(sz), filtData, filtFFT, FFTW_FORWARD, FFTW_ESTIMATE);
- fftw_plan plan_backward = fftw_plan_dft_1d(int(sz), tempData, tempIfft, FFTW_BACKWARD, FFTW_ESTIMATE);
-
-
- for (std::size_t i = 0; i < sz; ++i)
- {
- if (i < a.size()) { inpData[i][0] = a[i]; }
- else { inpData[i][0] = 0.0; }
- inpData[i][1] = 0.0;
- if (i < b.size()) { filtData[i][0] = b[i]; }
- else { filtData[i][0] = 0.0; }
- filtData[i][1] = 0.0;
- }
-
-
- fftw_execute(plan_forward_inp);
-
- fftw_execute(plan_forward_filt);
-
- for (std::size_t i = 0; i < sz; ++i)
- {
- tempData[i][0] = inpFFT[i][0] * filtFFT[i][0] - inpFFT[i][1] * filtFFT[i][1];
- tempData[i][1] = inpFFT[i][0] * filtFFT[i][1] + inpFFT[i][1] * filtFFT[i][0];
- }
-
-
- fftw_execute(plan_backward);
-
- for (std::size_t i = 0; i < sz; ++i)
- {
- double temp1;
- temp1 = tempIfft[i][0] / double(sz);
- c.push_back(temp1);
- }
- fftw_free(inpData);
- fftw_free(filtData);
- fftw_free(inpFFT);
- fftw_free(filtFFT);
- fftw_free(tempData);
- fftw_free(tempIfft);
- fftw_destroy_plan(plan_forward_inp);
- fftw_destroy_plan(plan_forward_filt);
- fftw_destroy_plan(plan_backward);
-
- return 0;
- }
-
- double convfftm(std::vector<double>& a, std::vector<double>& b, std::vector<double>& c)
- {
- const std::size_t sz = a.size() + b.size() - 1;
- fftw_complex* inpData = static_cast<fftw_complex*>(fftw_malloc(sizeof(fftw_complex) * sz));
- fftw_complex* filtData = static_cast<fftw_complex*>(fftw_malloc(sizeof(fftw_complex) * sz));
-
- fftw_complex* inpFFT = static_cast<fftw_complex*>(fftw_malloc(sizeof(fftw_complex) * sz));
- fftw_complex* filtFFT = static_cast<fftw_complex*>(fftw_malloc(sizeof(fftw_complex) * sz));
-
- fftw_complex* tempData = static_cast<fftw_complex*>(fftw_malloc(sizeof(fftw_complex) * sz));
- fftw_complex* tempIfft = static_cast<fftw_complex*>(fftw_malloc(sizeof(fftw_complex) * sz));
-
- if (sz != fftTransientSize)
- {
- if (fftTransientSize != 0)
- {
- fftw_destroy_plan(plan_forward_inp);
- fftw_destroy_plan(plan_forward_filt);
- fftw_destroy_plan(plan_backward);
- }
-
- plan_forward_inp = fftw_plan_dft_1d(int(sz), inpData, inpFFT, FFTW_FORWARD, FFTW_MEASURE);
- plan_forward_filt = fftw_plan_dft_1d(int(sz), filtData, filtFFT, FFTW_FORWARD, FFTW_MEASURE);
- plan_backward = fftw_plan_dft_1d(int(sz), tempData, tempIfft, FFTW_BACKWARD, FFTW_MEASURE);
- fftTransientSize = sz;
- }
-
- for (std::size_t i = 0; i < sz; ++i)
- {
- if (i < a.size()) { inpData[i][0] = a[i]; }
- else { inpData[i][0] = 0.0; }
- inpData[i][1] = 0.0;
- if (i < b.size()) { filtData[i][0] = b[i]; }
- else { filtData[i][0] = 0.0; }
- filtData[i][1] = 0.0;
- }
-
-
- fftw_execute_dft(plan_forward_inp, inpData, inpFFT);
- fftw_execute_dft(plan_forward_filt, filtData, filtFFT);
-
-
- for (std::size_t i = 0; i < sz; ++i)
- {
- tempData[i][0] = inpFFT[i][0] * filtFFT[i][0] - inpFFT[i][1] * filtFFT[i][1];
- tempData[i][1] = inpFFT[i][0] * filtFFT[i][1] + inpFFT[i][1] * filtFFT[i][0];
- }
-
- fftw_execute_dft(plan_backward, tempData, tempIfft);
-
-
- for (std::size_t i = 0; i < sz; ++i)
- {
- double temp1;
- temp1 = tempIfft[i][0] / double(sz);
- c.push_back(temp1);
- }
- fftw_free(inpData);
- fftw_free(filtData);
- fftw_free(inpFFT);
- fftw_free(filtFFT);
- fftw_free(tempData);
- fftw_free(tempIfft);
-
- return 0;
- }
-
- void* fft(std::vector<std::complex<double>>& data, const int sign, std::size_t n)
- {
- double pi = - 3.14159265358979;
- if (sign == 1 || sign == -1) { pi = sign * pi; }
- else
- {
- std::cout << "Format fft(data, num), num = +1(fft) and num = -1 (Ifft)" << std::endl;
- exit(1);
- }
- const std::size_t len = data.size();
- const auto it = data.end();
- if (len != n)
- {
- const std::size_t al = n - len;
- data.insert(it, al, std::complex<double>(0, 0));
- }
-
- const std::size_t k = std::size_t(pow(2.0, ceil(log10(double(n)) / log10(2.0))));
- const auto it1 = data.end();
- if (n < k)
- {
- const std::size_t al = k - n;
- data.insert(it1, al, std::complex<double>(0, 0));
- n = k;
- }
-
- bitreverse(data);
-
- // radix2(data);
- for (std::size_t iter = 1; iter < n; iter <<= 1)
- {
- const std::size_t step = iter << 1;
-
- const double theta = pi / double(iter);
-
- double wtemp = sin(theta * .5);
- // Multipliers
- const double wreal = -2 * wtemp * wtemp;
- const double wimag = sin(theta);
-
- // Factors
- double wr = 1.0;
- double wi = 0.0;
- // Iteration through two loops
-
- for (std::size_t m = 0; m < iter; ++m)
- {
- // Iteration within m
- for (std::size_t i = m; i < n; i += step)
- {
- // jth position
- const std::size_t j = i + iter;
-
- double tempr = wr * std::real(data[j]) - wi * std::imag(data[j]);
- double tempi = wr * std::imag(data[j]) + wi * std::real(data[j]);
-
- std::complex<double> temp(tempr, tempi);
- data[j] = data[i] - temp;
- data[i] += temp;
- }
- // Twiddle Factors updated
- wtemp = wr;
- wr += wr * wreal - wi * wimag;
- wi += wi * wreal + wtemp * wimag;
- }
- }
-
- if (sign == -1)
- {
- const double scale = 1.0 / double(n);
- for (std::size_t i = 0; i < n; ++i) { data[i] *= scale; }
- }
-
-
- // Place holder
- return nullptr;
- }
-
-
- void* bitreverse(std::vector<std::complex<double>>& sig)
- {
- const std::size_t len = sig.size();
- const std::size_t n = std::size_t(pow(2.0, ceil(log10(double(len)) / log10(2.0))));
- std::size_t rev = 0;
- // Processing Input Data
- for (std::size_t iter = 0; iter < n; ++iter)
- {
- if (rev > iter)
- {
- // Replacing current values with reversed values
-
- double tempr = std::real(sig[rev]);
- double tempi = std::imag(sig[rev]);
- const std::complex<double> temp(tempr, tempi);
- sig[rev] = sig[iter];
- sig[iter] = temp;
- }
- // Using filter "filt" such that the value of reverse changes with each iteration
- std::size_t filt = n;
- while (rev & (filt >>= 1)) { rev &= ~filt; }
- rev |= filt;
- }
- return nullptr;
- }
-
-
- void* dwt(std::vector<double>& sig, int j, const std::string& nm, std::vector<double>& dwtOutput, std::vector<double>& flag, std::vector<std::size_t>& length)
- {
- const int maxIter = int(ceil(log(double(sig.size())) / log(2.0))) - 2;
-
- if (maxIter < j) { j = maxIter; }
-
- std::vector<double> appxSig, detSig;
- const std::vector<double> originalCopy = sig;
-
- // Zero Pad the Signal to nearest 2^ M value ,where M is an integer.
- std::size_t tempLen = sig.size();
- if ((tempLen % 2) != 0)
- {
- const double temp = sig[tempLen - 1];
- sig.push_back(temp);
- flag.push_back(1);
- tempLen++;
- }
- else { flag.push_back(0); }
- length.push_back(tempLen);
- flag.push_back(double(j));
-
- std::vector<double> orig = sig;
-
-
- // Storing Filter Values for GnuPlot
- std::vector<double> lp1, hp1, lp2, hp2;
- filtcoef(nm, lp1, hp1, lp2, hp2);
-
-
- for (std::size_t iter = 0; iter < std::size_t(j); ++iter)
- {
- dwt1(nm, orig, appxSig, detSig);
- dwtOutput.insert(dwtOutput.begin(), detSig.begin(), detSig.end());
-
- const int temp = detSig.size();
- length.insert(length.begin(), temp);
-
- if (iter == std::size_t(j - 1))
- {
- dwtOutput.insert(dwtOutput.begin(), appxSig.begin(), appxSig.end());
- std::size_t temp2 = appxSig.size();
- length.insert(length.begin(), temp2);
- }
-
- orig = appxSig;
- appxSig.clear();
- detSig.clear();
- }
-
- sig = originalCopy;
- return nullptr;
- }
-
-
- void circshift(std::vector<double>& sigCir, int l)
- {
- if (abs(l) > int(sigCir.size())) { l = sign(l) * int(abs(l) % sigCir.size()); }
-
- if (l < 0)
- {
- l = int((sigCir.size() + l) % sigCir.size());
- // std::cout << "L" << L << std::endl;
- }
- for (std::size_t i = 0; i < std::size_t(l); ++i)
- {
- sigCir.push_back(sigCir[0]);
- sigCir.erase(sigCir.begin());
- }
- }
-
- double convol(std::vector<double>& a1, std::vector<double>& b1, std::vector<double>& c)
- {
- const std::size_t lenC = a1.size() + b1.size() - 1;
- std::vector<double> a = a1;
- std::vector<double> b = b1;
- std::vector<double> oup(lenC);
- const auto itA = a.end();
- const double al = double(lenC - a.size());
- a.insert(itA, al, 0);
-
- const auto itB = b.end();
- const double bl = double(lenC - b.size());
- b.insert(itB, bl, 0);
-
- for (std::size_t ini = 0; ini < lenC; ++ini)
- {
- oup[ini] = 0;
- double temp = 0;
- for (std::size_t jni = 0; jni <= ini; ++jni)
- {
- const double ou1 = a[jni] * b[ini - jni];
- oup[ini] += ou1;
- }
- temp = oup[ini];
- c.push_back(temp);
- }
- oup.clear();
- return 0;
- }
-
- void downsamp(std::vector<double>& sig, const int m, std::vector<double>& sigD)
- {
- const std::size_t len = sig.size();
- const std::size_t n = std::size_t(ceil(double(len) / double(m)));
- for (std::size_t i = 0; i < n; ++i)
- {
- double temp = sig[i * m];
- sigD.push_back(temp);
- }
- }
-
-
- void* dwt1(const std::string& wname, std::vector<double>& signal, std::vector<double>& cA, std::vector<double>& cD)
- {
- std::vector<double> lpd, hpd, lpr, hpr;
-
- filtcoef(wname, lpd, hpd, lpr, hpr);
-
- const std::size_t lenLpfilt = lpd.size();
- const std::size_t lenHpfilt = hpd.size();
- const std::size_t lenAvg = (lenLpfilt + lenHpfilt) / 2;
- const std::size_t lenSig = 2 * std::size_t(ceil(double(signal.size()) / 2.0));
-
- // std::cout << lenLpfilt << "Filter" << std::endl;
- per_ext(signal, int(lenAvg / 2)); // Periodic Extension
- // computations designed to deal with boundary distortions
-
- // Low Pass Filtering Operations in the Analysis Filter Bank Section
- // int len_cA =(int) floor(double (len_sig + lenLpfilt -1) / double (2));
- std::vector<double> cAUndec;
- // convolving signal with lpd, Low Pass Filter, and O/P is stored in cA_undec
- convfft(signal, lpd, cAUndec);
- const int d = 2; // Downsampling Factor is 2
- cAUndec.erase(cAUndec.begin(), cAUndec.begin() + lenAvg - 1);
- cAUndec.erase(cAUndec.end() - lenAvg + 1, cAUndec.end());
- cAUndec.erase(cAUndec.begin() + lenSig, cAUndec.end());
- cAUndec.erase(cAUndec.begin());
-
-
- // Downsampling by 2 gives cA
- downsamp(cAUndec, d, cA);
-
- // cA.erase(cA.begin(),cA.begin()+len_avg/2);
- // cA.erase(cA.end()-len_avg/2,cA.end());
-
- // High Pass Filtering Operations in the Analysis Filter Bank Section
- // int len_cA =(int) floor(double (len_sig + lenLpfilt -1) / double (2));
-
- std::vector<double> cDUndec;
- // convolving signal with lpd, Low Pass Filter, and O/P is stored in cA_undec
- convfft(signal, hpd, cDUndec);
- cDUndec.erase(cDUndec.begin(), cDUndec.begin() + lenAvg - 1);
- cDUndec.erase(cDUndec.end() - lenAvg + 1, cDUndec.end());
- cDUndec.erase(cDUndec.begin() + lenSig, cDUndec.end());
- cDUndec.erase(cDUndec.begin());
-
- // Downsampling Factor is 2
-
- // Downsampling by 2 gives cA
- downsamp(cDUndec, d, cD);
-
- // cD.erase(cD.begin(),cD.begin()+len_avg/2);
- // cD.erase(cD.end()-len_avg/2,cD.end());
-
- filtcoef(wname, lpd, hpd, lpr, hpr);
-
- return nullptr;
- }
-
- void* dwt1_m(const std::string& wname, std::vector<double>& signal, std::vector<double>& cA, std::vector<double>& cD)
- {
- std::vector<double> lpd, hpd, lpr, hpr;
-
- filtcoef(wname, lpd, hpd, lpr, hpr);
-
- const std::size_t lenLpfilt = lpd.size();
- const std::size_t lenHpfilt = hpd.size();
- const std::size_t lenAvg = (lenLpfilt + lenHpfilt) / 2;
- const std::size_t lenSig = 2 * std::size_t(ceil(double(signal.size()) / 2.0));
-
- // std::cout << lenLpfilt << "Filter" << std::endl;
- per_ext(signal, int(lenAvg / 2)); // Periodic Extension
- // computations designed to deal with boundary distortions
-
- // Low Pass Filtering Operations in the Analysis Filter Bank Section
- // int len_cA =(int) floor(double (len_sig + lenLpfilt -1) / double (2));
- std::vector<double> cAUndec;
- // convolving signal with lpd, Low Pass Filter, and O/P is stored in cA_undec
- convfftm(signal, lpd, cAUndec);
- const int d = 2; // Downsampling Factor is 2
- cAUndec.erase(cAUndec.begin(), cAUndec.begin() + lenAvg - 1);
- cAUndec.erase(cAUndec.end() - lenAvg + 1, cAUndec.end());
- cAUndec.erase(cAUndec.begin() + lenSig, cAUndec.end());
- cAUndec.erase(cAUndec.begin());
-
-
- // Downsampling by 2 gives cA
- downsamp(cAUndec, d, cA);
-
- // cA.erase(cA.begin(),cA.begin()+len_avg/2);
- // cA.erase(cA.end()-len_avg/2,cA.end());
-
- // High Pass Filtering Operations in the Analysis Filter Bank Section
- // int len_cA =(int) floor(double (len_sig + lenLpfilt -1) / double (2));
-
- std::vector<double> cDUndec;
- // convolving signal with lpd, Low Pass Filter, and O/P is stored in cA_undec
- convfftm(signal, hpd, cDUndec);
- cDUndec.erase(cDUndec.begin(), cDUndec.begin() + lenAvg - 1);
- cDUndec.erase(cDUndec.end() - lenAvg + 1, cDUndec.end());
- cDUndec.erase(cDUndec.begin() + lenSig, cDUndec.end());
- cDUndec.erase(cDUndec.begin());
-
- // Downsampling Factor is 2
-
- // Downsampling by 2 gives cA
- downsamp(cDUndec, d, cD);
-
- // cD.erase(cD.begin(),cD.begin()+len_avg/2);
- // cD.erase(cD.end()-len_avg/2,cD.end());
-
- filtcoef(wname, lpd, hpd, lpr, hpr);
-
- return nullptr;
- }
-
-
- void* dyadic_zpad_1d(std::vector<double>& signal)
- {
- const std::size_t n = signal.size();
- const double m = log10(double(n)) / log10(2.0);
- const int d = int(ceil(m));
- const double intVal = pow(2.0, double(d)) - pow(2.0, m);
-
- const int z = int(intVal);
- const auto itA = signal.end();
- const double val = signal[n - 1];
- // double val = 0;
- signal.insert(itA, z, val);
- return nullptr;
- }
-
-
- void* idwt(std::vector<double>& dwtop, std::vector<double>& flag, const std::string& nm, std::vector<double>& idwtOutput, std::vector<std::size_t>& length)
- {
- const std::size_t j = std::size_t(flag[1]);
- // int zpad =(int) flag[0];
-
- std::vector<double> app;
- std::vector<double> detail;
- std::size_t appLen = length[0];
- std::size_t detLen = length[1];
-
- const auto dwt = dwtop.begin();
- app.assign(dwt, dwtop.begin() + appLen);
- detail.assign(dwtop.begin() + appLen, dwtop.begin() + 2 * appLen);
-
- for (std::size_t i = 0; i < j; ++i)
- {
- idwt1(nm, idwtOutput, app, detail);
- appLen += detLen;
- app.clear();
- detail.clear();
- if (i < j - 1)
- {
- detLen = length[i + 2];
- for (std::size_t l = 0; l < detLen; ++l)
- {
- double temp = dwtop[appLen + l];
- detail.push_back(temp);
- }
- app = idwtOutput;
-
- if (app.size() >= detail.size())
- {
- const std::size_t t = app.size() - detail.size();
- const std::size_t lent = std::size_t(floor(double(t) / 2.0));
- app.erase(app.begin() + detail.size() + lent, app.end());
- app.erase(app.begin(), app.begin() + lent);
- }
- }
-
- //int value1 = (int) ceil(double(app.size() - det_len)/2.0);
- //int value2 = (int) floor(double(app.size() - det_len)/2.0);
-
- //app.erase(app.end() -value2,app.end());
- //app.erase(app.begin(),app.begin()+value1);
- }
-
-
- // Remove ZeroPadding
-
- const int zerop = int(flag[0]);
- idwtOutput.erase(idwtOutput.end() - zerop, idwtOutput.end());
-
- return nullptr;
- }
-
- void* idwt1_m(const std::string& wname, std::vector<double>& x, std::vector<double>& cA, std::vector<double>& cD)
- {
- std::vector<double> lpd1, hpd1, lpr1, hpr1;
-
- filtcoef(wname, lpd1, hpd1, lpr1, hpr1);
- const std::size_t lenLpfilt = lpr1.size();
- const std::size_t lenHpfilt = hpr1.size();
- const std::size_t lenAvg = (lenLpfilt + lenHpfilt) / 2;
- const std::size_t n = 2 * cD.size();
- const int U = 2; // Upsampling Factor
-
- // Operations in the Low Frequency branch of the Synthesis Filter Bank
-
- std::vector<double> cAUp;
- std::vector<double> xLp;
- // int len1 = cAUp.size();
- upsamp(cA, U, cAUp);
- per_ext(cAUp, int(lenAvg / 2));
- convfftm(cAUp, lpr1, xLp);
-
- // Operations in the High Frequency branch of the Synthesis Filter Bank
- std::vector<double> cDUp, xHp;
- upsamp(cD, U, cDUp);
- per_ext(cDUp, int(lenAvg / 2));
- convfftm(cDUp, hpr1, xHp);
-
- // Remove periodic extension
- // X.erase(X.begin(),X.begin()+len_avg+len_avg/2-1);
- // X.erase(X.end()-len_avg-len_avg/2,X.end());
- xLp.erase(xLp.begin() + n + lenAvg - 1, xLp.end());
- xLp.erase(xLp.begin(), xLp.begin() + lenAvg - 1);
- xHp.erase(xHp.begin() + n + lenAvg - 1, xHp.end());
- xHp.erase(xHp.begin(), xHp.begin() + lenAvg - 1);
- vecsum(xLp, xHp, x);
- return nullptr;
- }
-
- void* idwt1(const std::string& wname, std::vector<double>& X, std::vector<double>& cA, std::vector<double>& cD)
- {
- std::vector<double> lpd1, hpd1, lpr1, hpr1;
-
- filtcoef(wname, lpd1, hpd1, lpr1, hpr1);
- const std::size_t lenLpfilt = lpr1.size();
- const std::size_t lenHpfilt = hpr1.size();
- const std::size_t lenAvg = (lenLpfilt + lenHpfilt) / 2;
- const std::size_t n = 2 * cD.size();
- const int U = 2; // Upsampling Factor
-
- // Operations in the Low Frequency branch of the Synthesis Filter Bank
-
- std::vector<double> cAUp, xLp;
- // int len1 = cAUp.size();
- upsamp(cA, U, cAUp);
-
- per_ext(cAUp, int(lenAvg / 2));
-
-
- convfft(cAUp, lpr1, xLp);
-
-
- // Operations in the High Frequency branch of the Synthesis Filter Bank
-
- std::vector<double> cDUp, xHp;
- upsamp(cD, U, cDUp);
- per_ext(cDUp, int(lenAvg / 2));
-
-
- convfft(cDUp, hpr1, xHp);
-
- // Remove periodic extension
-
- // X.erase(X.begin(),X.begin()+len_avg+len_avg/2-1);
- // X.erase(X.end()-len_avg-len_avg/2,X.end());
-
- xLp.erase(xLp.begin() + n + lenAvg - 1, xLp.end());
- xLp.erase(xLp.begin(), xLp.begin() + lenAvg - 1);
-
- xHp.erase(xHp.begin() + n + lenAvg - 1, xHp.end());
- xHp.erase(xHp.begin(), xHp.begin() + lenAvg - 1);
-
- vecsum(xLp, xHp, X);
-
- return nullptr;
- }
-
- int sign(const int x)
- {
- if (x >= 0) { return 1; }
- return -1;
- }
-
- void upsamp(std::vector<double>& sig, const int m, std::vector<double>& sigU)
- {
- const std::size_t len = sig.size();
- const std::size_t n = std::size_t(ceil(double(len) * double(m)));
-
- for (std::size_t i = 0; i < n; ++i)
- {
- if (i % m == 0)
- {
- double temp = sig[i / m];
- sigU.push_back(temp);
- }
- else { sigU.push_back(0); }
- }
- }
-
- double OPSum(const double i, const double j) { return (i + j); }
-
- int vecsum(std::vector<double>& a, std::vector<double>& b, std::vector<double>& c)
- {
- c.resize(a.size());
- transform(a.begin(), a.end(), b.begin(), b.begin(), OPSum);
- c = b;
- return 0;
- }
-
- void* getcoeff2d(std::vector<std::vector<double>>& dwtoutput, std::vector<std::vector<double>>& cH, std::vector<std::vector<double>>& cV,
- std::vector<std::vector<double>>& cD, std::vector<double>& flag, int& n)
- {
- if (n > flag[2])
- {
- std::cout << "Signal is decimated only up to " << flag[2] << " levels" << std::endl;
- exit(1);
- }
- const std::size_t rows = dwtoutput.size();
- const std::size_t cols = dwtoutput[0].size();
- // Getting Horizontal Coefficients
- const std::size_t r = std::size_t(ceil(double(rows) / pow(2.0, n)));
- const std::size_t c = std::size_t(ceil(double(cols) / pow(2.0, n)));
-
- for (std::size_t i = 0; i < std::size_t(ceil(double(rows) / pow(2.0, n))); ++i)
- {
- for (std::size_t j = 0; j < std::size_t(ceil(double(cols) / pow(2.0, n))); ++j) { cH[i][j] = dwtoutput[i][c + j]; }
- }
- for (std::size_t i = 0; i < std::size_t(ceil(double(rows) / pow(2.0, n))); ++i)
- {
- for (std::size_t j = 0; j < std::size_t(ceil(double(cols) / pow(2.0, n))); ++j) { cV[i][j] = dwtoutput[i + r][j]; }
- }
- for (std::size_t i = 0; i < std::size_t(ceil(double(rows) / pow(2.0, n))); ++i)
- {
- for (std::size_t j = 0; j < std::size_t(ceil(double(cols) / pow(2.0, n))); ++j) { cD[i][j] = dwtoutput[i + r][c + j]; }
- }
-
- return nullptr;
- }
-
- void* zero_remove(std::vector<std::vector<double>>& input, std::vector<std::vector<double>>& output)
- {
- const int zeroRows = int(output.size() - input.size());
- const int zeroCols = int(output[0].size() - input[0].size());
-
- auto row = output.end() - zeroRows;
-
- const std::size_t ousize = output.size();
- for (std::size_t i = input.size(); i < ousize; ++i)
- {
- output.erase(row);
- ++row;
- }
-
- // std::size_t ousize2 = output[0].size();
-
-
- for (std::size_t i = 0; i < ousize; ++i)
- {
- const auto col = output[i].end() - zeroCols;
- output[i].erase(col, output[i].end());
- }
- return nullptr;
- }
-
- void* dwt_output_dim(std::vector<std::vector<double>>& signal, int& r, int& c)
- {
- const std::size_t rows = signal.size();
- const std::size_t cols = signal[0].size();
-
- const double mr = log10(double(rows)) / log10(2.0);
- const int dr = int(ceil(mr));
- const double intValRow = pow(2.0, double(dr));
- const int r1 = int(intValRow);
-
- const double mc = log10(double(cols)) / log10(2.0);
- const int dc = int(ceil(mc));
- const double intValCols = pow(2.0, double(dc));
- const int c1 = int(intValCols);
- r = std::max(r1, c1);
- c = std::max(r1, c1);
-
- return nullptr;
- }
-
- void* dyadic_zpad_2d(std::vector<std::vector<double>>& signal, std::vector<std::vector<double>>& mod)
- {
- const std::size_t rows = signal.size();
- const std::size_t cols = signal[0].size();
-
- for (std::size_t i = 0; i < rows; ++i) { for (std::size_t j = 0; j < cols; ++j) { mod[i][j] = signal[i][j]; } }
- // Zeropadding the columns
-
- const double mr = log10(double(rows)) / log10(2.0);
- const int dr = int(ceil(mr));
- const double intValRow = pow(2.0, double(dr)) - pow(2.0, mr);
-
- const int zerosRow = int(intValRow);
-
- const double mc = log10(double(cols)) / log10(2.0);
- const int dc = int(ceil(mc));
- const double intValCols = pow(2.0, double(dc)) - pow(2.0, mc);
-
- const int zerosCols = int(intValCols);
-
- for (std::size_t i = 0; i < rows + zerosRow; ++i) { for (std::size_t j = cols; j < cols + zerosCols; ++j) { mod[i][j] = 0; } }
- for (std::size_t i = rows; i < rows + zerosRow; ++i) { for (std::size_t j = 0; j < cols + zerosCols; ++j) { mod[i][j] = 0; } }
-
- return nullptr;
- }
-
- void* idwt_2d(std::vector<double>& dwtop, std::vector<double>& flag, const std::string& nm, std::vector<std::vector<double>>& idwtOutput, std::vector<std::size_t>& length)
- {
- std::size_t J = std::size_t(flag[0]);
- std::size_t rows = length[0];
- std::size_t cols = length[1];
-
- std::size_t sumCoef = 0;
- std::vector<double> lp1, hp1, lp2, hp2;
- filtcoef(nm, lp1, hp1, lp2, hp2);
- std::vector<std::vector<double>> cLL(rows, std::vector<double>(cols));
-
-
- for (std::size_t iter = 0; iter < J; ++iter)
- {
- std::size_t nRows = length[2 * iter];
- std::size_t nCols = length[2 * iter + 1];
-
- std::vector<std::vector<double>> cLH(nRows, std::vector<double>(nCols));
- std::vector<std::vector<double>> cHL(nRows, std::vector<double>(nCols));
- std::vector<std::vector<double>> cHH(nRows, std::vector<double>(nCols));
-
- for (std::size_t i = 0; i < nRows; ++i)
- {
- for (std::size_t j = 0; j < nCols; ++j)
- {
- if (iter == 0)
- {
- cLL[i][j] = dwtop[sumCoef + i * nCols + j];
- cLH[i][j] = dwtop[sumCoef + nRows * nCols + i * nCols + j];
- cHL[i][j] = dwtop[sumCoef + 2 * nRows * nCols + i * nCols + j];
- cHH[i][j] = dwtop[sumCoef + 3 * nRows * nCols + i * nCols + j];
- }
- else
- {
- cLH[i][j] = dwtop[sumCoef + i * nCols + j];
- cHL[i][j] = dwtop[sumCoef + nRows * nCols + i * nCols + j];
- cHH[i][j] = dwtop[sumCoef + 2 * nRows * nCols + i * nCols + j];
- }
- }
- }
-
-
- // temp_A = cLL;
- // idwt2_sym(nm,idwtOutput2, cA, cH,cV,cD);
-
- std::size_t lenX = cLH.size();
- std::size_t lenY = cLH[0].size();
-
- // Row Upsampling and Column Filtering at the first LP Stage
- std::vector<std::vector<double>> cL(2 * lenX, std::vector<double>(lenY));
- std::vector<std::vector<double>> cH(2 * lenX, std::vector<double>(lenY));
-
- if (iter == 0)
- {
- for (std::size_t j = 0; j < lenY; ++j)
- {
- std::vector<double> sigLL, sigLH, oup;
-
- for (std::size_t i = 0; i < lenX; ++i)
- {
- double temp1 = cLL[i][j];
- double temp2 = cLH[i][j];
- sigLL.push_back(temp1);
- sigLH.push_back(temp2);
- }
- idwt1_m(nm, oup, sigLL, sigLH);
-
- for (std::size_t i = 0; i < oup.size(); ++i) { cL[i][j] = oup[i]; }
- }
- }
- else
- {
- std::size_t rows1 = cLH.size();
- std::size_t cols1 = cLH[0].size();
-
- for (std::size_t j = 0; j < cols1; ++j)
- {
- std::vector<double> tempL1, tempL2, oup;
- for (std::size_t i = 0; i < rows1; ++i)
- {
- double temp = cLL[i][j];
- tempL1.push_back(temp);
-
- double temp2 = cLH[i][j];
- tempL2.push_back(temp2);
- }
- idwt1_m(nm, oup, tempL1, tempL2);
-
- for (std::size_t i = 0; i < oup.size(); ++i) { cL[i][j] = oup[i]; }
- }
- }
-
-
- for (std::size_t j = 0; j < lenY; ++j)
- {
- std::vector<double> sigHL, sigHH, oup2;
- for (std::size_t i = 0; i < lenX; ++i)
- {
- double temp3 = cHL[i][j];
- double temp4 = cHH[i][j];
- sigHL.push_back(temp3);
- sigHH.push_back(temp4);
- }
- idwt1_m(nm, oup2, sigHL, sigHH);
-
- for (std::size_t i = 0; i < oup2.size(); ++i) { cH[i][j] = oup2[i]; }
- }
-
- std::vector<std::vector<double>> signal(2 * lenX, std::vector<double>(2 * lenY));
- for (std::size_t i = 0; i < 2 * lenX; ++i)
- {
- std::vector<double> sigL, sigH, oup;
- for (std::size_t j = 0; j < lenY; ++j)
- {
- double temp5 = cL[i][j];
- double temp6 = cH[i][j];
- sigL.push_back(temp5);
- sigH.push_back(temp6);
- }
- idwt1_m(nm, oup, sigL, sigH);
-
- for (std::size_t j = 0; j < oup.size(); ++j) { signal[i][j] = oup[j]; }
- }
-
- idwtOutput = signal;
-
-
- if (iter == 0) { sumCoef += 4 * nRows * nCols; }
- else { sumCoef += 3 * nRows * nCols; }
- cLL = signal;
- }
-
-
- return nullptr;
- }
-
-
- void* dwt_2d(std::vector<std::vector<double>>& origsig, const int J, const std::string& nm, std::vector<double>& dwtOutput, std::vector<double>& flag, std::vector<std::size_t>& length)
- {
- // flag will contain
-
- std::vector<std::vector<double>> sig = origsig;
- std::size_t nRows = sig.size(); // No. of rows
- std::size_t nCols = sig[0].size(); //No. of columns
- std::vector<std::vector<double>> originalCopy = sig;
- const int maxIter = std::min(int(ceil(log(double(sig.size())) / log(2.0))), int(ceil(log(double(sig[0].size())) / log(2.0))));
- if (maxIter < J)
- {
- std::cout << J << " Iterations are not possible with signals of this dimension " << std::endl;
- exit(1);
- }
- std::vector<double> lp1, hp1, lp2, hp2;
-
- flag.push_back(double(J));
- flag.push_back(0);
-
-
- length.insert(length.begin(), nCols);
- length.insert(length.begin(), nRows);
-
-
- std::size_t sumCoef = 0;
- for (std::size_t iter = 0; iter < std::size_t(J); ++iter)
- {
- filtcoef(nm, lp1, hp1, lp2, hp2);
-
- nRows = int(ceil(double(nRows) / 2.0));
- nCols = int(ceil(double(nCols) / 2.0));
- length.insert(length.begin(), nCols);
- length.insert(length.begin(), nRows);
-
- std::vector<std::vector<double>> cA(nRows, std::vector<double>(nCols));
- std::vector<std::vector<double>> cH(nRows, std::vector<double>(nCols));
- std::vector<std::vector<double>> cV(nRows, std::vector<double>(nCols));
- std::vector<std::vector<double>> cD(nRows, std::vector<double>(nCols));
-
- if (iter == 0) { dwt2(nm, originalCopy, cA, cH, cV, cD); }
- else { dwt2(nm, originalCopy, cA, cH, cV, cD); }
- std::vector<double> tempSig2;
-
- originalCopy = cA;
- if (iter == std::size_t(J - 1))
- {
- for (std::size_t i = 0; i < nRows; ++i)
- {
- for (std::size_t j = 0; j < nCols; ++j)
- {
- double temp = cA[i][j];
- tempSig2.push_back(temp);
- }
- }
- }
- for (std::size_t i = 0; i < nRows; ++i)
- {
- for (std::size_t j = nCols; j < nCols * 2; ++j)
- {
- double temp = cH[i][j - nCols];
- tempSig2.push_back(temp);
- }
- }
-
- for (std::size_t i = nRows; i < nRows * 2; ++i)
- {
- for (std::size_t j = 0; j < nCols; ++j)
- {
- double temp = cV[i - nRows][j];
- tempSig2.push_back(temp);
- }
- }
-
- for (std::size_t i = nRows; i < nRows * 2; ++i)
- {
- for (std::size_t j = nCols; j < nCols * 2; ++j)
- {
- double temp = cD[i - nRows][j - nCols];
- tempSig2.push_back(temp);
- }
- }
-
- dwtOutput.insert(dwtOutput.begin(), tempSig2.begin(), tempSig2.end());
- sumCoef += 4 * nRows * nCols;
- }
- /*
- ofstream dwt2out("dwt2out.dat");
- for (std::size_t i= 0; i < dwtOutput.size(); ++i){ dwt2out << dwtOutput[i] <<endl; }
- */
-
- return nullptr;
- }
-
-
- void* branch_lp_hp_up(const std::string& wname, std::vector<double>& cA, std::vector<double>& cD, std::vector<double>& x)
- {
- std::vector<double> lpd1, hpd1, lpr1, hpr1;
-
- filtcoef(wname, lpd1, hpd1, lpr1, hpr1);
- const std::size_t lenLpfilt = lpr1.size();
- const std::size_t lenHpfilt = hpr1.size();
- const std::size_t lenAvg = (lenLpfilt + lenHpfilt) / 2;
- //std::size_t N = 2 * cA.size();
- const int U = 2; // Upsampling Factor
-
- // Operations in the Low Frequency branch of the Synthesis Filter Bank
-
- std::vector<double> cAUp;
- std::vector<double> xLp;
- per_ext(cA, int(lenAvg / 2));
- upsamp(cA, U, cAUp);
- convfftm(cAUp, lpr1, xLp);
-
- // Operations in the High Frequency branch of the Synthesis Filter Bank
-
- std::vector<double> cDUp;
- std::vector<double> xHp;
- per_ext(cD, int(lenAvg / 2));
- upsamp(cD, U, cDUp);
- convfftm(cDUp, hpr1, xHp);
- vecsum(xLp, xHp, x);
- // Remove periodic extension
- x.erase(x.begin(), x.begin() + lenAvg + lenAvg / 2 - 1);
- x.erase(x.end() - lenAvg - lenAvg / 2, x.end());
-
- return nullptr;
- }
-
- void* branch_hp_dn(const std::string& wname, std::vector<double>& signal, std::vector<double>& sigop)
- {
- std::vector<double> lpd, hpd, lpr, hpr;
-
- filtcoef(wname, lpd, hpd, lpr, hpr);
- //for (std::size_t i = 0; i < signal.size(); ++i) {
- // std::cout << signal[i] << std::endl;
- // out2 << signal[i] << std::endl;
- //}
-
- const std::size_t tempLen = signal.size();
-
- if ((tempLen % 2) != 0)
- {
- const double temp = signal[tempLen - 1];
- signal.push_back(temp);
- }
-
- const std::size_t lenLpfilt = lpd.size();
- const std::size_t lenHpfilt = hpd.size();
- const std::size_t lenAvg = (lenLpfilt + lenHpfilt) / 2;
-
- // std::cout << lenLpfilt << "Filter" << std::endl;
- per_ext(signal, int(lenAvg / 2)); // Periodic Extension
- // computations designed to deal with boundary distortions
-
- // Low Pass Filtering Operations in the Analysis Filter Bank Section
- // int len_cA =(int) floor(double (len_sig + lenLpfilt -1) / double (2));
- std::vector<double> cAUndec;
- // convolving signal with lpd, Low Pass Filter, and O/P is stored in cA_undec
- convfftm(signal, hpd, cAUndec);
- const int d = 2; // Downsampling Factor is 2
-
- // Downsampling by 2 gives cA
- downsamp(cAUndec, d, sigop);
-
- sigop.erase(sigop.begin(), sigop.begin() + lenAvg / 2);
- sigop.erase(sigop.end() - lenAvg / 2, sigop.end());
- return nullptr;
- }
-
- void* branch_lp_dn(const std::string& wname, std::vector<double>& signal, std::vector<double>& sigop)
- {
- std::vector<double> lpd, hpd, lpr, hpr;
-
- filtcoef(wname, lpd, hpd, lpr, hpr);
- // for (std::size_t i = 0; i < signal.size(); ++i) {
- // std::cout << signal[i] << endl;
- // out2 << signal[i] <<endl;
- // }
-
- const std::size_t tempLen = signal.size();
-
- if ((tempLen % 2) != 0)
- {
- const double temp = signal[tempLen - 1];
- signal.push_back(temp);
- }
-
- const std::size_t lenLpfilt = lpd.size();
- const std::size_t lenHpfilt = hpd.size();
- const std::size_t lenAvg = (lenLpfilt + lenHpfilt) / 2;
-
- // std::cout << lenLpfilt << "Filter" << std::endl;
- per_ext(signal, int(lenAvg / 2)); // Periodic Extension
- // computations designed to deal with boundary distortions
-
- // Low Pass Filtering Operations in the Analysis Filter Bank Section
- // int len_cA =(int) floor(double (len_sig + lenLpfilt -1) / double (2));
- std::vector<double> cAUndec;
- // convolving signal with lpd, Low Pass Filter, and O/P is stored in cA_undec
- convfftm(signal, lpd, cAUndec);
- const int d = 2; // Downsampling Factor is 2
-
- // Downsampling by 2 gives cA
- downsamp(cAUndec, d, sigop);
-
- sigop.erase(sigop.begin(), sigop.begin() + lenAvg / 2);
- sigop.erase(sigop.end() - lenAvg / 2, sigop.end());
-
-
- return nullptr;
- }
-
- void* idwt2(const std::string& name, std::vector<std::vector<double>>& signal, std::vector<std::vector<double>>& cLL, std::vector<std::vector<double>>& cLH,
- std::vector<std::vector<double>>& cHL, std::vector<std::vector<double>>& cHH)
- {
- // Synthesis
- const std::size_t rows = cLL.size();
- const std::size_t cols = cLL[0].size();
- const std::size_t nRows = 2 * rows;
- // Row Upsampling and Column Filtering at the first LP Stage
- std::vector<std::vector<double>> cL(nRows, std::vector<double>(cols));
- std::vector<std::vector<double>> cH(nRows, std::vector<double>(cols));
-
- for (std::size_t j = 0; j < cols; ++j)
- {
- std::vector<double> sigLL;
- std::vector<double> sigLH;
- for (std::size_t i = 0; i < rows; ++i)
- {
- double temp1 = cLL[i][j];
- double temp2 = cLH[i][j];
- sigLL.push_back(temp1);
- sigLH.push_back(temp2);
- }
- std::vector<double> oup;
-
- branch_lp_hp_up(name, sigLL, sigLH, oup);
- sigLL.clear();
- sigLH.clear();
- for (std::size_t i = 0; i < oup.size(); ++i) { cL[i][j] = oup[i]; }
- }
-
- for (std::size_t j = 0; j < cols; ++j)
- {
- std::vector<double> sigHL;
- std::vector<double> sigHH;
- for (std::size_t i = 0; i < rows; ++i)
- {
- double temp3 = cHL[i][j];
- double temp4 = cHH[i][j];
- sigHL.push_back(temp3);
- sigHH.push_back(temp4);
- }
- std::vector<double> oup2;
- branch_lp_hp_up(name, sigHL, sigHH, oup2);
- sigHL.clear();
- sigHH.clear();
-
- for (std::size_t i = 0; i < oup2.size(); ++i) { cH[i][j] = oup2[i]; }
- }
-
- for (std::size_t i = 0; i < nRows; ++i)
- {
- std::vector<double> sigL;
- std::vector<double> sigH;
- for (std::size_t j = 0; j < cols; ++j)
- {
- double temp5 = cL[i][j];
- double temp6 = cH[i][j];
- sigL.push_back(temp5);
- sigH.push_back(temp6);
- }
- std::vector<double> oup3;
- branch_lp_hp_up(name, sigL, sigH, oup3);
- sigL.clear();
- sigH.clear();
-
- for (std::size_t j = 0; j < oup3.size(); ++j) { signal[i][j] = oup3[j]; }
- }
- return nullptr;
- }
-
- void* dwt2(const std::string& name, std::vector<std::vector<double>>& signal, std::vector<std::vector<double>>& cLL, std::vector<std::vector<double>>& cLH,
- std::vector<std::vector<double>>& cHL, std::vector<std::vector<double>>& cHH)
- {
- //Analysis
- const std::size_t rows = signal.size();
- std::size_t cols = signal[0].size();
- const std::size_t colsLp1 = cLL[0].size();
- const std::size_t colsHp1 = cLL[0].size();
- std::vector<double> lp1, hp1, lp2, hp2;
- filtcoef(name, lp1, hp1, lp2, hp2);
- std::vector<std::vector<double>> lpDn1(rows, std::vector<double>(colsLp1));
- std::vector<std::vector<double>> hpDn1(rows, std::vector<double>(colsHp1));
-
- // Implementing row filtering and column downsampling in each branch.
- for (std::size_t i = 0; i < rows; ++i)
- {
- std::vector<double> tempRow, oupLp, oupHp;
- for (std::size_t j = 0; j < cols; ++j)
- {
- double temp = signal[i][j];
- tempRow.push_back(temp);
- }
- dwt1_m(name, tempRow, oupLp, oupHp);
-
- for (std::size_t j = 0; j < oupLp.size(); ++j)
- {
- lpDn1[i][j] = oupLp[j];
- hpDn1[i][j] = oupHp[j];
- }
- }
-
-
- cols = colsLp1;
- // Implementing column filtering and row downsampling in Low Pass branch.
-
- for (std::size_t j = 0; j < cols; ++j)
- {
- std::vector<double> tempRow3, oupLp, oupHp;
- for (std::size_t i = 0; i < rows; ++i)
- {
- double temp = lpDn1[i][j];
- tempRow3.push_back(temp);
- }
- dwt1_m(name, tempRow3, oupLp, oupHp);
-
- for (std::size_t i = 0; i < oupLp.size(); ++i)
- {
- cLL[i][j] = oupLp[i];
- cLH[i][j] = oupHp[i];
- }
- }
-
-
- // Implementing column filtering and row downsampling in High Pass branch.
-
- for (std::size_t j = 0; j < cols; ++j)
- {
- std::vector<double> tempRow5, oupLp, oupHp;
- for (std::size_t i = 0; i < rows; ++i)
- {
- double temp = hpDn1[i][j];
- tempRow5.push_back(temp);
- }
- dwt1_m(name, tempRow5, oupLp, oupHp);
-
- for (std::size_t i = 0; i < oupLp.size(); ++i)
- {
- cHL[i][j] = oupLp[i];
- cHH[i][j] = oupHp[i];
- }
- }
- return nullptr;
- }
-
-
- void* downsamp2(std::vector<std::vector<double>>& vec1, std::vector<std::vector<double>>& vec2, const int rowsDn, const int colsDn)
- {
- const std::size_t rows = vec1.size();
- const std::size_t cols = vec1[0].size();
- const std::size_t nRows = std::size_t(ceil(double(rows) / double(rowsDn)));
- const std::size_t nCols = std::size_t(ceil(double(cols) / double(colsDn)));
- for (std::size_t i = 0; i < nRows; ++i) { for (std::size_t j = 0; j < nCols; ++j) { vec2[i][j] = vec1[i * rowsDn][j * colsDn]; } }
- return nullptr;
- }
-
- void* upsamp2(std::vector<std::vector<double>>& vec1, std::vector<std::vector<double>>& vec2, const int rowsUp, const int colsUp)
- {
- const std::size_t rows = vec1.size();
- const std::size_t cols = vec1[0].size();
- const std::size_t nRows = rows * rowsUp;
- const std::size_t nCols = cols * colsUp;
- for (std::size_t i = 0; i < nRows; ++i)
- {
- for (std::size_t j = 0; j < nCols; ++j)
- {
- if (i % rowsUp == 0 && j % colsUp == 0) { vec2[i][j] = vec1[i / rowsUp][j / colsUp]; }
- else { vec2[i][j] = 0; }
- }
- }
- return nullptr;
- }
-
-
- int filtcoef(const std::string& name, std::vector<double>& lp1, std::vector<double>& hp1, std::vector<double>& lp2, std::vector<double>& hp2)
- {
- if (name == "haar" || name == "db1")
- {
- lp1.push_back(0.7071);
- lp1.push_back(0.7071);
- hp1.push_back(-0.7071);
- hp1.push_back(0.7071);
- lp2.push_back(0.7071);
- lp2.push_back(0.7071);
- hp2.push_back(0.7071);
- hp2.push_back(-0.7071);
- // std::cout << lp2[1] << std::endl;
- // hpd = {-0.7071, 0.7071};
- // lpr = {0.7071, 0.7071};
- // hpr = {0.7071, -0.7071};
- return 0;
- }
- if (name == "db2")
- {
- lp1 = { -0.12940952255092145, 0.22414386804185735, 0.83651630373746899, 0.48296291314469025 };
- hp1 = { -0.48296291314469025, 0.83651630373746899, -0.22414386804185735, -0.12940952255092145 };
- lp2 = { 0.48296291314469025, 0.83651630373746899, 0.22414386804185735, -0.12940952255092145 };
- hp2 = { -0.12940952255092145, -0.22414386804185735, 0.83651630373746899, -0.48296291314469025 };
- return 0;
- }
- if (name == "db3")
- {
- lp1 = { 0.035226291882100656, -0.085441273882241486, -0.13501102001039084, 0.45987750211933132, 0.80689150931333875, 0.33267055295095688 };
- hp1 = { -0.33267055295095688, 0.80689150931333875, -0.45987750211933132, -0.13501102001039084, 0.085441273882241486, 0.035226291882100656 };
- lp2 = { 0.33267055295095688, 0.80689150931333875, 0.45987750211933132, -0.13501102001039084, -0.085441273882241486, 0.035226291882100656 };
- hp2 = { 0.035226291882100656, 0.085441273882241486, -0.13501102001039084, -0.45987750211933132, 0.80689150931333875, -0.33267055295095688 };
- return 0;
- }
- if (name == "db4")
- {
- lp1 = {
- -0.010597401784997278, 0.032883011666982945, 0.030841381835986965, -0.18703481171888114, -0.027983769416983849, 0.63088076792959036,
- 0.71484657055254153, 0.23037781330885523
- };
-
- hp1 = {
- -0.23037781330885523, 0.71484657055254153, -0.63088076792959036, -0.027983769416983849, 0.18703481171888114, 0.030841381835986965,
- -0.032883011666982945, -0.010597401784997278
- };
-
- lp2 = {
- 0.23037781330885523, 0.71484657055254153, 0.63088076792959036, -0.027983769416983849, -0.18703481171888114, 0.030841381835986965,
- 0.032883011666982945, -0.010597401784997278
- };
-
- hp2 = {
- -0.010597401784997278, -0.032883011666982945, 0.030841381835986965, 0.18703481171888114, -0.027983769416983849, -0.63088076792959036,
- 0.71484657055254153, -0.23037781330885523
- };
- return 0;
- }
- if (name == "db5")
- {
- lp1 = {
- 0.0033357252850015492, -0.012580751999015526, -0.0062414902130117052, 0.077571493840065148, -0.03224486958502952, -0.24229488706619015,
- 0.13842814590110342, 0.72430852843857441, 0.60382926979747287, 0.16010239797412501
- };
-
- hp1 = {
- -0.16010239797412501, 0.60382926979747287, -0.72430852843857441, 0.13842814590110342, 0.24229488706619015, -0.03224486958502952,
- -0.077571493840065148, -0.0062414902130117052, 0.012580751999015526, 0.0033357252850015492
- };
-
- lp2 = {
- 0.16010239797412501, 0.60382926979747287, 0.72430852843857441, 0.13842814590110342, -0.24229488706619015, -0.03224486958502952,
- 0.077571493840065148, -0.0062414902130117052, -0.012580751999015526, 0.0033357252850015492
- };
-
- hp2 = {
- 0.0033357252850015492, 0.012580751999015526, -0.0062414902130117052, -0.077571493840065148, -0.03224486958502952, 0.24229488706619015,
- 0.13842814590110342, -0.72430852843857441, 0.60382926979747287, -0.16010239797412501
- };
- return 0;
- }
- if (name == "db6")
- {
- lp1 = {
- -0.0010773010849955799, 0.0047772575110106514, 0.0005538422009938016, -0.031582039318031156, 0.027522865530016288, 0.097501605587079362,
- -0.12976686756709563, -0.22626469396516913, 0.3152503517092432, 0.75113390802157753, 0.49462389039838539, 0.11154074335008017
- };
-
- hp1 = {
- -0.11154074335008017, 0.49462389039838539, -0.75113390802157753, 0.3152503517092432, 0.22626469396516913, -0.12976686756709563,
- -0.097501605587079362, 0.027522865530016288, 0.031582039318031156, 0.0005538422009938016, -0.0047772575110106514, -0.0010773010849955799
- };
-
- lp2 = {
- 0.11154074335008017, 0.49462389039838539, 0.75113390802157753, 0.3152503517092432, -0.22626469396516913, -0.12976686756709563, 0.097501605587079362,
- 0.027522865530016288, -0.031582039318031156, 0.0005538422009938016, 0.0047772575110106514, -0.0010773010849955799
- };
-
- hp2 = {
- -0.0010773010849955799, -0.0047772575110106514, 0.0005538422009938016, 0.031582039318031156, 0.027522865530016288, -0.097501605587079362,
- -0.12976686756709563, 0.22626469396516913, 0.3152503517092432, -0.75113390802157753, 0.49462389039838539, -0.11154074335008017
- };
- return 0;
- }
- if (name == "db7")
- {
- lp1 = {
- 0.00035371380000103988, -0.0018016407039998328, 0.00042957797300470274, 0.012550998556013784, -0.01657454163101562, -0.038029936935034633,
- 0.080612609151065898, 0.071309219267050042, -0.22403618499416572, -0.14390600392910627, 0.4697822874053586, 0.72913209084655506,
- 0.39653931948230575, 0.077852054085062364
- };
-
- hp1 = {
- -0.077852054085062364, 0.39653931948230575, -0.72913209084655506, 0.4697822874053586, 0.14390600392910627, -0.22403618499416572,
- -0.071309219267050042, 0.080612609151065898, 0.038029936935034633, -0.01657454163101562, -0.012550998556013784, 0.0004295779730047027,
- 0.0018016407039998328, 0.00035371380000103988
- };
-
- lp2 = {
- 0.077852054085062364, 0.39653931948230575, 0.72913209084655506, 0.4697822874053586, -0.14390600392910627, -0.22403618499416572,
- 0.071309219267050042, 0.080612609151065898, -0.038029936935034633, -0.01657454163101562, 0.012550998556013784, 0.00042957797300470274,
- -0.0018016407039998328, 0.00035371380000103988
- };
-
- hp2 = {
- 0.00035371380000103988, 0.0018016407039998328, 0.00042957797300470274, -0.01255099855601378, -0.01657454163101562, 0.038029936935034633,
- 0.080612609151065898, -0.071309219267050042, -0.22403618499416572, 0.14390600392910627, 0.4697822874053586, -0.72913209084655506,
- 0.39653931948230575, -0.077852054085062364
- };
- return 0;
- }
- if (name == "db8")
- {
- lp1 = {
- -0.00011747678400228192, 0.00067544940599855677, -0.00039174037299597711, -0.0048703529930106603, 0.0087460940470156547, 0.013981027917015516,
- -0.044088253931064719, -0.017369301002022108, 0.12874742662018601, 0.00047248457399797254, -0.28401554296242809, -0.015829105256023893,
- 0.58535468365486909, 0.67563073629801285, 0.31287159091446592, 0.054415842243081609
- };
-
- hp1 = {
- -0.054415842243081609, 0.31287159091446592, -0.67563073629801285, 0.58535468365486909, 0.015829105256023893, -0.28401554296242809,
- -0.00047248457399797254, 0.12874742662018601, 0.017369301002022108, -0.044088253931064719, -0.013981027917015516, 0.0087460940470156547,
- 0.0048703529930106603, -0.00039174037299597711, -0.00067544940599855677, -0.00011747678400228192
- };
-
- lp2 = {
- 0.054415842243081609, 0.31287159091446592, 0.67563073629801285, 0.58535468365486909, -0.015829105256023893, -0.28401554296242809,
- 0.00047248457399797254, 0.12874742662018601, -0.017369301002022108, -0.044088253931064719, 0.013981027917015516, 0.0087460940470156547,
- -0.0048703529930106603, -0.00039174037299597711, 0.00067544940599855677, -0.00011747678400228192
- };
-
- hp2 = {
- -0.00011747678400228192, -0.00067544940599855677, -0.00039174037299597711, 0.0048703529930106603, 0.0087460940470156547, -0.013981027917015516,
- -0.044088253931064719, 0.017369301002022108, 0.12874742662018601, -0.00047248457399797254, -0.28401554296242809, 0.015829105256023893,
- 0.58535468365486909, -0.67563073629801285, 0.31287159091446592, -0.054415842243081609
- };
- return 0;
- }
- if (name == "db9")
- {
- lp1 = {
- 3.9347319995026124e-05, -0.00025196318899817888, 0.00023038576399541288, 0.0018476468829611268, -0.0042815036819047227, -0.004723204757894831,
- 0.022361662123515244, 0.00025094711499193845, -0.067632829059523988, 0.030725681478322865, 0.14854074933476008, -0.096840783220879037,
- -0.29327378327258685, 0.13319738582208895, 0.65728807803663891, 0.6048231236767786, 0.24383467463766728, 0.038077947363167282
- };
-
- hp1 = {
- -0.038077947363167282, 0.24383467463766728, -0.6048231236767786, 0.65728807803663891, -0.13319738582208895, -0.29327378327258685,
- 0.096840783220879037, 0.14854074933476008, -0.030725681478322865, -0.067632829059523988, -0.00025094711499193845, 0.022361662123515244,
- 0.004723204757894831, -0.0042815036819047227, -0.0018476468829611268, 0.00023038576399541288, 0.00025196318899817888, 3.9347319995026124e-05
- };
-
- lp2 = {
- 0.038077947363167282, 0.24383467463766728, 0.6048231236767786, 0.65728807803663891, 0.13319738582208895, -0.29327378327258685,
- -0.096840783220879037, 0.14854074933476008, 0.030725681478322865, -0.067632829059523988, 0.00025094711499193845, 0.022361662123515244,
- -0.004723204757894831, -0.0042815036819047227, 0.0018476468829611268, 0.00023038576399541288, -0.00025196318899817888, 3.9347319995026124e-05
- };
-
- hp2 = {
- 3.9347319995026124e-05, 0.00025196318899817888, 0.00023038576399541288, -0.0018476468829611268, -0.0042815036819047227, 0.004723204757894831,
- 0.022361662123515244, -0.00025094711499193845, -0.067632829059523988, -0.030725681478322865, 0.14854074933476008, 0.096840783220879037,
- -0.29327378327258685, -0.13319738582208895, 0.65728807803663891, -0.6048231236767786, 0.24383467463766728, -0.038077947363167282
- };
- return 0;
- }
- if (name == "db10")
- {
- lp1 = {
- -1.3264203002354869e-05, 9.3588670001089845e-05, -0.0001164668549943862, -0.00068585669500468248, 0.0019924052949908499, 0.0013953517469940798,
- -0.010733175482979604, 0.0036065535669883944, 0.033212674058933238, -0.029457536821945671, -0.071394147165860775, 0.093057364603806592,
- 0.12736934033574265, -0.19594627437659665, -0.24984642432648865, 0.28117234366042648, 0.68845903945259213, 0.52720118893091983, 0.18817680007762133,
- 0.026670057900950818
- };
-
- hp1 = {
- -0.026670057900950818, 0.18817680007762133, -0.52720118893091983, 0.68845903945259213, -0.28117234366042648, -0.24984642432648865,
- 0.19594627437659665, 0.12736934033574265, -0.093057364603806592, -0.071394147165860775, 0.029457536821945671, 0.033212674058933238,
- -0.0036065535669883944, -0.010733175482979604, -0.0013953517469940798, 0.0019924052949908499, 0.00068585669500468248, -0.0001164668549943862,
- -9.3588670001089845e-05, -1.3264203002354869e-05
- };
-
- lp2 = {
- 0.026670057900950818, 0.18817680007762133, 0.52720118893091983, 0.68845903945259213, 0.28117234366042648, -0.24984642432648865,
- -0.19594627437659665, 0.12736934033574265, 0.093057364603806592, -0.071394147165860775, -0.029457536821945671, 0.033212674058933238,
- 0.0036065535669883944, -0.010733175482979604, 0.0013953517469940798, 0.0019924052949908499, -0.00068585669500468248, -0.0001164668549943862,
- 9.3588670001089845e-05, -1.3264203002354869e-05
- };
-
- hp2 = {
- -1.3264203002354869e-05, -9.3588670001089845e-05, -0.0001164668549943862, 0.00068585669500468248, 0.0019924052949908499, -0.0013953517469940798,
- -0.010733175482979604, -0.0036065535669883944, 0.033212674058933238, 0.029457536821945671, -0.071394147165860775, -0.093057364603806592,
- 0.12736934033574265, 0.19594627437659665, -0.24984642432648865, -0.28117234366042648, 0.68845903945259213, -0.52720118893091983,
- 0.18817680007762133, -0.026670057900950818
- };
- return 0;
- }
- if (name == "db12")
- {
- lp1 = {
- -1.5290717580684923e-06, 1.2776952219379579e-05, -2.4241545757030318e-05, -8.8504109208203182e-05, 0.00038865306282092672, 6.5451282125215034e-06,
- -0.0021795036186277044, 0.0022486072409952287, 0.0067114990087955486, -0.012840825198299882, -0.01221864906974642, 0.041546277495087637,
- 0.010849130255828966, -0.09643212009649671, 0.0053595696743599965, 0.18247860592758275, -0.023779257256064865, -0.31617845375277914,
- -0.044763885653777619, 0.51588647842780067, 0.65719872257929113, 0.37735513521420411, 0.10956627282118277, 0.013112257957229239
- };
-
- hp1 = {
- -0.013112257957229239, 0.10956627282118277, -0.37735513521420411, 0.65719872257929113, -0.51588647842780067, -0.044763885653777619,
- 0.31617845375277914, -0.023779257256064865, -0.18247860592758275, 0.0053595696743599965, 0.09643212009649671, 0.010849130255828966,
- -0.041546277495087637, -0.01221864906974642, 0.012840825198299882, 0.0067114990087955486, -0.0022486072409952287, -0.0021795036186277044,
- -6.5451282125215034e-06, 0.00038865306282092672, 8.8504109208203182e-05, -2.4241545757030318e-05, -1.2776952219379579e-05, -1.5290717580684923e-06
- };
-
- lp2 = {
- 0.013112257957229239, 0.10956627282118277, 0.37735513521420411, 0.65719872257929113, 0.51588647842780067, -0.044763885653777619,
- -0.31617845375277914, -0.023779257256064865, 0.18247860592758275, 0.0053595696743599965, -0.09643212009649671, 0.010849130255828966,
- 0.041546277495087637, -0.01221864906974642, -0.012840825198299882, 0.0067114990087955486, 0.0022486072409952287, -0.0021795036186277044,
- 6.5451282125215034e-06, 0.00038865306282092672, -8.8504109208203182e-05, -2.4241545757030318e-05, 1.2776952219379579e-05, -1.5290717580684923e-06
- };
-
- hp2 = {
- -1.5290717580684923e-06, -1.2776952219379579e-05, -2.4241545757030318e-05, 8.8504109208203182e-05, 0.00038865306282092672, -6.5451282125215034e-06,
- -0.0021795036186277044, -0.0022486072409952287, 0.0067114990087955486, 0.012840825198299882, -0.01221864906974642, -0.041546277495087637,
- 0.010849130255828966, 0.09643212009649671, 0.0053595696743599965, -0.18247860592758275, -0.023779257256064865, 0.31617845375277914,
- -0.044763885653777619, -0.51588647842780067, 0.65719872257929113, -0.37735513521420411, 0.10956627282118277, -0.013112257957229239
- };
- return 0;
- }
- if (name == "db13")
- {
- lp1 = {
- 5.2200350984547998e-07, -4.7004164793608082e-06, 1.0441930571407941e-05, 3.0678537579324358e-05, -0.00016512898855650571, 4.9251525126285676e-05,
- 0.00093232613086724904, -0.0013156739118922766, -0.002761911234656831, 0.0072555894016171187, 0.0039239414487955773, -0.023831420710327809,
- 0.0023799722540522269, 0.056139477100276156, -0.026488406475345658, -0.10580761818792761, 0.072948933656788742, 0.17947607942935084,
- -0.12457673075080665, -0.31497290771138414, 0.086985726179645007, 0.58888957043121193, 0.61105585115878114, 0.31199632216043488,
- 0.082861243872901946, 0.0092021335389622788
- };
-
- hp1 = {
- -0.0092021335389622788, 0.082861243872901946, -0.31199632216043488, 0.61105585115878114, -0.58888957043121193, 0.086985726179645007,
- 0.31497290771138414, -0.12457673075080665, -0.17947607942935084, 0.072948933656788742, 0.10580761818792761, -0.026488406475345658,
- -0.056139477100276156, 0.0023799722540522269, 0.023831420710327809, 0.0039239414487955773, -0.0072555894016171187, -0.002761911234656831,
- 0.0013156739118922766, 0.00093232613086724904, -4.9251525126285676e-05, -0.00016512898855650571, -3.0678537579324358e-05, 1.0441930571407941e-05,
- 4.7004164793608082e-06, 5.2200350984547998e-07
- };
-
- lp2 = {
- 0.0092021335389622788, 0.082861243872901946, 0.31199632216043488, 0.61105585115878114, 0.58888957043121193, 0.086985726179645007,
- -0.31497290771138414, -0.12457673075080665, 0.17947607942935084, 0.072948933656788742, -0.10580761818792761, -0.026488406475345658,
- 0.056139477100276156, 0.0023799722540522269, -0.023831420710327809, 0.0039239414487955773, 0.0072555894016171187, -0.002761911234656831,
- -0.0013156739118922766, 0.00093232613086724904, 4.9251525126285676e-05, -0.00016512898855650571, 3.0678537579324358e-05, 1.0441930571407941e-05,
- -4.7004164793608082e-06, 5.2200350984547998e-07
- };
-
- hp2 = {
- 5.2200350984547998e-07, 4.7004164793608082e-06, 1.0441930571407941e-05, -3.0678537579324358e-05, -0.00016512898855650571, -4.9251525126285676e-05,
- 0.00093232613086724904, 0.0013156739118922766, -0.002761911234656831, -0.0072555894016171187, 0.0039239414487955773, 0.023831420710327809,
- 0.0023799722540522269, -0.056139477100276156, -0.026488406475345658, 0.10580761818792761, 0.072948933656788742, -0.17947607942935084,
- -0.12457673075080665, 0.31497290771138414, 0.086985726179645007, -0.58888957043121193, 0.61105585115878114, -0.31199632216043488,
- 0.082861243872901946, -0.0092021335389622788
- };
- return 0;
- }
- if (name == "db11")
- {
- lp1 = {
- 4.4942742772363519e-06, -3.4634984186983789e-05, 5.4439074699366381e-05, 0.00024915252355281426, -0.00089302325066623663, -0.00030859285881515924,
- 0.0049284176560587777, -0.0033408588730145018, -0.015364820906201324, 0.020840904360180039, 0.031335090219045313, -0.066438785695020222,
- -0.04647995511667613, 0.14981201246638268, 0.066043588196690886, -0.27423084681792875, -0.16227524502747828, 0.41196436894789695,
- 0.68568677491617847, 0.44989976435603013, 0.14406702115061959, 0.018694297761470441
- };
-
- hp1 = {
- -0.018694297761470441, 0.14406702115061959, -0.44989976435603013, 0.68568677491617847, -0.41196436894789695, -0.16227524502747828,
- 0.27423084681792875, 0.066043588196690886, -0.14981201246638268, -0.04647995511667613, 0.066438785695020222, 0.031335090219045313,
- -0.020840904360180039, -0.015364820906201324, 0.0033408588730145018, 0.0049284176560587777, 0.00030859285881515924, -0.00089302325066623663,
- -0.00024915252355281426, 5.4439074699366381e-05, 3.4634984186983789e-05, 4.4942742772363519e-06
- };
-
- lp2 = {
- 0.018694297761470441, 0.14406702115061959, 0.44989976435603013, 0.68568677491617847, 0.41196436894789695, -0.16227524502747828,
- -0.27423084681792875, 0.066043588196690886, 0.14981201246638268, -0.04647995511667613, -0.066438785695020222, 0.031335090219045313,
- 0.020840904360180039, -0.015364820906201324, -0.0033408588730145018, 0.0049284176560587777, -0.00030859285881515924, -0.00089302325066623663,
- 0.00024915252355281426, 5.4439074699366381e-05, -3.4634984186983789e-05, 4.4942742772363519e-06
- };
-
- hp2 = {
- 4.4942742772363519e-06, 3.4634984186983789e-05, 5.4439074699366381e-05, -0.00024915252355281426, -0.00089302325066623663, 0.00030859285881515924,
- 0.0049284176560587777, 0.0033408588730145018, -0.015364820906201324, -0.020840904360180039, 0.031335090219045313, 0.066438785695020222,
- -0.04647995511667613, -0.14981201246638268, 0.066043588196690886, 0.27423084681792875, -0.16227524502747828, -0.41196436894789695,
- 0.68568677491617847, -0.44989976435603013, 0.14406702115061959, -0.018694297761470441
- };
- return 0;
- }
- if (name == "db14")
- {
- lp1 = {
- -1.7871399683109222e-07, 1.7249946753674012e-06, -4.3897049017804176e-06, -1.0337209184568496e-05, 6.875504252695734e-05, -4.1777245770370672e-05,
- -0.00038683194731287514, 0.00070802115423540481, 0.001061691085606874, -0.003849638868019787, -0.00074621898926387534, 0.012789493266340071,
- -0.0056150495303375755, -0.030185351540353976, 0.026981408307947971, 0.05523712625925082, -0.071548955503983505, -0.086748411568110598,
- 0.13998901658445695, 0.13839521386479153, -0.21803352999321651, -0.27168855227867705, 0.21867068775886594, 0.63118784910471981, 0.55430561794077093,
- 0.25485026779256437, 0.062364758849384874, 0.0064611534600864905
- };
-
- hp1 = {
- -0.0064611534600864905, 0.062364758849384874, -0.25485026779256437, 0.55430561794077093, -0.63118784910471981, 0.21867068775886594,
- 0.27168855227867705, -0.21803352999321651, -0.13839521386479153, 0.13998901658445695, 0.086748411568110598, -0.071548955503983505,
- -0.05523712625925082, 0.026981408307947971, 0.030185351540353976, -0.0056150495303375755, -0.012789493266340071, -0.00074621898926387534,
- 0.003849638868019787, 0.001061691085606874, -0.00070802115423540481, -0.00038683194731287514, 4.1777245770370672e-05, 6.875504252695734e-05,
- 1.0337209184568496e-05, -4.3897049017804176e-06, -1.7249946753674012e-06, -1.7871399683109222e-07
- };
-
- lp2 = {
- 0.0064611534600864905, 0.062364758849384874, 0.25485026779256437, 0.55430561794077093, 0.63118784910471981, 0.21867068775886594,
- -0.27168855227867705, -0.21803352999321651, 0.13839521386479153, 0.13998901658445695, -0.086748411568110598, -0.071548955503983505,
- 0.05523712625925082, 0.026981408307947971, -0.030185351540353976, -0.0056150495303375755, 0.012789493266340071, -0.00074621898926387534,
- -0.003849638868019787, 0.001061691085606874, 0.00070802115423540481, -0.00038683194731287514, -4.1777245770370672e-05, 6.875504252695734e-05,
- -1.0337209184568496e-05, -4.3897049017804176e-06, 1.7249946753674012e-06, -1.7871399683109222e-07
- };
-
- hp2 = {
- -1.7871399683109222e-07, -1.7249946753674012e-06, -4.3897049017804176e-06, 1.0337209184568496e-05, 6.875504252695734e-05, 4.1777245770370672e-05,
- -0.00038683194731287514, -0.00070802115423540481, 0.001061691085606874, 0.003849638868019787, -0.00074621898926387534, -0.012789493266340071,
- -0.0056150495303375755, 0.030185351540353976, 0.026981408307947971, -0.05523712625925082, -0.071548955503983505, 0.086748411568110598,
- 0.13998901658445695, -0.13839521386479153, -0.21803352999321651, 0.27168855227867705, 0.21867068775886594, -0.63118784910471981,
- 0.55430561794077093, -0.25485026779256437, 0.062364758849384874, -0.0064611534600864905
- };
- return 0;
- }
- if (name == "db15")
- {
- lp1 = {
- 6.1333599133037138e-08, -6.3168823258794506e-07, 1.8112704079399406e-06, 3.3629871817363823e-06, -2.8133296266037558e-05, 2.579269915531323e-05,
- 0.00015589648992055726, -0.00035956524436229364, -0.00037348235413726472, 0.0019433239803823459, -0.00024175649075894543, -0.0064877345603061454,
- 0.0051010003604228726, 0.015083918027862582, -0.020810050169636805, -0.025767007328366939, 0.054780550584559995, 0.033877143923563204,
- -0.11112093603713753, -0.039666176555733602, 0.19014671400708816, 0.065282952848765688, -0.28888259656686216, -0.19320413960907623,
- 0.33900253545462167, 0.64581314035721027, 0.49263177170797529, 0.20602386398692688, 0.046743394892750617, 0.0045385373615773762
- };
-
- hp1 = {
- -0.0045385373615773762, 0.046743394892750617, -0.20602386398692688, 0.49263177170797529, -0.64581314035721027, 0.33900253545462167,
- 0.19320413960907623, -0.28888259656686216, -0.065282952848765688, 0.19014671400708816, 0.039666176555733602, -0.11112093603713753,
- -0.033877143923563204, 0.054780550584559995, 0.025767007328366939, -0.020810050169636805, -0.015083918027862582, 0.0051010003604228726,
- 0.0064877345603061454, -0.00024175649075894543, -0.0019433239803823459, -0.00037348235413726472, 0.00035956524436229364, 0.00015589648992055726,
- -2.579269915531323e-05, -2.8133296266037558e-05, -3.3629871817363823e-06, 1.8112704079399406e-06, 6.3168823258794506e-07, 6.1333599133037138e-08
- };
-
- lp2 = {
- 0.0045385373615773762, 0.046743394892750617, 0.20602386398692688, 0.49263177170797529, 0.64581314035721027, 0.33900253545462167,
- -0.19320413960907623, -0.28888259656686216, 0.065282952848765688, 0.19014671400708816, -0.039666176555733602, -0.11112093603713753,
- 0.033877143923563204, 0.054780550584559995, -0.025767007328366939, -0.020810050169636805, 0.015083918027862582, 0.0051010003604228726,
- -0.0064877345603061454, -0.00024175649075894543, 0.0019433239803823459, -0.00037348235413726472, -0.00035956524436229364, 0.00015589648992055726,
- 2.579269915531323e-05, -2.8133296266037558e-05, 3.3629871817363823e-06, 1.8112704079399406e-06, -6.3168823258794506e-07, 6.1333599133037138e-08
- };
-
- hp2 = {
- 6.1333599133037138e-08, 6.3168823258794506e-07, 1.8112704079399406e-06, -3.3629871817363823e-06, -2.8133296266037558e-05, -2.579269915531323e-05,
- 0.00015589648992055726, 0.00035956524436229364, -0.00037348235413726472, -0.0019433239803823459, -0.00024175649075894543, 0.0064877345603061454,
- 0.0051010003604228726, -0.015083918027862582, -0.020810050169636805, 0.025767007328366939, 0.054780550584559995, -0.033877143923563204,
- -0.11112093603713753, 0.039666176555733602, 0.19014671400708816, -0.065282952848765688, -0.28888259656686216, 0.19320413960907623,
- 0.33900253545462167, -0.64581314035721027, 0.49263177170797529, -0.20602386398692688, 0.046743394892750617, -0.0045385373615773762
- };
- return 0;
- }
- if (name == "bior1.1")
- {
- lp1 = { 0.70710678118654757, 0.70710678118654757 };
- hp1 = { -0.70710678118654757, 0.70710678118654757 };
- lp2 = { 0.70710678118654757, 0.70710678118654757 };
- hp2 = { 0.70710678118654757, -0.70710678118654757 };
- return 0;
- }
- if (name == "bior1.3")
- {
- lp1 = { -0.088388347648318447, 0.088388347648318447, 0.70710678118654757, 0.70710678118654757, 0.088388347648318447, -0.088388347648318447, };
- hp1 = { 0.0, 0.0, -0.70710678118654757, 0.70710678118654757, 0.0, 0.0 };
- lp2 = { 0.0, 0.0, 0.70710678118654757, 0.70710678118654757, 0.0, 0.0 };
- hp2 = { -0.088388347648318447, -0.088388347648318447, 0.70710678118654757, -0.70710678118654757, 0.088388347648318447, 0.088388347648318447 };
- return 0;
- }
- if (name == "bior1.5")
- {
- lp1 = {
- 0.01657281518405971, -0.01657281518405971, -0.12153397801643787, 0.12153397801643787, 0.70710678118654757, 0.70710678118654757, 0.12153397801643787,
- -0.12153397801643787, -0.01657281518405971, 0.01657281518405971
- };
-
- hp1 = { 0.0, 0.0, 0.0, 0.0, -0.70710678118654757, 0.70710678118654757, 0.0, 0.0, 0.0, 0.0 };
-
- lp2 = { 0.0, 0.0, 0.0, 0.0, 0.70710678118654757, 0.70710678118654757, 0.0, 0.0, 0.0, 0.0 };
-
- hp2 = {
- 0.01657281518405971, 0.01657281518405971, -0.12153397801643787, -0.12153397801643787, 0.70710678118654757, -0.70710678118654757,
- 0.12153397801643787, 0.12153397801643787, -0.01657281518405971, -0.01657281518405971
- };
- return 0;
- }
- if (name == "bior2.2")
- {
- lp1 = { 0.0, -0.17677669529663689, 0.35355339059327379, 1.0606601717798214, 0.35355339059327379, -0.17677669529663689 };
-
- hp1 = { 0.0, 0.35355339059327379, -0.70710678118654757, 0.35355339059327379, 0.0, 0.0 };
-
- lp2 = { 0.0, 0.35355339059327379, 0.70710678118654757, 0.35355339059327379, 0.0, 0.0 };
-
- hp2 = { 0.0, 0.17677669529663689, 0.35355339059327379, -1.0606601717798214, 0.35355339059327379, 0.17677669529663689 };
- return 0;
- }
- if (name == "bior2.4")
- {
- lp1 = {
- 0.0, 0.033145630368119419, -0.066291260736238838, -0.17677669529663689, 0.4198446513295126, 0.99436891104358249, 0.4198446513295126,
- -0.17677669529663689, -0.066291260736238838, 0.033145630368119419
- };
-
- hp1 = { 0.0, 0.0, 0.0, 0.35355339059327379, -0.70710678118654757, 0.35355339059327379, 0.0, 0.0, 0.0, 0.0 };
-
- lp2 = { 0.0, 0.0, 0.0, 0.35355339059327379, 0.70710678118654757, 0.35355339059327379, 0.0, 0.0, 0.0, 0.0 };
-
- hp2 = {
- 0.0, -0.033145630368119419, -0.066291260736238838, 0.17677669529663689, 0.4198446513295126, -0.99436891104358249, 0.4198446513295126,
- 0.17677669529663689, -0.066291260736238838, -0.033145630368119419
- };
- return 0;
- }
- if (name == "bior2.6")
- {
- lp1 = {
- 0.0, -0.0069053396600248784, 0.013810679320049757, 0.046956309688169176, -0.10772329869638811, -0.16987135563661201, 0.44746600996961211,
- 0.96674755240348298, 0.44746600996961211, -0.16987135563661201, -0.10772329869638811, 0.046956309688169176, 0.013810679320049757,
- -0.0069053396600248784
- };
-
- hp1 = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.35355339059327379, -0.70710678118654757, 0.35355339059327379, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
-
- lp2 = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.35355339059327379, 0.70710678118654757, 0.35355339059327379, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
-
- hp2 = {
- 0.0, 0.0069053396600248784, 0.013810679320049757, -0.046956309688169176, -0.10772329869638811, 0.16987135563661201, 0.44746600996961211,
- -0.96674755240348298, 0.44746600996961211, 0.16987135563661201, -0.10772329869638811, -0.046956309688169176, 0.013810679320049757,
- 0.0069053396600248784
- };
- return 0;
- }
- if (name == "bior2.8")
- {
- lp1 = {
- 0.0, 0.0015105430506304422, -0.0030210861012608843, -0.012947511862546647, 0.028916109826354178, 0.052998481890690945, -0.13491307360773608,
- -0.16382918343409025, 0.46257144047591658, 0.95164212189717856, 0.46257144047591658, -0.16382918343409025, -0.13491307360773608,
- 0.052998481890690945, 0.028916109826354178, -0.012947511862546647, -0.0030210861012608843, 0.0015105430506304422
- };
-
- hp1 = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.35355339059327379, -0.70710678118654757, 0.35355339059327379, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
-
- lp2 = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.35355339059327379, 0.70710678118654757, 0.35355339059327379, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
-
- hp2 = {
- 0.0, -0.0015105430506304422, -0.0030210861012608843, 0.012947511862546647, 0.028916109826354178, -0.052998481890690945, -0.13491307360773608,
- 0.16382918343409025, 0.46257144047591658, -0.95164212189717856, 0.46257144047591658, 0.16382918343409025, -0.13491307360773608,
- -0.052998481890690945, 0.028916109826354178, 0.012947511862546647, -0.0030210861012608843, -0.0015105430506304422
- };
- return 0;
- }
- if (name == "bior3.1")
- {
- lp1 = { -0.35355339059327379, 1.0606601717798214, 1.0606601717798214, -0.35355339059327379 };
-
- hp1 = { -0.17677669529663689, 0.53033008588991071, -0.53033008588991071, 0.17677669529663689 };
-
- lp2 = { 0.17677669529663689, 0.53033008588991071, 0.53033008588991071, 0.17677669529663689 };
-
- hp2 = { -0.35355339059327379, -1.0606601717798214, 1.0606601717798214, 0.35355339059327379 };
- return 0;
- }
- if (name == "bior3.3")
- {
- lp1 = {
- 0.066291260736238838, -0.19887378220871652, -0.15467960838455727, 0.99436891104358249, 0.99436891104358249, -0.15467960838455727,
- -0.19887378220871652, 0.066291260736238838
- };
-
- hp1 = { 0.0, 0.0, -0.17677669529663689, 0.53033008588991071, -0.53033008588991071, 0.17677669529663689, 0.0, 0.0 };
-
- lp2 = { 0.0, 0.0, 0.17677669529663689, 0.53033008588991071, 0.53033008588991071, 0.17677669529663689, 0.0, 0.0 };
-
- hp2 = {
- 0.066291260736238838, 0.19887378220871652, -0.15467960838455727, -0.99436891104358249, 0.99436891104358249, 0.15467960838455727,
- -0.19887378220871652, -0.066291260736238838
- };
- return 0;
- }
- if (name == "bior3.5")
- {
- lp1 = {
- -0.013810679320049757, 0.041432037960149271, 0.052480581416189075, -0.26792717880896527, -0.071815532464258744, 0.96674755240348298,
- 0.96674755240348298, -0.071815532464258744, -0.26792717880896527, 0.052480581416189075, 0.041432037960149271, -0.013810679320049757
- };
-
- hp1 = { 0.0, 0.0, 0.0, 0.0, -0.17677669529663689, 0.53033008588991071, -0.53033008588991071, 0.17677669529663689, 0.0, 0.0, 0.0, 0.0 };
-
- lp2 = { 0.0, 0.0, 0.0, 0.0, 0.17677669529663689, 0.53033008588991071, 0.53033008588991071, 0.17677669529663689, 0.0, 0.0, 0.0, 0.0 };
-
- hp2 = {
- -0.013810679320049757, -0.041432037960149271, 0.052480581416189075, 0.26792717880896527, -0.071815532464258744, -0.96674755240348298,
- 0.96674755240348298, 0.071815532464258744, -0.26792717880896527, -0.052480581416189075, 0.041432037960149271, 0.013810679320049757
- };
- return 0;
- }
- if (name == "bior3.7")
- {
- lp1 = {
- 0.0030210861012608843, -0.0090632583037826529, -0.016831765421310641, 0.074663985074019001, 0.031332978707362888, -0.301159125922835,
- -0.026499240945345472, 0.95164212189717856, 0.95164212189717856, -0.026499240945345472, -0.301159125922835, 0.031332978707362888,
- 0.074663985074019001, -0.016831765421310641, -0.0090632583037826529, 0.0030210861012608843
- };
-
- hp1 = {
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.17677669529663689, 0.53033008588991071, -0.53033008588991071, 0.17677669529663689, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
- };
-
- lp2 = {
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.17677669529663689, 0.53033008588991071, 0.53033008588991071, 0.17677669529663689, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
- };
-
- hp2 = {
- 0.0030210861012608843, 0.0090632583037826529, -0.016831765421310641, -0.074663985074019001, 0.031332978707362888, 0.301159125922835,
- -0.026499240945345472, -0.95164212189717856, 0.95164212189717856, 0.026499240945345472, -0.301159125922835, -0.031332978707362888,
- 0.074663985074019001, 0.016831765421310641, -0.0090632583037826529, -0.0030210861012608843
- };
- return 0;
- }
- if (name == "bior3.9")
- {
- lp1 = {
- -0.00067974437278369901, 0.0020392331183510968, 0.0050603192196119811, -0.020618912641105536, -0.014112787930175846, 0.09913478249423216,
- 0.012300136269419315, -0.32019196836077857, 0.0020500227115698858, 0.94212570067820678, 0.94212570067820678, 0.0020500227115698858,
- -0.32019196836077857, 0.012300136269419315, 0.09913478249423216, -0.014112787930175846, -0.020618912641105536, 0.0050603192196119811,
- 0.0020392331183510968, -0.00067974437278369901
- };
-
- hp1 = {
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.17677669529663689, 0.53033008588991071, -0.53033008588991071, 0.17677669529663689, 0.0, 0.0, 0.0, 0.0,
- 0.0, 0.0, 0.0, 0.0
- };
-
- lp2 = {
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.17677669529663689, 0.53033008588991071, 0.53033008588991071, 0.17677669529663689, 0.0, 0.0, 0.0, 0.0, 0.0,
- 0.0, 0.0, 0.0
- };
-
- hp2 = {
- -0.00067974437278369901, -0.0020392331183510968, 0.0050603192196119811, 0.020618912641105536, -0.014112787930175846, -0.09913478249423216,
- 0.012300136269419315, 0.32019196836077857, 0.0020500227115698858, -0.94212570067820678, 0.94212570067820678, -0.0020500227115698858,
- -0.32019196836077857, -0.012300136269419315, 0.09913478249423216, 0.014112787930175846, -0.020618912641105536, -0.0050603192196119811,
- 0.0020392331183510968, 0.00067974437278369901
- };
- return 0;
- }
- if (name == "bior4.4")
- {
- lp1 = {
- 0.0, 0.03782845550726404, -0.023849465019556843, -0.11062440441843718, 0.37740285561283066, 0.85269867900889385, 0.37740285561283066,
- -0.11062440441843718, -0.023849465019556843, 0.03782845550726404
- };
-
- hp1 = {
- 0.0, -0.064538882628697058, 0.040689417609164058, 0.41809227322161724, -0.7884856164055829, 0.41809227322161724, 0.040689417609164058,
- -0.064538882628697058, 0.0, 0.0
- };
-
- lp2 = {
- 0.0, -0.064538882628697058, -0.040689417609164058, 0.41809227322161724, 0.7884856164055829, 0.41809227322161724, -0.040689417609164058,
- -0.064538882628697058, 0.0, 0.0
- };
-
- hp2 = {
- 0.0, -0.03782845550726404, -0.023849465019556843, 0.11062440441843718, 0.37740285561283066, -0.85269867900889385, 0.37740285561283066,
- 0.11062440441843718, -0.023849465019556843, -0.03782845550726404
- };
- return 0;
- }
- if (name == "bior5.5")
- {
- lp1 = {
- 0.0, 0.0, 0.03968708834740544, 0.0079481086372403219, -0.054463788468236907, 0.34560528195603346, 0.73666018142821055, 0.34560528195603346,
- -0.054463788468236907, 0.0079481086372403219, 0.03968708834740544, 0.0
- };
-
- hp1 = {
- -0.013456709459118716, -0.0026949668801115071, 0.13670658466432914, -0.093504697400938863, -0.47680326579848425, 0.89950610974864842,
- -0.47680326579848425, -0.093504697400938863, 0.13670658466432914, -0.0026949668801115071, -0.013456709459118716, 0.0
- };
-
- lp2 = {
- 0.013456709459118716, -0.0026949668801115071, -0.13670658466432914, -0.093504697400938863, 0.47680326579848425, 0.89950610974864842,
- 0.47680326579848425, -0.093504697400938863, -0.13670658466432914, -0.0026949668801115071, 0.013456709459118716, 0.0
- };
-
- hp2 = {
- 0.0, 0.0, 0.03968708834740544, -0.0079481086372403219, -0.054463788468236907, -0.34560528195603346, 0.73666018142821055, -0.34560528195603346,
- -0.054463788468236907, -0.0079481086372403219, 0.03968708834740544, 0.0
- };
- return 0;
- }
- if (name == "bior6.8")
- {
- lp1 = {
- 0.0, 0.0019088317364812906, -0.0019142861290887667, -0.016990639867602342, 0.01193456527972926, 0.04973290349094079, -0.077263173167204144,
- -0.09405920349573646, 0.42079628460982682, 0.82592299745840225, 0.42079628460982682, -0.09405920349573646, -0.077263173167204144,
- 0.04973290349094079, 0.01193456527972926, -0.016990639867602342, -0.0019142861290887667, 0.0019088317364812906
- };
-
- hp1 = {
- 0.0, 0.0, 0.0, 0.014426282505624435, -0.014467504896790148, -0.078722001062628819, 0.040367979030339923, 0.41784910915027457, -0.75890772945365415,
- 0.41784910915027457, 0.040367979030339923, -0.078722001062628819, -0.014467504896790148, 0.014426282505624435, 0.0, 0.0, 0.0, 0.0
- };
-
- lp2 = {
- 0.0, 0.0, 0.0, 0.014426282505624435, 0.014467504896790148, -0.078722001062628819, -0.040367979030339923, 0.41784910915027457, 0.75890772945365415,
- 0.41784910915027457, -0.040367979030339923, -0.078722001062628819, 0.014467504896790148, 0.014426282505624435, 0.0, 0.0, 0.0, 0.0
- };
-
- hp2 = {
- 0.0, -0.0019088317364812906, -0.0019142861290887667, 0.016990639867602342, 0.01193456527972926, -0.04973290349094079, -0.077263173167204144,
- 0.09405920349573646, 0.42079628460982682, -0.82592299745840225, 0.42079628460982682, 0.09405920349573646, -0.077263173167204144,
- -0.04973290349094079, 0.01193456527972926, 0.016990639867602342, -0.0019142861290887667, -0.0019088317364812906
- };
- return 0;
- }
- if (name == "coif1")
- {
- lp1 = { -0.01565572813546454, -0.072732619512853897, 0.38486484686420286, 0.85257202021225542, 0.33789766245780922, -0.072732619512853897 };
-
- hp1 = { 0.072732619512853897, 0.33789766245780922, -0.85257202021225542, 0.38486484686420286, 0.072732619512853897, -0.01565572813546454 };
-
- lp2 = { -0.072732619512853897, 0.33789766245780922, 0.85257202021225542, 0.38486484686420286, -0.072732619512853897, -0.01565572813546454 };
-
- hp2 = { -0.01565572813546454, 0.072732619512853897, 0.38486484686420286, -0.85257202021225542, 0.33789766245780922, 0.072732619512853897 };
- return 0;
- }
- if (name == "coif2")
- {
- lp1 = {
- -0.00072054944536451221, -0.0018232088707029932, 0.0056114348193944995, 0.023680171946334084, -0.059434418646456898, -0.076488599078306393,
- 0.41700518442169254, 0.81272363544554227, 0.38611006682116222, -0.067372554721963018, -0.041464936781759151, 0.016387336463522112
- };
-
- hp1 = {
- -0.016387336463522112, -0.041464936781759151, 0.067372554721963018, 0.38611006682116222, -0.81272363544554227, 0.41700518442169254,
- 0.076488599078306393, -0.059434418646456898, -0.023680171946334084, 0.0056114348193944995, 0.0018232088707029932, -0.00072054944536451221
- };
-
- lp2 = {
- 0.016387336463522112, -0.041464936781759151, -0.067372554721963018, 0.38611006682116222, 0.81272363544554227, 0.41700518442169254,
- -0.076488599078306393, -0.059434418646456898, 0.023680171946334084, 0.0056114348193944995, -0.0018232088707029932, -0.00072054944536451221
- };
-
- hp2 = {
- -0.00072054944536451221, 0.0018232088707029932, 0.0056114348193944995, -0.023680171946334084, -0.059434418646456898, 0.076488599078306393,
- 0.41700518442169254, -0.81272363544554227, 0.38611006682116222, 0.067372554721963018, -0.041464936781759151, -0.016387336463522112
- };
- return 0;
- }
- if (name == "coif3")
- {
- lp1 = {
- -3.4599772836212559e-05, -7.0983303138141252e-05, 0.00046621696011288631, 0.0011175187708906016, -0.0025745176887502236, -0.0090079761366615805,
- 0.015880544863615904, 0.034555027573061628, -0.082301927106885983, -0.071799821619312018, 0.42848347637761874, 0.79377722262562056,
- 0.4051769024096169, -0.061123390002672869, -0.0657719112818555, 0.023452696141836267, 0.0077825964273254182, -0.0037935128644910141
- };
-
- hp1 = {
- 0.0037935128644910141, 0.0077825964273254182, -0.023452696141836267, -0.0657719112818555, 0.061123390002672869, 0.4051769024096169,
- -0.79377722262562056, 0.42848347637761874, 0.071799821619312018, -0.082301927106885983, -0.034555027573061628, 0.015880544863615904,
- 0.0090079761366615805, -0.0025745176887502236, -0.0011175187708906016, 0.00046621696011288631, 7.0983303138141252e-05, -3.4599772836212559e-05
- };
-
- lp2 = {
- -0.0037935128644910141, 0.0077825964273254182, 0.023452696141836267, -0.0657719112818555, -0.061123390002672869, 0.4051769024096169,
- 0.79377722262562056, 0.42848347637761874, -0.071799821619312018, -0.082301927106885983, 0.034555027573061628, 0.015880544863615904,
- -0.0090079761366615805, -0.0025745176887502236, 0.0011175187708906016, 0.00046621696011288631, -7.0983303138141252e-05, -3.4599772836212559e-05
- };
-
- hp2 = {
- -3.4599772836212559e-05, 7.0983303138141252e-05, 0.00046621696011288631, -0.0011175187708906016, -0.0025745176887502236, 0.0090079761366615805,
- 0.015880544863615904, -0.034555027573061628, -0.082301927106885983, 0.071799821619312018, 0.42848347637761874, -0.79377722262562056,
- 0.4051769024096169, 0.061123390002672869, -0.0657719112818555, -0.023452696141836267, 0.0077825964273254182, 0.0037935128644910141
- };
- return 0;
- }
- if (name == "coif4")
- {
- lp1 = {
- -1.7849850030882614e-06, -3.2596802368833675e-06, 3.1229875865345646e-05, 6.2339034461007128e-05, -0.00025997455248771324, -0.00058902075624433831,
- 0.0012665619292989445, 0.0037514361572784571, -0.0056582866866107199, -0.015211731527946259, 0.025082261844864097, 0.039334427123337491,
- -0.096220442033987982, -0.066627474263425038, 0.4343860564914685, 0.78223893092049901, 0.41530840703043026, -0.056077313316754807,
- -0.081266699680878754, 0.026682300156053072, 0.016068943964776348, -0.0073461663276420935, -0.0016294920126017326, 0.00089231366858231456
- };
-
- hp1 = {
- -0.00089231366858231456, -0.0016294920126017326, 0.0073461663276420935, 0.016068943964776348, -0.026682300156053072, -0.081266699680878754,
- 0.056077313316754807, 0.41530840703043026, -0.78223893092049901, 0.4343860564914685, 0.066627474263425038, -0.096220442033987982,
- -0.039334427123337491, 0.025082261844864097, 0.015211731527946259, -0.0056582866866107199, -0.0037514361572784571, 0.0012665619292989445,
- 0.00058902075624433831, -0.00025997455248771324, -6.2339034461007128e-05, 3.1229875865345646e-05, 3.2596802368833675e-06, -1.7849850030882614e-06
- };
-
- lp2 = {
- 0.00089231366858231456, -0.0016294920126017326, -0.0073461663276420935, 0.016068943964776348, 0.026682300156053072, -0.081266699680878754,
- -0.056077313316754807, 0.41530840703043026, 0.78223893092049901, 0.4343860564914685, -0.066627474263425038, -0.096220442033987982,
- 0.039334427123337491, 0.025082261844864097, -0.015211731527946259, -0.0056582866866107199, 0.0037514361572784571, 0.0012665619292989445,
- -0.00058902075624433831, -0.00025997455248771324, 6.2339034461007128e-05, 3.1229875865345646e-05, -3.2596802368833675e-06, -1.7849850030882614e-06
- };
-
- hp2 = {
- -1.7849850030882614e-06, 3.2596802368833675e-06, 3.1229875865345646e-05, -6.2339034461007128e-05, -0.00025997455248771324, 0.00058902075624433831,
- 0.0012665619292989445, -0.0037514361572784571, -0.0056582866866107199, 0.015211731527946259, 0.025082261844864097, -0.039334427123337491,
- -0.096220442033987982, 0.066627474263425038, 0.4343860564914685, -0.78223893092049901, 0.41530840703043026, 0.056077313316754807,
- -0.081266699680878754, -0.026682300156053072, 0.016068943964776348, 0.0073461663276420935, -0.0016294920126017326, -0.00089231366858231456
- };
- return 0;
- }
- if (name == "coif5")
- {
- lp1 = {
- -9.517657273819165e-08, -1.6744288576823017e-07, 2.0637618513646814e-06, 3.7346551751414047e-06, -2.1315026809955787e-05, -4.1340432272512511e-05,
- 0.00014054114970203437, 0.00030225958181306315, -0.00063813134304511142, -0.0016628637020130838, 0.0024333732126576722, 0.0067641854480530832,
- -0.0091642311624818458, -0.019761778942572639, 0.032683574267111833, 0.041289208750181702, -0.10557420870333893, -0.062035963962903569,
- 0.43799162617183712, 0.77428960365295618, 0.42156620669085149, -0.052043163176243773, -0.091920010559696244, 0.02816802897093635,
- 0.023408156785839195, -0.010131117519849788, -0.004159358781386048, 0.0021782363581090178, 0.00035858968789573785, -0.00021208083980379827
- };
-
- hp1 = {
- 0.00021208083980379827, 0.00035858968789573785, -0.0021782363581090178, -0.004159358781386048, 0.010131117519849788, 0.023408156785839195,
- -0.02816802897093635, -0.091920010559696244, 0.052043163176243773, 0.42156620669085149, -0.77428960365295618, 0.43799162617183712,
- 0.062035963962903569, -0.10557420870333893, -0.041289208750181702, 0.032683574267111833, 0.019761778942572639, -0.0091642311624818458,
- -0.0067641854480530832, 0.0024333732126576722, 0.0016628637020130838, -0.00063813134304511142, -0.00030225958181306315, 0.00014054114970203437,
- 4.1340432272512511e-05, -2.1315026809955787e-05, -3.7346551751414047e-06, 2.0637618513646814e-06, 1.6744288576823017e-07, -9.517657273819165e-08
- };
-
- lp2 = {
- -0.00021208083980379827, 0.00035858968789573785, 0.0021782363581090178, -0.004159358781386048, -0.010131117519849788, 0.023408156785839195,
- 0.02816802897093635, -0.091920010559696244, -0.052043163176243773, 0.42156620669085149, 0.77428960365295618, 0.43799162617183712,
- -0.062035963962903569, -0.10557420870333893, 0.041289208750181702, 0.032683574267111833, -0.019761778942572639, -0.0091642311624818458,
- 0.0067641854480530832, 0.0024333732126576722, -0.0016628637020130838, -0.00063813134304511142, 0.00030225958181306315, 0.00014054114970203437,
- -4.1340432272512511e-05, -2.1315026809955787e-05, 3.7346551751414047e-06, 2.0637618513646814e-06, -1.6744288576823017e-07, -9.517657273819165e-08
- };
-
- hp2 = {
- -9.517657273819165e-08, 1.6744288576823017e-07, 2.0637618513646814e-06, -3.7346551751414047e-06, -2.1315026809955787e-05, 4.1340432272512511e-05,
- 0.00014054114970203437, -0.00030225958181306315, -0.00063813134304511142, 0.0016628637020130838, 0.0024333732126576722, -0.0067641854480530832,
- -0.0091642311624818458, 0.019761778942572639, 0.032683574267111833, -0.041289208750181702, -0.10557420870333893, 0.062035963962903569,
- 0.43799162617183712, -0.77428960365295618, 0.42156620669085149, 0.052043163176243773, -0.091920010559696244, -0.02816802897093635,
- 0.023408156785839195, 0.010131117519849788, -0.004159358781386048, -0.0021782363581090178, 0.00035858968789573785, 0.00021208083980379827
- };
- return 0;
- }
- if (name == "sym2")
- {
- lp1 = { -0.12940952255092145, 0.22414386804185735, 0.83651630373746899, 0.48296291314469025 };
-
- hp1 = { -0.48296291314469025, 0.83651630373746899, -0.22414386804185735, -0.12940952255092145 };
-
- lp2 = { 0.48296291314469025, 0.83651630373746899, 0.22414386804185735, -0.12940952255092145 };
-
- hp2 = { -0.12940952255092145, -0.22414386804185735, 0.83651630373746899, -0.48296291314469025 };
- return 0;
- }
- if (name == "sym3")
- {
- lp1 = { 0.035226291882100656, -0.085441273882241486, -0.13501102001039084, 0.45987750211933132, 0.80689150931333875, 0.33267055295095688 };
-
- hp1 = { -0.33267055295095688, 0.80689150931333875, -0.45987750211933132, -0.13501102001039084, 0.085441273882241486, 0.035226291882100656 };
-
- lp2 = { 0.33267055295095688, 0.80689150931333875, 0.45987750211933132, -0.13501102001039084, -0.085441273882241486, 0.035226291882100656 };
-
- hp2 = { 0.035226291882100656, 0.085441273882241486, -0.13501102001039084, -0.45987750211933132, 0.80689150931333875, -0.33267055295095688 };
- return 0;
- }
- if (name == "sym4")
- {
- lp1 = {
- -0.075765714789273325, -0.02963552764599851, 0.49761866763201545, 0.80373875180591614, 0.29785779560527736, -0.099219543576847216,
- -0.012603967262037833, 0.032223100604042702
- };
-
- hp1 = {
- -0.032223100604042702, -0.012603967262037833, 0.099219543576847216, 0.29785779560527736, -0.80373875180591614, 0.49761866763201545,
- 0.02963552764599851, -0.075765714789273325
- };
-
- lp2 = {
- 0.032223100604042702, -0.012603967262037833, -0.099219543576847216, 0.29785779560527736, 0.80373875180591614, 0.49761866763201545,
- -0.02963552764599851, -0.075765714789273325
- };
-
- hp2 = {
- -0.075765714789273325, 0.02963552764599851, 0.49761866763201545, -0.80373875180591614, 0.29785779560527736, 0.099219543576847216,
- -0.012603967262037833, -0.032223100604042702
- };
- return 0;
- }
- if (name == "sym5")
- {
- lp1 = {
- 0.027333068345077982, 0.029519490925774643, -0.039134249302383094, 0.1993975339773936, 0.72340769040242059, 0.63397896345821192,
- 0.016602105764522319, -0.17532808990845047, -0.021101834024758855, 0.019538882735286728
- };
-
- hp1 = {
- -0.019538882735286728, -0.021101834024758855, 0.17532808990845047, 0.016602105764522319, -0.63397896345821192, 0.72340769040242059,
- -0.1993975339773936, -0.039134249302383094, -0.029519490925774643, 0.027333068345077982
- };
-
- lp2 = {
- 0.019538882735286728, -0.021101834024758855, -0.17532808990845047, 0.016602105764522319, 0.63397896345821192, 0.72340769040242059,
- 0.1993975339773936, -0.039134249302383094, 0.029519490925774643, 0.027333068345077982
- };
-
- hp2 = {
- 0.027333068345077982, -0.029519490925774643, -0.039134249302383094, -0.1993975339773936, 0.72340769040242059, -0.63397896345821192,
- 0.016602105764522319, 0.17532808990845047, -0.021101834024758855, -0.019538882735286728
- };
- return 0;
- }
- if (name == "sym6")
- {
- lp1 = {
- 0.015404109327027373, 0.0034907120842174702, -0.11799011114819057, -0.048311742585632998, 0.49105594192674662, 0.787641141030194,
- 0.3379294217276218, -0.072637522786462516, -0.021060292512300564, 0.044724901770665779, 0.0017677118642428036, -0.007800708325034148
- };
-
- hp1 = {
- 0.007800708325034148, 0.0017677118642428036, -0.044724901770665779, -0.021060292512300564, 0.072637522786462516, 0.3379294217276218,
- -0.787641141030194, 0.49105594192674662, 0.048311742585632998, -0.11799011114819057, -0.0034907120842174702, 0.015404109327027373
- };
-
- lp2 = {
- -0.007800708325034148, 0.0017677118642428036, 0.044724901770665779, -0.021060292512300564, -0.072637522786462516, 0.3379294217276218,
- 0.787641141030194, 0.49105594192674662, -0.048311742585632998, -0.11799011114819057, 0.0034907120842174702, 0.015404109327027373
- };
-
- hp2 = {
- 0.015404109327027373, -0.0034907120842174702, -0.11799011114819057, 0.048311742585632998, 0.49105594192674662, -0.787641141030194,
- 0.3379294217276218, 0.072637522786462516, -0.021060292512300564, -0.044724901770665779, 0.0017677118642428036, 0.007800708325034148
- };
- return 0;
- }
- if (name == "sym7")
- {
- lp1 = {
- 0.0026818145682578781, -0.0010473848886829163, -0.01263630340325193, 0.03051551316596357, 0.067892693501372697, -0.049552834937127255,
- 0.017441255086855827, 0.5361019170917628, 0.76776431700316405, 0.28862963175151463, -0.14004724044296152, -0.10780823770381774,
- 0.0040102448715336634, 0.010268176708511255
- };
-
- hp1 = {
- -0.010268176708511255, 0.0040102448715336634, 0.10780823770381774, -0.14004724044296152, -0.28862963175151463, 0.76776431700316405,
- -0.5361019170917628, 0.017441255086855827, 0.049552834937127255, 0.067892693501372697, -0.03051551316596357, -0.01263630340325193,
- 0.0010473848886829163, 0.0026818145682578781
- };
-
- lp2 = {
- 0.010268176708511255, 0.0040102448715336634, -0.10780823770381774, -0.14004724044296152, 0.28862963175151463, 0.76776431700316405,
- 0.5361019170917628, 0.017441255086855827, -0.049552834937127255, 0.067892693501372697, 0.03051551316596357, -0.01263630340325193,
- -0.0010473848886829163, 0.0026818145682578781
- };
-
- hp2 = {
- 0.0026818145682578781, 0.0010473848886829163, -0.01263630340325193, -0.03051551316596357, 0.067892693501372697, 0.049552834937127255,
- 0.017441255086855827, -0.5361019170917628, 0.76776431700316405, -0.28862963175151463, -0.14004724044296152, 0.10780823770381774,
- 0.0040102448715336634, -0.010268176708511255
- };
- return 0;
- }
- if (name == "sym8")
- {
- lp1 = {
- -0.0033824159510061256, -0.00054213233179114812, 0.031695087811492981, 0.0076074873249176054, -0.14329423835080971, -0.061273359067658524,
- 0.48135965125837221, 0.77718575170052351, 0.3644418948353314, -0.051945838107709037, -0.027219029917056003, 0.049137179673607506,
- 0.0038087520138906151, -0.014952258337048231, -0.0003029205147213668, 0.0018899503327594609
- };
-
- hp1 = {
- -0.0018899503327594609, -0.0003029205147213668, 0.014952258337048231, 0.0038087520138906151, -0.049137179673607506, -0.027219029917056003,
- 0.051945838107709037, 0.3644418948353314, -0.77718575170052351, 0.48135965125837221, 0.061273359067658524, -0.14329423835080971,
- -0.0076074873249176054, 0.031695087811492981, 0.00054213233179114812, -0.0033824159510061256
- };
-
- lp2 = {
- 0.0018899503327594609, -0.0003029205147213668, -0.014952258337048231, 0.0038087520138906151, 0.049137179673607506, -0.027219029917056003,
- -0.051945838107709037, 0.3644418948353314, 0.77718575170052351, 0.48135965125837221, -0.061273359067658524, -0.14329423835080971,
- 0.0076074873249176054, 0.031695087811492981, -0.00054213233179114812, -0.0033824159510061256
- };
-
- hp2 = {
- -0.0033824159510061256, 0.00054213233179114812, 0.031695087811492981, -0.0076074873249176054, -0.14329423835080971, 0.061273359067658524,
- 0.48135965125837221, -0.77718575170052351, 0.3644418948353314, 0.051945838107709037, -0.027219029917056003, -0.049137179673607506,
- 0.0038087520138906151, 0.014952258337048231, -0.0003029205147213668, -0.0018899503327594609
- };
- return 0;
- }
- if (name == "sym9")
- {
- lp1 = {
- 0.0014009155259146807, 0.00061978088898558676, -0.013271967781817119, -0.01152821020767923, 0.03022487885827568, 0.00058346274612580684,
- -0.054568958430834071, 0.238760914607303, 0.717897082764412, 0.61733844914093583, 0.035272488035271894, -0.19155083129728512, -0.018233770779395985,
- 0.06207778930288603, 0.0088592674934004842, -0.010264064027633142, -0.00047315449868008311, 0.0010694900329086053
- };
-
- hp1 = {
- -0.0010694900329086053, -0.00047315449868008311, 0.010264064027633142, 0.0088592674934004842, -0.06207778930288603, -0.018233770779395985,
- 0.19155083129728512, 0.035272488035271894, -0.61733844914093583, 0.717897082764412, -0.238760914607303, -0.054568958430834071,
- -0.00058346274612580684, 0.03022487885827568, 0.01152821020767923, -0.013271967781817119, -0.00061978088898558676, 0.0014009155259146807
- };
-
- lp2 = {
- 0.0010694900329086053, -0.00047315449868008311, -0.010264064027633142, 0.0088592674934004842, 0.06207778930288603, -0.018233770779395985,
- -0.19155083129728512, 0.035272488035271894, 0.61733844914093583, 0.717897082764412, 0.238760914607303, -0.054568958430834071,
- 0.00058346274612580684, 0.03022487885827568, -0.01152821020767923, -0.013271967781817119, 0.00061978088898558676, 0.0014009155259146807
- };
-
- hp2 = {
- 0.0014009155259146807, -0.00061978088898558676, -0.013271967781817119, 0.01152821020767923, 0.03022487885827568, -0.00058346274612580684,
- -0.054568958430834071, -0.238760914607303, 0.717897082764412, -0.61733844914093583, 0.035272488035271894, 0.19155083129728512,
- -0.018233770779395985, -0.06207778930288603, 0.0088592674934004842, 0.010264064027633142, -0.00047315449868008311, -0.0010694900329086053
- };
- return 0;
- }
- if (name == "sym10")
- {
- lp1 = {
- 0.00077015980911449011, 9.5632670722894754e-05, -0.0086412992770224222, -0.0014653825813050513, 0.045927239231092203, 0.011609893903711381,
- -0.15949427888491757, -0.070880535783243853, 0.47169066693843925, 0.7695100370211071, 0.38382676106708546, -0.035536740473817552,
- -0.0319900568824278, 0.049994972077376687, 0.0057649120335819086, -0.02035493981231129, -0.00080435893201654491, 0.0045931735853118284,
- 5.7036083618494284e-05, -0.00045932942100465878
- };
-
- hp1 = {
- 0.00045932942100465878, 5.7036083618494284e-05, -0.0045931735853118284, -0.00080435893201654491, 0.02035493981231129, 0.0057649120335819086,
- -0.049994972077376687, -0.0319900568824278, 0.035536740473817552, 0.38382676106708546, -0.7695100370211071, 0.47169066693843925,
- 0.070880535783243853, -0.15949427888491757, -0.011609893903711381, 0.045927239231092203, 0.0014653825813050513, -0.0086412992770224222,
- -9.5632670722894754e-05, 0.00077015980911449011
- };
-
- lp2 = {
- -0.00045932942100465878, 5.7036083618494284e-05, 0.0045931735853118284, -0.00080435893201654491, -0.02035493981231129, 0.0057649120335819086,
- 0.049994972077376687, -0.0319900568824278, -0.035536740473817552, 0.38382676106708546, 0.7695100370211071, 0.47169066693843925,
- -0.070880535783243853, -0.15949427888491757, 0.011609893903711381, 0.045927239231092203, -0.0014653825813050513, -0.0086412992770224222,
- 9.5632670722894754e-05, 0.00077015980911449011
- };
-
- hp2 = {
- 0.00077015980911449011, -9.5632670722894754e-05, -0.0086412992770224222, 0.0014653825813050513, 0.045927239231092203, -0.011609893903711381,
- -0.15949427888491757, 0.070880535783243853, 0.47169066693843925, -0.7695100370211071, 0.38382676106708546, 0.035536740473817552,
- -0.0319900568824278, -0.049994972077376687, 0.0057649120335819086, 0.02035493981231129, -0.00080435893201654491, -0.0045931735853118284,
- 5.7036083618494284e-05, 0.00045932942100465878
- };
- return 0;
- }
- std::cout << "Filter Not in Database" << std::endl;
- return -1;
- }
-
- #endif
|