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 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); }
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; }