REAL test_cox(INT tx,INT ty,INT tz) { ElTimer aT; cInterfaceCoxAlgo * pSCA = cInterfaceCoxAlgo::StdNewOne ( Pt2di(tx,ty), 0, tz, 2 ); for (INT x=0; x<tx ; x++) for (INT y=0; y<ty ; y++) for (INT z=0; z<tz ; z++) pSCA->SetCost(Pt3di(x,y,z),INT(100*NRrandom3())); pSCA->PccMaxFlow(); REAL aRes = aT.uval(); cout << "tCox : " << aRes << " ; " << tx << " " << ty << " " << tz << " " << (aRes *1e4 / (tx*ty*tz)) << "\n"; delete pSCA; return aRes; }
void Scale_Im_Compr<TObj,TLut,TInd>::DoItZoom() { ElTimer aTimer; Zoom_Im_Compr<TObj,TLut,TInd> ZIC(this->_u2wX,this->_l0,_lut); for (INT wy0=this->_pW0.y; wy0<this->_pW1.y; ) { INT yU0 = round_ni(this->y_to_user(wy0)); INT wy1 = wy0+1; while ( (wy1<this->_pW1.y) && (yU0==round_ni(this->y_to_user(wy1)))) wy1++; yU0 = std::max(0,std::min(yU0,this->_SzU.y-1)); DeCompr ( _dim->lpckb(yU0), ZIC,this->_xU0,this->_xU1,_dim->per() ); mTimeUnCompr += aTimer.uval(); RasterUseLine ( Pt2di(this->_pW0.x,wy0), Pt2di(this->_pW1.x,wy1), this->_line ); aTimer.reinit(); wy0 = wy1; } }
void TestOriBundleBasic() { ElTimer aChrono; for (int aT=0 ; aT<10000 ; aT++) { std::list<ElMatrix<double> > aLR = OriFromBundle(P3dRand(),P3dRand(),P3dRand(),P3dRand(),P3dRand(),P3dRand(),P3dRand(),30,5,5); } std::cout << aChrono.uval() << "\n"; }
void bench_fp() { // const char * ch = "../TMP/f3Reduc1.tif"; const char * ch = "/home/data/mpd/Andalousie/andaReduc1.tif"; Tiff_Im tiff(ch); ELISE_fp fp(ch, ELISE_fp::READ); tiff.show(); INT NbTx = tiff.sz().x/ tiff.SzTile()[0]; INT NbTy = tiff.sz().y/ tiff.SzTile()[1]; REAL ttot =0; INT k=0; INT f = 1; char * c = new char [tiff.SzTile()[0] * tiff.SzTile()[1]*f*3]; for (INT x=0; x< NbTx -1; x++) for (INT y=0; y< NbTy ; y++) { fp.seek_begin(tiff.offset_tile(x,y,0)); ElTimer tim; cout << tiff.offset_tile(x,y,0) << " " << tiff.byte_count_tile(x,y,0) << "\n"; fp.read(c,1,tiff.byte_count_tile(x,y,0)/1); REAL t = tim.sval(); ttot += t; k++; cout << "Read Time moy " << ttot/k << " " << x << " " << y << "\n"; } REAL m1 = ttot/k ; ttot = 0; k=0; { for (INT x=0; x< NbTx ; x++) for (INT y=0; y< NbTy ; y++) { fp.seek_begin(0); ElTimer tim; fp.seek_begin(tiff.offset_tile(x,y,0)); REAL t = tim.sval(); ttot += t; k++; cout << "Time moy " << ttot/k << " " << x << " " << y << "\n"; } } REAL m2 = ttot/k ; cout << "Moy read = " << m1 << " Moy Seek = " << m2 << "\n"; }
void Optim_L1FormLin::One_bench_craig() { /* ElMatrix<REAL> Smpd = MpdSolve(); ElMatrix<REAL> SBar = BarrodaleSolve(); for (INT v=0; v<_NbVar ; v++) { cout << SBar(0,v) << " " << Smpd(0,v) << " " << (SBar(0,v)-Smpd(0,v)) *1e10 <<"\n"; } */ ElTimer t; BarrodaleSolve(); cout << "Time = " << t.sval() << " " << _NbVar << " " << _NbForm << "\n"; }
void SleepProcess(REAL aDelay) { if (aDelay<=0) return ; int aIDelay = round_ni(aDelay); #if (!ELISE_windows) sleep(aIDelay); #else Sleep(aIDelay); #endif REAL aRDelay = aDelay-aIDelay; if (aRDelay >0) { ElTimer aChrono; while (aChrono.uval() < aRDelay) { } } }
REAL TestMulMat(INT aNbTime, INT aNbVar) { ElTimer aChrono; Im2D_REAL8 aMat(aNbVar,aNbVar,0.0); Im1D_REAL8 aVec(aNbVar,0.0); REAL8 ** aDM = aMat.data(); REAL8 * aDV = aVec.data(); for (INT aKT=0 ; aKT<aNbTime ; aKT++) for (INT aKV=0 ; aKV<aNbVar ; aKV++) { for (INT aX=0 ; aX<aNbVar ; aX++) for (INT aY=0 ; aY<aNbVar ; aY++) aDM[aY][aX] += aDV[aY] * aDV[aX]; } return aChrono.uval(); }
void GMCube::Opt() { REAL aCapaTot = 0; ElTimer aTimer; INT aCPT = 0; { // if ((aCPT %10==0) || (aCPT>=155)) pSCA->NbChem(); INT aCapa = pSCA->PccMaxFlow(); aCapaTot += aCapa; aCPT++; if ((aCPT%1 == 0) || (aCapa == 0)) cout << "CPT " << aCPT << " Time : " << aTimer.uval() << " DCapa : " << aCapa << " Som Capa = " << aCapaTot << "\n"; { cout << "AAAAAAAAAAA\n"; Im2D_INT2 aZ = pSCA->Sol(0); Tiff_Im aTif ( "/home/pierrot/Data/Cox.tif", mSz, GenIm::u_int1, Tiff_Im::No_Compr, Tiff_Im::BlackIsZero ); ELISE_COPY(aZ.all_pts(),aZ.in(),aTif.out()); ShowIm2(aZ,mW4); cout << "BBBBBBBB\n"; return; } } }
void cAppliOneReechMarqFid::DoReech() { if (! mBySingle) return; ElTimer aChrono; mAffChambreMm2PixIm = ElAffin2D::L2Fit(mPack,&mResidu); mAffPixIm2ChambreMm = mAffChambreMm2PixIm.inv(); ReechFichier ( true, mNameIm, Box2dr(Pt2dr(0,0),Pt2dr(mSzIm)), this, mBoxChambrePix, 10.0, "OIS-Reech_"+mNameIm, mPostMasq, mNumKer ); std::cout << "FOR " << mNameIm << " RESIDU " << mResidu << " Time " << aChrono.uval() << " \n"; }
void cAppli_Martini::StdCom(const std::string & aCom,const std::string & aPost) { std::string aFullCom = MM3dBinFile_quotes( "TestLib ") + aCom + " " + QUOTE(mPat); if (EAMIsInit(&mNameOriCalib)) aFullCom = aFullCom + " OriCalib=" + mNameOriCalib; aFullCom += " Quick=" + ToString(mQuick); aFullCom = aFullCom + aPost; if (mExe) System(aFullCom); else std::cout << "COM= " << aFullCom << "\n"; std::cout << " DONE " << aCom << " in time " << aChrono.uval() << "\n"; }
int CPP_AllOptimTriplet_main(int argc,char ** argv) { ElTimer aChrono; std::string aFullPat,aNameCalib; bool inParal=true; bool Quick = false; std::string aPrefHom=""; bool Debug = false; ElInitArgMain ( argc,argv, LArgMain() << EAMC(aFullPat,"Pattern"), LArgMain() << EAM(aNameCalib,"OriCalib",true,"Orientation for calibration ", eSAM_IsExistDirOri) << EAM(inParal,"Paral",true,"Execute in parallel ", eSAM_IsBool) << EAM(Quick,"Quick",true,"Quick version", eSAM_IsBool) << EAM(aPrefHom,"PrefHom",true,"Prefix Homologous points, def=\"\"") << EAM(Debug,"Debug",true,"Debugging mode (tuning purpose)", eSAM_IsBool) ); cElemAppliSetFile anEASF(aFullPat); const cInterfChantierNameManipulateur::tSet * aVIm = anEASF.SetIm(); cSetName * aSetN= anEASF.mICNM->KeyOrPatSelector(aFullPat); std::set<std::string> aSetName(aVIm->begin(),aVIm->end()); std::string aDir = anEASF.mDir; cNewO_NameManager * aNM = new cNewO_NameManager(aPrefHom,Quick,aDir,aNameCalib,"dat"); cSauvegardeNamedRel aLCpl = StdGetFromPCP(aNM->NameCpleOfTopoTriplet(true),SauvegardeNamedRel); std::list<std::string> aLCom; int aNb= 0 ; int aNb2 = (int)aLCpl.Cple().size(); for (std::vector<cCpleString>::const_iterator itC=aLCpl.Cple().begin() ; itC!=aLCpl.Cple().end() ; itC++) { aNb++; const std::string & aN1 = itC->N1(); const std::string & aN2 = itC->N2(); if (aSetN->SetBasicIsIn(aN1) && aSetN->SetBasicIsIn(aN2)) { std::string aCom = MM3dBinFile("TestLib NO_OneImOptTrip") + " " + aN1 + " " + aN2 + " " + cAppliOptimTriplet::KeyCple; if (EAMIsInit(&aNameCalib)) aCom += " OriCalib=" + aNameCalib; aCom += " Quick=" + ToString(Quick); aCom += " PrefHom=" + aPrefHom; if (inParal) { aLCom.push_back(aCom); if ((aNb%40) == 0) { cEl_GPAO::DoComInParal(aLCom); aLCom.clear(); std::cout << "Optim triplets Done " << aNb << " pairs out of " << aNb2 << " in " << aChrono.uval() << "\n"; } } else { std::cout << "COM " << aCom << "\n"; System(aCom); } } } cEl_GPAO::DoComInParal(aLCom); return EXIT_SUCCESS; }
cApply_CreateEpip_main::cApply_CreateEpip_main(int argc,char ** argv) : mForceGen (false), mNumKer (5), mDebug (false), mPostMasq ("") { Tiff_Im::SetDefTileFile(50000); std::string aDir= ELISE_Current_DIR; std::string anOri; double aScale=1.0; bool Gray = true; bool Cons16B = true; bool InParal = true; bool DoIm = true; std::string aNameHom; bool mExpTxt=false; ElInitArgMain ( argc,argv, LArgMain() << EAMC(mName1,"Name first image", eSAM_IsExistFile) << EAMC(mName2,"Name second image", eSAM_IsExistFile) << EAMC(anOri,"Name orientation", eSAM_IsExistDirOri), LArgMain() << EAM(aScale,"Scale",true) << EAM(aDir,"Dir",true,"directory (Def=current)", eSAM_IsDir) << EAM(Gray,"Gray",true,"One channel gray level image (Def=true)", eSAM_IsBool) << EAM(Cons16B,"16B",true,"Maintain 16 Bits images if avalaible (Def=true)", eSAM_IsBool) << EAM(InParal,"InParal",true,"Compute in parallel (Def=true)", eSAM_IsBool) << EAM(DoIm,"DoIm",true,"Compute image (def=true !!)", eSAM_IsBool) << EAM(aNameHom,"NameH",true,"Extension to compute Hom point in epi coord (def=none)", eSAM_NoInit) << EAM(mDegre,"Degre",true,"Degre of polynom to correct epi (def=9)") << EAM(mForceGen,"FG",true,"Force generik epip even with stenope cam") << EAM(mNumKer,"Kern",true,"Kernel of interpol,0 Bilin, 1 Bicub, other SinC (fix size of apodisation window), Def=5") << EAM(mPostMasq,"AttrMasq",true,"Atribut for masq toto-> toto_AttrMasq.tif, NONE if unused, Def=Ori") << EAM(mPostIm,"PostIm",true,"Attribut for Im ") << EAM(mExpTxt,"ExpTxt",false,"Use txt tie points (Def false, e.g. use dat format)") ); if (!MMVisualMode) { if (mName1 > mName2) ElSwap(mName1,mName2); int aNbChan = Gray ? 1 : - 1; cTplValGesInit<std::string> aTplFCND; mICNM = cInterfChantierNameManipulateur::StdAlloc ( argc,argv, aDir, aTplFCND ); mICNM->CorrecNameOrient(anOri); if (mPostMasq!="NONE") { // if (!EAMIsInit(&mPostMasq)) mPostMasq = anOri; mPostMasq = "_Masq"; } if (!EAMIsInit(&mPostIm)) mPostIm = "_"+anOri; mGenI1 = mICNM->StdCamGenOfNames(anOri,mName1); mGenI2 = mICNM->StdCamGenOfNames(anOri,mName2); if ((mGenI1->DownCastCS()==0) || (mGenI2->DownCastCS()==0) || mForceGen) { if (! EAMIsInit(&mDegre)) mDegre = 9; DoEpipGen(); return; } std::string aKey = + "NKS-Assoc-Im2Orient@-" + anOri; std::string aNameOr1 = mICNM->Assoc1To1(aKey,mName1,true); std::string aNameOr2 = mICNM->Assoc1To1(aKey,mName2,true); // std::cout << "RREEEEEEEEEEEEEEead cam \n"; CamStenope * aCam1 = CamStenope::StdCamFromFile(true,aNameOr1,mICNM); // std::cout << "EPISZPPPpp " << aCam1->SzPixel() << "\n"; CamStenope * aCam2 = CamStenope::StdCamFromFile(true,aNameOr2,mICNM); Tiff_Im aTif1 = Tiff_Im::StdConvGen(aDir+mName1,aNbChan,Cons16B); Tiff_Im aTif2 = Tiff_Im::StdConvGen(aDir+mName2,aNbChan,Cons16B); // aCam1->SetSz(aTif1.sz(),true); // aCam2->SetSz(aTif2.sz(),true); // for (int aK=0; aK<13 ; aK++) std::cout << "SSSssssssssssssssssssiize !!!!\n"; getchar(); // Test commit cCpleEpip aCplE ( aDir, aScale, *aCam1,mName1, *aCam2,mName2 ); const char * aCarHom = 0; if (EAMIsInit(&aNameHom)) aCarHom = aNameHom.c_str(); std::cout << "TimeEpi-0 \n"; ElTimer aChrono; aCplE.ImEpip(aTif1,aNameOr1,true,InParal,DoIm,aCarHom,mDegre,mExpTxt); std::cout << "TimeEpi-1 " << aChrono.uval() << "\n"; aCplE.ImEpip(aTif2,aNameOr2,false,InParal,DoIm,aCarHom,mDegre,mExpTxt); std::cout << "TimeEpi-2 " << aChrono.uval() << "\n"; aCplE.SetNameLock("End"); aCplE.LockMess("End cCpleEpip::ImEpip"); return ; } else return ; }
void cAppliOptimTriplet::Execute() { ElTimer aChrono; if (! EAMIsInit(&mNbMaxSel)) { mNbMaxSel = mQuick ? QuickDefNbMaxSel : StdDefNbMaxSel; } if (mShow) mQuitExist = false; mNbMaxInit = mQuick ? QuickNbMaxInit : StdNbMaxInit ; if (! EAMIsInit(&mShow)) mShow = EAMIsInit(&mSzShow); if (MMVisualMode) return; cNewO_OneIm * mNoIm3 = new cNewO_OneIm(*mNM,m3S.mV2); std::string aNameSauveXml = mNM->NameOriOptimTriplet(false,mNoIm1,mNoIm2,mNoIm3,false); std::string aNameSauveBin = mNM->NameOriOptimTriplet(true ,mNoIm1,mNoIm2,mNoIm3,false); if (ELISE_fp::exist_file(aNameSauveXml) && ELISE_fp::exist_file(aNameSauveBin) && mQuitExist) return ; std::string aName3R = mNM->NameOriInitTriplet(true,mNoIm1,mNoIm2,mNoIm3); cXml_Ori3ImInit aXml3Ori = StdGetFromSI(aName3R,Xml_Ori3ImInit); mIms.push_back(new cImOfTriplet(0,*this,mNoIm1,ElRotation3D::Id)); mIms.push_back(new cImOfTriplet(1,*this,mNoIm2,Xml2El(aXml3Ori.Ori2On1()))); mIms.push_back(new cImOfTriplet(2,*this,mNoIm3,Xml2El(aXml3Ori.Ori3On1()))); mIm1 = mIms[0]; mIm2 = mIms[1]; mIm3 = mIms[2]; mFoc = 1/ ( (1.0/mIm1->Foc()+1.0/mIm2->Foc()+1.0/mIm3->Foc()) / 3.0 ) ; // mP12 = new cPairOfTriplet(mIm1,mIm2,mIm3); // mP13 = new cPairOfTriplet(mIm1,mIm3,mIm2); // mP23 = new cPairOfTriplet(mIm2,mIm3,mIm1); mPairs.push_back(new cPairOfTriplet(mIm1,mIm2,mIm3)); mPairs.push_back(new cPairOfTriplet(mIm1,mIm3,mIm2)); mPairs.push_back(new cPairOfTriplet(mIm2,mIm3,mIm1)); mP12 = mPairs[0]; mP13 = mPairs[1]; mP23 = mPairs[2]; mNM->LoadTriplet(mIm1->Im(),mIm2->Im(),mIm3->Im(),&mIm1->VFullPtOf3(),&mIm2->VFullPtOf3(),&mIm3->VFullPtOf3()); if (EAMIsInit(&mSzShow) && (!EAMIsInit(&mNbMaxSel))) { mNbMaxSel = ModeShowNbMaxSel; } if (mShow) std::cout << "Time load " << aChrono.uval() << "\n"; int aNb3 = round_up(CoutAttenueTetaMax(mIm2->VFullPtOf3().size() ,mNbMaxSel)); mNbMaxSel = aNb3; // mSel3 = IndPackReduit(mIm2->VFullPtOf3(),mNbMaxInit,mNbMaxSel); mSel3 = IndPackReduit(mIm2->VFullPtOf3(),mNbMaxInit,mNbMaxSel); for (int aK=0 ; aK<3 ; aK++) { mIms[aK]->SetReduce(mSel3); mFullH123.push_back(&(mIms[aK]->VFullPtOf3())); mRedH123.push_back(&(mIms[aK]->VRedPtOf3())); } mP12->SetPackRed(false,mNbMaxInit,mNbMaxSel,mSel3,*mFullH123[1]); mP23->SetPackRed(true ,mNbMaxInit,mNbMaxSel,mSel3,*mFullH123[1]); mP13->SetPackRed(true ,mNbMaxInit,mNbMaxSel,mSel3,*mFullH123[0]); mPds3 = ElMin(MaxSurPond3,(mP12->NbR()+mP13->NbR()+mP23->NbR())/double(mIm1->NbR())); mBestResidu = ResiduGlob(); /* TestOPA(*mP12); */ if (mShow) { std::cout << "Time reduc " << aChrono.uval() << " Pds3=" << mPds3 << "\n"; } for (int aKP=0 ; aKP<int(mPairs.size()) ; aKP++) { TestOPA(*(mPairs[aKP])); } if (mShow) { std::cout << "Time opa " << aChrono.uval() << "\n"; } if (mShow) { std::cout << "NB TRIPLE " << mIm2->VFullPtOf3().size() << " Resi3: " << ResiduTriplet() << " F " << mFoc << "\n"; std::cout << "RESIDU/PAIRES " << mP12->ResiduMoy() << " " << mP13->ResiduMoy() << " " << mP23->ResiduMoy() << " " << "\n"; std::cout << "R Glob " << ResiduGlob() << "\n"; } #if (ELISE_X11) if (EAMIsInit(&mSzShow)) { mIm2->InitW(mSzShow); ShowPoints(mIm2,mP12->FullVP2(),P8COL::cyan,2); ShowPoints(mIm2,mP23->FullVP1(),P8COL::yellow,2); ShowPointSel(mIm2,mP12->VRedP2(),P8COL::cyan); ShowPointSel(mIm2,mP23->VRedP1(),P8COL::yellow); std::cout << "NB 12 " << mP12->VRedP2().size() << "\n"; // ShowPoints(mIm2,mIm2->VFullPtOf3(),P8COL::blue,4); // ShowPointSel(mSel3.mVSel,mIm2,mIm2->VFullPtOf3(),P8COL::red); // ShowPoints(mIm2,mIm2->VFullPtOf3(),P8COL::blue,2); ShowPointSel(mIm2,mIm2->VRedPtOf3(),P8COL::blue); //================================== mIm1->InitW(mSzShow); ShowPoints(mIm1,mP13->FullVP1(),P8COL::cyan,2); ShowPointSel(mIm1,mP13->VRedP1(),P8COL::cyan); ShowPoints(mIm1,mIm1->VFullPtOf3(),P8COL::blue,2); ShowPointSel(mIm1,mIm1->VRedPtOf3(),P8COL::blue); mIm2->W()->clik_in(); } #endif /* SolveBundle3Image ( mFoc, mIm2->Rot(), mIm3->Rot(), mFullH123, mP12->FullHoms(), mP13->FullHoms(), mP23->FullHoms() ); */ int aNbIterBundle = mQuick ? QuickNbIterBundle : StdNbIterBundle; double aBOnH; Pt3dr aPMed; SolveBundle3Image ( mFoc, mIm2->Ori(), mIm3->Ori(), aPMed, aBOnH, mRedH123, mP12->RedHoms(), mP13->RedHoms(), mP23->RedHoms(), mPds3, aNbIterBundle ); cXml_Ori3ImInit aXml; aXml.Ori2On1() = El2Xml(mIm2->Ori()); aXml.Ori3On1() = El2Xml(mIm3->Ori()); aXml.ResiduTriplet() = ResiduGlob(); aXml.NbTriplet() = (int)mRedH123[0]->size(); aXml.BSurH() = aBOnH; aXml.PMed() = aPMed; MakeFileXML(aXml,aNameSauveXml); MakeFileXML(aXml,aNameSauveBin); if (mShow) { std::cout << "NB TRIPLE " << mIm2->VFullPtOf3().size() << " Resi3: " << ResiduTriplet() << " F " << mFoc << "\n"; std::cout << "RESIDU/PAIRES " << mP12->ResiduMoy() << " " << mP13->ResiduMoy() << " " << mP23->ResiduMoy() << " " << "\n"; std::cout << "R Glob " << ResiduGlob() << "\n"; std::cout << "Time bundle " << aChrono.uval() << "\n"; } for (int aK=0 ; aK<3 ; aK++) { delete mPairs[aK]; delete mIms[aK]; } mPairs.clear(); mIms.clear(); mFullH123.clear(); mRedH123.clear(); }
void cASAMG::TestImCoher() { ElTimer aChrono; const std::vector<cASAMG *> & aVN = mCloseNeigh; int aNbIm = aVN.size(); Im2D_REAL4 aImDif(mSz.x,mSz.y,1000); TIm2D<REAL4,REAL8> aTDif(aImDif); Pt2di aP; for (aP.x=0 ; aP.x<mSz.x ; aP.x++) { for (aP.y=0 ; aP.y<mSz.y ; aP.y++) { if (mTMasqN.get(aP)) { Pt3dr aPE = mStdN->PtOfIndex(aP); double aSom=0; for (int aK=0 ; aK<aNbIm ; aK++) { aSom += aVN[aK]->QualityProjOnMe(aPE); } aTDif.oset(aP,aSom); } } } for (int aNbRec = 3 ; aNbRec>=0 ; aNbRec --) { double aSeuil = aNbRec-0.25; Fonc_Num aFInside = aImDif.in(-1) > aSeuil; if (aNbRec>0) { eQualCloud aQual = eQC_Coh1; if (aNbRec==2) aQual = eQC_Coh2; if (aNbRec==3) aQual = eQC_Coh3; // Pour ceux qui ont ete valide (aNbRec> 0.75) et non bord ou autre chose ont leur met la bonne valeur ELISE_COPY ( select(mImQuality.all_pts(),aFInside && (mImQuality.in()==eQC_NonAff)), aQual, mImQuality.out() ); ELISE_COPY ( select ( mImQuality.all_pts(), aFInside && (mImQuality.in()==eQC_GradFaibleC1) && (erod_32(mMasqN.in_proj(),2*mPrm.DilateBord().Val())) ), eQC_GradFaibleC2, mImQuality.out() ); } else { aFInside = aImDif.in(-1) <= (aSeuil+1); Im2D_Bits<1> aImLQ(mSz.x,mSz.y); ELISE_COPY(aImLQ.all_pts(),aFInside,aImLQ.out()); ELISE_COPY ( select(mImQuality.all_pts(), aImLQ.in() && (mImQuality.in()==eQC_NonAff)), eQC_ZeroCohImMul, mImQuality.out() ); ELISE_COPY ( select ( mImQuality.all_pts(), aImLQ.in()&&( mImQuality.in()>=eQC_GradFort) && ( mImQuality.in()<=eQC_Bord) ), eQC_ZeroCohBrd, mImQuality.out() ); /* */ } } ELISE_COPY(mImQuality.border(1),eQC_Out,mImQuality.out()); InitGlobHisto(); for (int aK=0 ; aK<mHisto.tx() ; aK++) { if (mDH[aK]) { mMaxNivH = aK; } } Video_Win * aW = mAppli->Param().VisuImageCoh().Val() ? TheWinIm() : 0 ; if (aW) { aW->set_title(mIma->mNameIm.c_str()); std::cout << "For " << mIma->mNameIm << " time " << aChrono.uval() << " NbIm " << aNbIm << "\n"; Fonc_Num fGray = Min(255,aImDif.in() * (255.0/aNbIm)); for (int aK=0 ; aK<mHisto.tx() ; aK++) std::cout << "H[" << aK << "]= " << mHisto.data()[aK] << "\n"; InspectQual(true); } }
void Scale_Im_Compr<TObj,TLut,TInd>::DoItReduce() { ElTimer aTimer; for (INT wy=this->_pW0.y; wy<this->_pW1.y; wy++) { INT yU0 = round_down(this->y_to_user(wy-0.5)); INT yU1 = round_up(this->y_to_user(wy+0.5)); ElSetMax(yU0,0); ElSetMin(yU1,this->_SzU.y-1); for (INT ux= this->_pW0.x -(Scale_Im_Compr<TObj,TLut,TInd>::RAB) ; ux<this->_pW1.x +(Scale_Im_Compr<TObj,TLut,TInd>::RAB); ux++) this->_l0[ux] = 0; INT pdsTot = 0; if (yU0<yU1) { for (INT uy= yU0; uy<=yU1 ; uy++) { REAL yW0 = std::max(this->y_to_window(uy-0.5),wy-0.5); REAL yW1 = std::min(this->y_to_window(uy+0.5),wy+0.5); INT pds = round_ni((yW1-yW0) * this->_CoeffPds); if (pds > 0) { pdsTot += 0; _CurPds = pds; DeCompr ( _dim->lpckb(uy), *this, this->_xU0, this->_xU1, _dim->per() ); pdsTot += pds; } } if (pdsTot) { { for (INT ux= this->_pW0.x ; ux<this->_pW1.x +(Scale_Im_Compr<TObj,TLut,TInd>::RAB) ; ux++) this->_l0[ux] += this->_l0[ux-1]; } INT pxy = pdsTot * this->_CoeffPds; { for (INT ux= this->_pW0.x ; ux<this->_pW1.x ; ux++) this->_l0[ux] /= pxy; } mTimeUnCompr += aTimer.uval(); RasterUseLine ( Pt2di(this->_pW0.x,wy), Pt2di(this->_pW1.x,wy+1), this->_line ); aTimer.reinit(); } } } }
Im2D_INT2 TestCoxRoy ( INT aSzV, Im2D_U_INT1 imG1, Im2D_U_INT1 imG2, Pt2di aP0, Pt2di aP1, INT aParMin, INT aParMax ) { ElTimer aRoyTimer; TheP0 = aP0; Pt2di aSz = aP1 -aP0; Im2D_INT2 aRes (aSz.x,aSz.y); TheCorr = new EliseCorrel2D ( imG1.in(0), imG2.in(0), imG1.sz(), aSzV, false, -1, true, true ); Im2D_INT2 aIZMin(aSz.x,aSz.y,(INT2)(aParMin)); Im2D_INT2 aIZMax(aSz.x,aSz.y,(INT2)(aParMax)); cInterfaceCoxRoyAlgo * TheCRA = cInterfaceCoxRoyAlgo::NewOne ( aSz.x, aSz.y, aIZMin.data(), aIZMax.data(), false, false ); InitCostCoxRoy(*TheCRA); INT MpdFlow=0; if (false) { cInterfaceCoxAlgo * pSCA = cInterfaceCoxAlgo::StdNewOne ( aSz, 0, aParMax-aParMin, 2, false ); for (INT anX=aP0.x ; anX<aP1.x ; anX++) for (INT anY=aP0.y ; anY<aP1.y ; anY++) for (INT aZ=0 ; aZ<(aParMax-aParMin) ; aZ++) { Pt2di aP(anX,anY); REAL aC = TheCorr->Correl(aP,aP+Pt2di(aZ+aParMin,0)); pSCA->SetCost(Pt3di(anX-aP0.x,anY-aP0.y,aZ),MakeCapa(1-aC)); } MpdFlow = pSCA->PccMaxFlow(); Im2D_INT2 aSol = pSCA->Sol(0); Video_Win aW = Video_Win::WStd(aSol.sz(),1.0); aW.set_title("MPD"); INT aV0,aV1; ELISE_COPY(aSol.all_pts(),aSol.in(),VMin(aV0)|VMax(aV1)); ELISE_COPY(aSol.all_pts(),(aSol.in()-aV0)*(255.0/(aV1-aV0)),aW.ogray()); delete pSCA; } cout << "MPD Flow " << MpdFlow << "\n"; aRoyTimer.reinit(); INT aFl1 = TheCRA->TopMaxFlowStd(aRes.data()); cout << "Roy Time = " << aRoyTimer.uval() << "\n"; ELISE_COPY(aRes.all_pts(),aRes.in(),aRes.out()); { INT aV0,aV1; ELISE_COPY(aRes.all_pts(),aRes.in(),VMin(aV0)|VMax(aV1)); cout << "Cox Roy Interv = " << aV0 << " --- " << aV1 << "\n"; } delete TheCRA; INT ecartPlani = 2; INT ecartAlti = 5; ELISE_COPY ( aIZMin.all_pts(), rect_min(aRes.in(aParMax),ecartPlani) -ecartAlti, aIZMin.out() ); ELISE_COPY ( aIZMax.all_pts(), rect_max(aRes.in(aParMin),ecartPlani) +ecartAlti, aIZMax.out() ); Im2D_INT2 aRes2 (aSz.x,aSz.y); TheCRA = cInterfaceCoxRoyAlgo::NewOne ( aSz.x, aSz.y, aIZMin.data(), aIZMax.data(), false, false ); InitCostCoxRoy(*TheCRA); aRoyTimer.reinit(); INT aFl2 = TheCRA->TopMaxFlowStd(aRes2.data()); cout << "Roy Time 2 = " << aRoyTimer.uval() << "\n"; INT aNbDif; ELISE_COPY ( aRes.all_pts(), aRes.in()!=aRes2.in(), sigma(aNbDif) ); BENCH_ASSERT(aNbDif==0); cout << "FLOWS : " << aFl1 << " " << aFl2 << "\n"; cout << "Nb Dif = " << aNbDif << "\n"; delete TheCorr; return aRes; }
void cElHJaArrangt::ConstruireAll() { mStats.push_back ( cStatistique ( 0.0, 0.0, mSurfEmpr * mNbPl ) ); bool toShoTime = false; ElTimer aChrono; ELISE_ASSERT(mNbPl>=0,"No Init int cElHJaArrangt"); // Construction de la geometrie 3D for (tItPl itPl = mPlans.begin() ; itPl!=mPlans.end() ; itPl++) { (*itPl)->SetNbPlansInter(mNbPl); } for (tItPl itPl1 = mPlans.begin() ; itPl1!=mPlans.end() ; itPl1++) { for (tItPl itPl2 = NextIter(itPl1) ; itPl2!=mPlans.end() ; itPl2++) { bool Ok; ElSeg3D aD3d = (*itPl1)->Plan().Inter((*itPl2)->Plan(),Ok); if (Ok) { mDroites.push_back(new cElHJaDroite(aD3d,**itPl1,**itPl2,mNbPl)); for (tItPl itPl3=NextIter(itPl2) ; itPl3!=mPlans.end() ; itPl3++) { Pt3dr aP = (*itPl1)->Plan().Inter((*itPl2)->Plan(),(*itPl3)->Plan(),Ok); if (Ok && PointInPoly(mEmprVPt2d,Proj(aP))) mPoints.push_back(new cElHJaPoint(aP,**itPl1,**itPl2,**itPl3)); } } } } for (tItPoint itPt = mPoints.begin() ; itPt!=mPoints.end() ; itPt++) (*itPt)->MakeDroites(); if (toShoTime) cout << "Time Geom3D : " << aChrono.ValAndInit() << "\n"; // Construction des Intersection Droites/emprise for (tItDr itD = mDroites.begin(); itD!=mDroites.end(); itD++) (*itD)->MakeIntersectionEmprise(mEmprPl); if (toShoTime) cout << "Time Inter Emprise : " << aChrono.ValAndInit() << "\n"; // Construction des facettes dans chaque plan for (tItPl itPl = mPlans.begin() ; itPl!=mPlans.end() ; itPl++) (*itPl)->AddArcEmpriseInGraphe(); for (tItDr itD = mDroites.begin(); itD!=mDroites.end(); itD++) (*itD)->AddArcsInterieurInGraphe(mEmprVPt2d); for (tItPl itPl = mPlans.begin() ; itPl!=mPlans.end() ; itPl++) (*itPl)->MakeFacettes(*this); if (toShoTime) cout << "Time Facette : " << aChrono.ValAndInit() << "\n"; // Construction des relations entre facettes for (tItFac itF = mFacettes.begin() ; itF!=mFacettes.end() ; itF++) (*itF)->MakeAdjacences(); for (tItFac itF1 = mFacettes.begin() ; itF1!=mFacettes.end() ; itF1++) for (tItFac itF2 = NextIter(itF1) ; itF2!=mFacettes.end() ; itF2++) (*itF1)->MakeRecouvrt(*itF2); TriTopologiqueFacette(); if (toShoTime) cout << "Time Relation F : " << aChrono.ValAndInit() << "\n"; }
void cBenchCorrSub::MakeACorrel() { REAL aSzVgn = 10.0; REAL aStep = 0.5; OptCorrSubPix_Diff<U_INT1> aOCSPD ( mIm1.mIm,mIm2.mIm, aSzVgn,aStep, Pt3dr(-10,-10,-10) ); OptimTranslationCorrelation<U_INT1> aOpComb ( 0.001, 1.0, 1, mIm1.mIm,mIm2.mIm, aSzVgn,aStep ); TIm2D<REAL4,REAL8> aTDX(mDistX); TIm2D<REAL4,REAL8> aTDY(mDistY); INT NbStep = 30; std::vector<cStat> aStatRef(NbStep); std::vector<cStat> aStatComb(NbStep); cStat aStatCombRef; ElTimer aChrono; REAL aTimeComb =0; REAL aTimeDiff =0; for (INT aKP=0 ; aKP<100 ; aKP++) { Pt2dr aP1(Rand(aSzVgn,mSz.x),Rand(aSzVgn,mSz.y)); aOpComb.SetP0Im1(aP1); aOpComb.optim(Pt2dr(0,0)); Pt2dr aPComb = aP1+aOpComb.param(); Pt2dr aPComb1Rec(aTDX.getr(aPComb),aTDY.getr(aPComb)); aStatCombRef.Add(euclid(aP1,aPComb1Rec)); Pt2dr aP2Opt = aP1; if (aKP % 10 ==0) { aChrono.reinit(); for (INT aCp =0 ; aCp < 10 ; aCp++) aOpComb.optim(Pt2dr(0,0)); aTimeComb += aChrono.uval(); aChrono.reinit(); for (INT aCp =0 ; aCp < 10 ; aCp++) aOCSPD.Optim(aP1,aP1); aTimeDiff += aChrono.uval(); } for (INT aKOpt =0 ; aKOpt<NbStep ; aKOpt++) { Pt3dr aPOpt = aOCSPD.Optim(aP1,aP2Opt); aP2Opt = Pt2dr(aPOpt.x,aPOpt.y); Pt2dr aP1Rec(aTDX.getr(aP2Opt),aTDY.getr(aP2Opt)); REAL aDistRef = euclid (aP1,aP1Rec); REAL aDistComb = euclid (aP2Opt,aPComb); // cout << aDistRef << " " << aDistComb << " " << "\n"; aStatRef[aKOpt].Add(aDistRef); aStatComb[aKOpt].Add(aDistComb); } } /* for (INT aKOpt =0 ; aKOpt<NbStep ; aKOpt++) { cout << "Step " << aKOpt << " DIST MED " << aStatRef[aKOpt].Med() << " / Comb " << aStatComb[aKOpt].Med() << "\n"; } cout << "DMED Comb " << aStatCombRef.Med() << "\n"; cout << "Time " << " Diff " << aTimeDiff << " Comb " << aTimeComb << "\n"; */ BENCH_ASSERT(aStatComb[NbStep-1].Med() < 1e-1); }
template <class TypeIm,class TypeBase> Im2D_Bits<1> CreateGr(tGRGraf & mGr,Im2D<TypeIm,TypeBase> anIm,int aLabelOut,const cParamGrReg & aPGR) { bool V8=true; //int aNbV = V8 ? 8 : 4; //Pt2di * TabV = V8 ? TAB_8_NEIGH : TAB_4_NEIGH; TIm2D<TypeIm,TypeBase> aTIm(anIm); Pt2di aSz = anIm.sz(); Im2D_INT4 aImLabel(aSz.x,aSz.y,-1); TIm2D<INT4,INT4> aTL(aImLabel); ELISE_COPY(aImLabel.border(1),-2,aImLabel.out()); Pt2di aP0; int aCpt=0; ElGrowingSetInd aSV(1000); std::vector<tGRSom *> aVSom; for (aP0.y=0 ; aP0.y<aSz.y ; aP0.y++) { for (aP0.x=0 ; aP0.x<aSz.x ; aP0.x++) { int aLabel = aTIm.get(aP0); if ((aTL.get(aP0)==-1) && (aLabel != aLabelOut)) { std::vector<Pt2di> aVPts; CompCnx(aVPts,V8,aP0,anIm,aImLabel,INT4(aCpt),&aSV); int aNbPts = aVPts.size(); if (aNbPts >= aPGR.mSzMinInit) { cGR_AttrSom anAttr(aP0,aLabel,aCpt,aNbPts); tGRSom & aSom = mGr.new_som(anAttr); aVSom.push_back(&aSom); for (ElGrowingSetInd::const_iterator itV=aSV.begin(); itV!=aSV.end() ; itV++) { tGRSom * aS2 = aVSom[*itV]; if (aS2) { cGR_AttrArc anAA; mGr.add_arc(aSom,*aS2,anAA); } } } else { aVSom.push_back(0); } aCpt++; } } } //std::cout << "BGIN FLAG MONT-DESC\n"; getchar(); // Calcul des flag montant et descandant int aFlagArcMont = mGr.alloc_flag_arc(); int aFlagArcDesc = mGr.alloc_flag_arc(); ElSubGraphe<cGR_AttrSom,cGR_AttrArc> aSubAll; for (int aKS=0 ; aKS<int(aVSom.size()) ; aKS++) { tGRSom * aSom = aVSom[aKS]; if (aSom) { tGRSom * aSMax = aSom; tGRSom * aSMin = aSom; for (tGRSom::TArcIter itA=aSom->begin(aSubAll); itA.go_on(); itA++) { tGRSom * aS2 = &(itA->s2()); if ( (aS2->attr().ValR() > aSMax->attr().ValR()) || ((aS2->attr().ValR()==aSMax->attr().ValR()) && (aS2->attr().Sz() > aSMax->attr().Sz())) ) { aSMax = aS2; } if ( (aS2->attr().ValR() < aSMin->attr().ValR()) || ((aS2->attr().ValR()==aSMin->attr().ValR()) && (aS2->attr().Sz() > aSMin->attr().Sz())) ) { aSMin = aS2; } } if (aSMax != aSom) mGr.arc_s1s2(*aSom,*aSMax)->sym_flag_set_kth_true(aFlagArcMont); if (aSMin != aSom) mGr.arc_s1s2(*aSom,*aSMin)->sym_flag_set_kth_true(aFlagArcDesc); } } // std::cout << "EeenDD FLAG MONT-DESC\n"; // Analyse zone water shade for (int aKMD=0 ; aKMD<2 ; aKMD++) { bool isMont = (aKMD==0); int aFlagArc = (isMont) ? aFlagArcMont : aFlagArcDesc; ElPartition<tGRSom * > aPart; ElSubGraphe<cGR_AttrSom,cGR_AttrArc> aSubAll; cSubGrFlagArc< ElSubGraphe<cGR_AttrSom,cGR_AttrArc> > aSub(aSubAll,aFlagArc); PartitionCC(aPart,mGr,aSub); std::vector<tGRSom *> aVBarbs; cSubGrSzSup aGrCons(aPGR.mSzBarb); Ebarbule(mGr,aSub,aGrCons,aVBarbs); std::set<tGRSom *> aSetB(aVBarbs.begin(),aVBarbs.end()); for (int aKC=0 ; aKC< aPart.nb() ; aKC++) { ElSubFilo<tGRSom *> aCC = aPart[aKC]; int aSzTot = SomSz(aCC); bool Ok = aSzTot >= aPGR.mSeuilZonWS ; if (Ok) { for (int aKS=0 ; aKS<aCC.size() ; aKS++) { if (aSetB.find(aCC[aKS])==aSetB.end()) { aCC[aKS]->attr().Valid() = true; } else { } } } } } // std::cout << "EeenDD PARTITION\n"; getchar(); double aSomT=0; double aMaxT=0; int aDelta = 1; // 1 for (int aKS=0 ; aKS<int(aVSom.size()) ; aKS++) { tGRSom * aSom = aVSom[aKS]; if (aSom && (! aSom->attr().DoneValR())) { ElTimer aChrono; cSubGrInterv aSG(aSom->attr().ValR()-aDelta,aSom->attr().ValR()+aDelta); ElFifo<tGRSom *> aCC; comp_connexe_som(aCC,aSom,aSG); int aSzCC = SomSz(aCC); bool Ok = aSzCC >= aPGR.mSeuilValRDelta; for (int aKC=0 ; aKC<int(aCC.size()) ; aKC++) { tGRSom * aSom2 = aCC[aKC]; if (aSom2->attr().ValR() == aSom->attr().ValR()) aSom2->attr().DoneValR() = true; if (Ok) aSom2->attr().Valid() = true; } // ShowComp(aCC,V8,(Ok?255:0), anIm,aImLabel); double aT = aChrono.uval(); aSomT += aT; if (aT > aMaxT) { aMaxT = aT; } } } /* */ // EXPORT DES RESULTATS FINALS Im2D_Bits<1> aImRes(aSz.x,aSz.y,0); TIm2DBits<1> aTImRes(aImRes); for (int aKS=0 ; aKS<int(aVSom.size()) ; aKS++) { tGRSom * aSom = aVSom[aKS]; if (aSom && aSom->attr().Valid()) { std::vector<Pt2di> aVPts; CompCnxCste(aVPts,V8,aSom->attr().P0(),anIm,aImLabel); for (int aKP=0 ; aKP<int(aVPts.size()) ; aKP++) { aTImRes.oset(aVPts[aKP],1); } } } return aImRes; }