Im2D_REAL4 RecursiveImpaint ( Im2D_REAL4 aFlMaskInit, Im2D_REAL4 aFlMaskFinal, Im2D_REAL4 aFlIm, int aDeZoom, int aZoomCible ) { Pt2di aSz = aFlIm.sz(); Im2D_REAL4 aSolInit(aSz.x,aSz.y); ELISE_COPY(aFlIm.all_pts(),aFlIm.in(),aSolInit.out()); TIm2D<REAL4,REAL> aTMaskI(aFlMaskInit); TIm2D<REAL4,REAL> aTMaskF(aFlMaskFinal); int aNbIter = 2 + 3 * aDeZoom; if (aDeZoom >=aZoomCible) { aNbIter += ElSquare(aNbIter)/2; Im2D_REAL8 aDblMasqk(aSz.x,aSz.y); ELISE_COPY(aFlIm.all_pts(),aFlMaskInit.in(),aDblMasqk.out()); ELISE_COPY ( select(aDblMasqk.all_pts(), erod_d4(aDblMasqk.in(0)>0.5,1)), 0, aDblMasqk.out() ); Im2D_REAL8 aDblIm(aSz.x,aSz.y); ELISE_COPY(aDblIm.all_pts(),aFlIm.in()*aDblMasqk.in(),aDblIm.out()); FilterGauss(aDblIm,2.0,1); FilterGauss(aDblMasqk,2.0,1); ELISE_COPY ( select(aSolInit.all_pts(),aFlMaskInit.in()<0.5), aDblIm.in() / Max(1e-20,aDblMasqk.in()), aSolInit.out() ); } else { TIm2D<REAL4,REAL> aTSolInit(aSolInit); TIm2D<REAL4,REAL> aTIm(aFlIm); Im2D_REAL4 aSsEch = RecursiveImpaint ( ReducItered(aFlMaskInit,1), ReducItered(aFlMaskFinal,1), ReducItered(aFlIm,1), aDeZoom*2, aZoomCible ); TIm2D<REAL4,REAL> aTSsE(aSsEch); Pt2di aP; for (aP.x=0 ; aP.x<aSz.x ; aP.x++) { for (aP.y=0 ; aP.y<aSz.y ; aP.y++) { double aPdsI = aTMaskI.get(aP); if (aPdsI <0.999) { double aVal = aPdsI * aTIm.get(aP) + (1-aPdsI) * aTSsE.getprojR(Pt2dr(aP.x/2.0,aP.y/2.0)); aTSolInit.oset(aP,aVal); } } } } std::vector<Pt2di> aVF; { Pt2di aP; for (aP.x=1 ; aP.x<aSz.x-1 ; aP.x++) { for (aP.y=1 ; aP.y<aSz.y-1 ; aP.y++) { if ((aTMaskI.get(aP)<0.999) && (aTMaskF.get(aP)>0.001)) { aVF.push_back(aP); } } } } int aNbPts = aVF.size(); for (int aKIter=0 ; aKIter<aNbIter ; aKIter++) { TIm2D<REAL4,REAL> aTSolInit(aSolInit); TIm2D<REAL4,REAL> aTIm(aFlIm); Im2D_REAL4 aNewSol (aSz.x,aSz.y); TIm2D<REAL4,REAL> aTNew(aNewSol); aNewSol.dup(aFlIm); for (int aKP=0 ; aKP<aNbPts ; aKP++) { Pt2di aP = aVF[aKP]; float aSomV=0; float aSomM=0; for (int aKV = 0 ; aKV<5 ; aKV++) { Pt2di aPV = aP+ TAB_5_NEIGH[aKV]; float aM = (float)aTMaskF.get(aPV); aSomM += aM; aSomV += aM *(float)aTSolInit.get(aPV); } float aPdsI = (float)aTMaskI.get(aP); float aVal = aPdsI * (float)aTIm.get(aP) + (1-aPdsI) * (aSomV/aSomM); aTNew.oset(aP,aVal); } aSolInit = aNewSol; } return aSolInit; }
void Dimap::createGrid(std::string const &nomGrid, std::string const &nomImage, double stepPixel, double stepCarto, double rowCrop, double sampCrop, std::vector<double> vAltitude, std::string targetSyst, std::string inputSyst, std::vector<double> vRefineCoef)const { double firstSamp = first_col; double firstLine = first_row; double lastSamp = last_col; double lastLine = last_row; //Direct nbr Lignes et colonnes + step last ligne et colonne int nbLine, nbSamp; nbLine=(lastLine-firstLine)/stepPixel +1; nbSamp=(lastSamp-firstSamp)/stepPixel +1 ; std::vector<Pt2dr> vPtCarto; createDirectGrid(firstSamp, firstLine, stepPixel, nbSamp, nbLine, vAltitude, vPtCarto, targetSyst, inputSyst, vRefineCoef, rowCrop, sampCrop); double xmin,xmax,ymin,ymax; // Pour estimer la zone carto on projette le domaine de validite geo // Recherche de la zone la plus etendue Pt2dr Pcarto = ptGeo2Carto(Pt2dr(first_lat, first_lon), targetSyst, inputSyst); xmin = Pcarto.x; ymin = Pcarto.y; xmax = xmin; ymax = ymin; Pcarto = ptGeo2Carto(Pt2dr(first_lat,last_lon), targetSyst, inputSyst); if (xmin>Pcarto.x) xmin = Pcarto.x; else if (xmax<Pcarto.x) xmax = Pcarto.x; if (ymin>Pcarto.y) ymin = Pcarto.y; else if (ymax<Pcarto.y) ymax = Pcarto.y; Pcarto = ptGeo2Carto(Pt2dr(last_lat, last_lon), targetSyst, inputSyst); if (xmin>Pcarto.x) xmin = Pcarto.x; else if (xmax<Pcarto.x) xmax = Pcarto.x; if (ymin>Pcarto.y) ymin = Pcarto.y; else if (ymax<Pcarto.y) ymax = Pcarto.y; Pcarto = ptGeo2Carto(Pt2dr(last_lat, first_lon), targetSyst, inputSyst); if (xmin>Pcarto.x) xmin = Pcarto.x; else if (xmax<Pcarto.x) xmax = Pcarto.x; if (ymin>Pcarto.y) ymin = Pcarto.y; else if (ymax<Pcarto.y) ymax = Pcarto.y; //Coins sup gauche et inf droit du domaine de validite RPC inverse Pt2dr urc(xmax,ymax); Pt2dr llc(xmin,ymin); std::cout << "Emprise carto : "<<llc.x<<" "<<urc.y<<" "<<urc.x<<" "<<llc.y<<std::endl; //Indirect nbr Lignes et colonnes + step last ligne et colonne int nbrLine, nbrSamp; nbrSamp=(urc.x-llc.x)/stepCarto +1; nbrLine=(urc.y-llc.y)/stepCarto +1; std::vector<Pt2dr> vPtImg; //Calcul des coefficients de l'affinite pour la transformation inverse std::vector<double> vRefineCoefInv; { double A0 = vRefineCoef[0]; double A1 = vRefineCoef[1]; double A2 = vRefineCoef[2]; double B0 = vRefineCoef[3]; double B1 = vRefineCoef[4]; double B2 = vRefineCoef[5]; double det = A1*B2 - A2*B1; double IA0 = -A0; double IA1 = B2/det; double IA2 = -A2/det; double IB0 = -B0; double IB1 = -B1/det; double IB2 = A1/det; vRefineCoefInv.push_back(IA0); vRefineCoefInv.push_back(IA1); vRefineCoefInv.push_back(IA2); vRefineCoefInv.push_back(IB0); vRefineCoefInv.push_back(IB1); vRefineCoefInv.push_back(IB2); } createIndirectGrid( xmin, ymax,nbrSamp,nbrLine,stepCarto,vAltitude,vPtImg, targetSyst, inputSyst, vRefineCoefInv, rowCrop, sampCrop); //Writing the grid //Creating grid and writing flux std::ofstream writeGrid(nomGrid.c_str()); writeGrid <<"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"<<std::endl; writeGrid <<"<trans_coord_grid version=\"5\" name=\"\">"<<std::endl; //creation of the date time_t t= time(0); struct tm * timeInfo =localtime(&t); std::string date; std::stringstream ssdate; ssdate<<timeInfo-> tm_year+1900; double adate []= {(double)timeInfo-> tm_mon, (double)timeInfo-> tm_mday, (double)timeInfo-> tm_hour,(double)timeInfo-> tm_min, (double)timeInfo-> tm_sec}; std::vector<double> vdate (adate,adate+5); // Formating the date for (int ida=0; ida<5;ida++) { std::stringstream ssdateTempo; std::string dateTempo; ssdateTempo<<vdate[ida]; dateTempo=ssdateTempo.str(); if (dateTempo.length()==2) ssdate<<dateTempo; else ssdate<<0<<dateTempo; } date=ssdate.str(); writeGrid <<"\t<date>"<<date<<"</date>"<<std::endl; writeGrid <<"\t<trans_coord name=\"\">"<<std::endl; writeGrid <<"\t\t<trans_sys_coord name=\"\">"<<std::endl; writeGrid <<"\t\t\t<sys_coord name=\"sys1\">"<<std::endl; writeGrid <<"\t\t\t\t<sys_coord_plani name=\"sys1\">"<<std::endl; writeGrid <<"\t\t\t\t\t<code>"<<nomImage<<"</code>"<<std::endl; writeGrid <<"\t\t\t\t\t<unit>"<<"p"<<"</unit>"<<std::endl; writeGrid <<"\t\t\t\t\t<direct>"<<"0"<<"</direct>"<<std::endl; writeGrid <<"\t\t\t\t\t<sub_code>"<<"*"<<"</sub_code>"<<std::endl; writeGrid <<"\t\t\t\t\t<vertical>"<<nomImage<<"</vertical>"<<std::endl; writeGrid <<"\t\t\t\t</sys_coord_plani>"<<std::endl; writeGrid <<"\t\t\t\t<sys_coord_alti name=\"sys1\">"<<std::endl; writeGrid <<"\t\t\t\t\t<code>"<<"Unused in MicMac"<<"</code>"<<std::endl; writeGrid <<"\t\t\t\t\t<unit>"<<"m"<<"</unit>"<<std::endl; writeGrid <<"\t\t\t\t</sys_coord_alti>"<<std::endl; writeGrid <<"\t\t\t</sys_coord>"<<std::endl; writeGrid <<"\t\t\t<sys_coord name=\"sys2\">"<<std::endl; writeGrid <<"\t\t\t\t<sys_coord_plani name=\"sys2\">"<<std::endl; writeGrid <<"\t\t\t\t\t<code>"<<"Unused in MicMac"<<"</code>"<<std::endl; writeGrid <<"\t\t\t\t\t<unit>"<<"m"<<"</unit>"<<std::endl; writeGrid <<"\t\t\t\t\t<direct>"<<"1"<<"</direct>"<<std::endl; writeGrid <<"\t\t\t\t\t<sub_code>"<<"*"<<"</sub_code>"<<std::endl; writeGrid <<"\t\t\t\t\t<vertical>"<<"Unused in MicMac"<<"</vertical>"<<std::endl; writeGrid <<"\t\t\t\t</sys_coord_plani>"<<std::endl; writeGrid <<"\t\t\t\t<sys_coord_alti name=\"sys2\">"<<std::endl; writeGrid <<"\t\t\t\t\t<code>"<<"Unused in MicMac"<<"</code>"<<std::endl; writeGrid <<"\t\t\t\t\t<unit>"<<"m"<<"</unit>"<<std::endl; writeGrid <<"\t\t\t\t</sys_coord_alti>"<<std::endl; writeGrid <<"\t\t\t</sys_coord>"<<std::endl; writeGrid <<"\t\t</trans_sys_coord>"<<std::endl; writeGrid <<"\t\t<category>"<<"1"<<"</category>"<<std::endl; writeGrid <<"\t\t<type_modele>"<<"2"<<"</type_modele>"<<std::endl; writeGrid <<"\t\t<direct_available>"<<"1"<<"</direct_available>"<<std::endl; writeGrid <<"\t\t<inverse_available>"<<"1"<<"</inverse_available>"<<std::endl; writeGrid <<"\t</trans_coord>"<<std::endl; // For the direct grid writeGrid <<"\t<multi_grid version=\"1\" name=\"1-2\" >"<<std::endl; std::stringstream ssUL; std::stringstream ssStepPix; std::stringstream ssNumbCol; std::stringstream ssNumbLine; std::string sUpperLeft; std::string sStepPix; std::string sNumbCol; std::string sNumbLine; ssUL<<std::setprecision(15)<<firstSamp-sampCrop<<" "<<std::setprecision(15)<<firstLine-rowCrop; ssStepPix<<stepPixel; ssNumbCol<<nbSamp; ssNumbLine<<nbLine; sUpperLeft=ssUL.str(); sStepPix=ssStepPix.str(); sNumbCol=ssNumbCol.str(); sNumbLine=ssNumbLine.str(); writeGrid <<"\t\t<upper_left>"<<sUpperLeft<<"</upper_left>"<<std::endl; writeGrid <<"\t\t<columns_interval>"<<sStepPix<<"</columns_interval>"<<std::endl; writeGrid <<"\t\t<rows_interval>"<<"-"+sStepPix<<"</rows_interval>"<<std::endl; writeGrid <<"\t\t<columns_number>"<<sNumbCol<<"</columns_number>"<<std::endl; writeGrid <<"\t\t<rows_number>"<<sNumbLine<<"</rows_number>"<<std::endl; writeGrid <<"\t\t<components_number>"<<"2"<<"</components_number>"<<std::endl; std::vector<Pt2dr>::const_iterator it = vPtCarto.begin(); for(size_t i=0;i<vAltitude.size();++i) { std::stringstream ssAlti; std::string sAlti; ssAlti<<std::setprecision(15)<<vAltitude[i]; sAlti=ssAlti.str(); writeGrid <<"\t\t\t<layer value=\""<<sAlti<<"\">"<<std::endl; for(int l=0;l<nbLine;++l) { for(int c = 0;c<nbSamp;++c) { Pt2dr const &PtCarto = (*it); ++it; std::stringstream ssCoord; std::string sCoord; ssCoord<<std::setprecision(15)<<PtCarto.x<<" "<<std::setprecision(15)<<PtCarto.y; sCoord=ssCoord.str(); writeGrid <<"\t\t\t"<<sCoord<<std::endl; } } writeGrid <<"\t\t\t</layer>"<<std::endl; } writeGrid <<"\t</multi_grid>"<<std::endl; // For the inverse grid writeGrid <<"\t<multi_grid version=\"1\" name=\"2-1\" >"<<std::endl; std::stringstream ssULInv; std::stringstream ssStepCarto; std::stringstream ssNumbColInv; std::stringstream ssNumbLineInv; std::string sUpperLeftInv; std::string sStepCarto; std::string sNumbColInv; std::string sNumbLineInv; ssULInv<<std::setprecision(15)<<vPtCarto[0].x<<" "<<std::setprecision(15)<<vPtCarto[0].y; ssStepCarto<<std::setprecision(15)<<stepCarto; ssNumbColInv<<nbrSamp; ssNumbLineInv<<nbrLine; sUpperLeftInv=ssULInv.str(); sStepCarto=ssStepCarto.str(); sNumbColInv=ssNumbColInv.str(); sNumbLineInv=ssNumbLineInv.str(); writeGrid <<"\t\t<upper_left>"<<sUpperLeftInv<<"</upper_left>"<<std::endl; writeGrid <<"\t\t<columns_interval>"<<sStepCarto<<"</columns_interval>"<<std::endl; writeGrid <<"\t\t<rows_interval>"<<sStepCarto<<"</rows_interval>"<<std::endl; writeGrid <<"\t\t<columns_number>"<<sNumbColInv<<"</columns_number>"<<std::endl; writeGrid <<"\t\t<rows_number>"<<sNumbLineInv<<"</rows_number>"<<std::endl; writeGrid <<"\t\t<components_number>"<<"2"<<"</components_number>"<<std::endl; std::vector<Pt2dr>::const_iterator it2 = vPtImg.begin(); for(size_t i=0;i<vAltitude.size();++i) { std::stringstream ssAlti; std::string sAlti; ssAlti<<std::setprecision(15)<<vAltitude[i]; sAlti=ssAlti.str(); writeGrid <<"\t\t\t<layer value=\""<<sAlti<<"\">"<<std::endl; for(int l=0;l<nbrLine;++l) { for(int c = 0;c<nbrSamp;++c) { Pt2dr const &PtImg = (*it2); ++it2; std::stringstream ssCoordInv; std::string sCoordInv; ssCoordInv<<std::setprecision(15)<<PtImg.x - sampCrop<<" " <<std::setprecision(15)<<PtImg.y - rowCrop; sCoordInv=ssCoordInv.str(); writeGrid <<"\t\t\t"<<sCoordInv<<std::endl; } } writeGrid <<"\t\t\t</layer>"<<std::endl; } writeGrid <<"\t</multi_grid>"<<std::endl; writeGrid <<"</trans_coord_grid>"<<std::endl; }
void cParamIntrinsequeFormel::UpdateCamGrid( double aTol) { if (UseAFocal() && (! AFocalAcceptNoDist)) return; bool aLastFiged = mFiged; mFiged = AllParamIsFiged() ; // Si rien n'a change if (aLastFiged == mFiged) return; // On passe de fige a mobile, donc plus de grille if (aLastFiged) { delete mCamGrid; mCamGrid =0; return; } // On se fige // CamStenope * aCS = CurPIF(); Pt2di aRab(20,20); Pt2di aStep(10,10); double aRabR = 0; Pt2di aSz = aCS->Sz(); double aR = euclid(aSz)/2.0; if (aCS->HasRayonUtile()) aR = aCS->RayonUtile(); // std::cout << "iuytml RAY = " << aR << " SZR " << euclid(aSz)/2.0 << "\n"; mCamGrid = cCamStenopeGrid::Alloc(aR+aRabR,*aCS,Pt2dr(aStep),true,true); if (mCamGrid) { mRayonGrid = 1e20; // std::cout << "iuytml END CGID \n"; double aEcMax =0; for (int aKx=100 ; aKx< aCS->Sz().x ; aKx += 200) { for (int aKy=100 ; aKy< aCS->Sz().y ; aKy += 200) { Pt2dr aP(aKx,aKy); // std::cout << "IZU " << mCamGrid->IsInZoneUtile(aP) << " " << aP << "\n"; if (mCamGrid->IsInZoneUtile(aP)) { // UVGCC4.6 double aEps=1e-5; Pt3dr aRay = aCS->F2toDirRayonL3(aP); // UVGCC4.6 Pt3dr aRayG = mCamGrid->F2toDirRayonL3(aP); // UVGCC4.6 Pt3dr aRayX = aRay + Pt3dr(aEps,0,0); // UVGCC4.6 Pt3dr aRayY = aRay + Pt3dr(0,aEps,0); Pt2dr aP1 = aCS->L3toF2(aRay); Pt2dr aPG = mCamGrid->L3toF2(aRay); // UVGCC4.6 Pt2dr aDx = (mCamGrid->L3toF2(aRayX)-aPG)/aEps; // UVGCC4.6 Pt2dr aDy = (mCamGrid->L3toF2(aRayY)-aPG)/aEps; Pt2dr aDGX,aDGY; // UVGCC4.6 Pt2dr aPG2 = mCamGrid->L2toF2AndDer(Pt2dr(aRay.x,aRay.y),aDGX,aDGY); // std::cout << aPG << aDx << aDy << "\n"; // std::cout << " " << aPG2 << aDGX << aDGY << "\n"; double aDist = euclid(aP1,aPG); if ( aDist >aTol) mRayonGrid = ElMin(mRayonGrid,euclid(aP,aSz/2.0)); aEcMax = ElMax(aDist,aEcMax); } } } /* std::cout << "GetC ------------RTOl------------ " << mRayonGrid << " -EcMax " << aEcMax << "\n"; getchar(); */ } }
template <class Type> void Bench_PackB_IM<Type>::verif() { INT def = (INT)(NRrandom3() * 1000); verif( rectangle(Pt2di(1,0),Pt2di(2,1))); for (INT k=0; k<10 ; k++) { verif( rectangle(Pt2di(k,0),Pt2di(k+1,10) ),def); verif( rectangle(Pt2di(k,0),Pt2di(k+10,10) ),def); verif( rectangle(Pt2di(k,0),Pt2di(k+100,10)),def); verif( rectangle(Pt2di(k,0),Pt2di(k+200,10)),def); } verif( im1.all_pts()); verif( rectangle(Pt2di(-10,-20),sz+Pt2di(30,40)),def); verif( disc(sz/2.0,euclid(sz)/1.8),def); { for (INT k=0 ; k<10 ; k++) { Pt2dr c = sz/2.0 + Pt2dr(NRrandom3(),NRrandom3())*20; REAL ray = 1+NRrandom3()*100; verif(disc(c,ray),def); } } ELISE_COPY(disc(CentreRand(),RayonRand()),1,im1.out()| pck.out()); verif(im1.all_pts()); ELISE_COPY(disc(CentreRand(),RayonRand()),frandr()*8,im1.out()| pck.out()); verif(im1.all_pts()); INT NbPts = (INT)(3 + NRrandom3()*10); ElList<Pt2di> Lpt; { for (INT k=0; k<NbPts ; k++) Lpt = Lpt+Pt2di(CentreRand()); } ELISE_COPY(polygone(Lpt),NRrandom3()<0.1,im1.out()| pck.out()); verif(im1.all_pts()); ModifCSte(rectangle(Pt2di(5,0),Pt2di(10,10)),2); verif(im1.all_pts()); ModifLut(rectangle(Pt2di(0,5),Pt2di(12,12)),FX&3); verif(im1.all_pts()); //ModifCSte(disc(Pt2di(50,50),20),3); ModifCSte(disc(Pt2dr(50,50),20),3); // __NEW verif(im1.all_pts()); for (INT NbC =0 ; NbC < 20 ; NbC++) { ElList<Pt2di> lPt; for (INT iPt =0 ; iPt < 20; iPt ++) { lPt = lPt + Pt2di(CentreRand()); } ModifCSte(polygone(lPt),INT(NRrandom3() * 3)); verif(im1.all_pts()); } Pt2di P_00 (0,0); Pt2di P_10 (sz.x,0); Pt2di P_01 (0,sz.y); ElList<Pt2di> lP1; lP1 = lP1 + P_00; lP1 = lP1 + P_01; lP1 = lP1 + P_10; ModifCSte(polygone(lP1),7); verif(im1.all_pts()); TiffVerif(); }
void cX11_Interface::Init() { //SetImagesPriority(0,); InitNbWindows(); Pt2di aSzF = mParam->SectionWindows().SzTotIm().Val().dcbyc(mNb2W);; int aCpt=0; Video_Win * aLastW = 0; Video_Win * aLastWX0 = 0; Video_Win * aWTitle = 0; Video_Win * aWY0XMax = 0; Pt2di aSzTitle(aSzF.x,15); for (int aKY =0 ; aKY<mNb2W.y ; aKY++) { for (int aKX =0 ; aKX<mNb2W.x ; aKX++) { if (aCpt<mNbW) { Video_Win * aRes = 0; if (aCpt==0) { aWTitle = Video_Win::PtrWStd(aSzTitle,true); aRes = new Video_Win(*aWTitle,Video_Win::eBasG,aSzF); // aRes = Video_Win::PtrWStd(aSzF,true); aLastWX0 = aRes; mDisp = new Video_Display(aRes->disp()); } else { if (aKX==0) { aWTitle = new Video_Win(*aLastWX0,Video_Win::eBasG,aSzTitle); aRes = new Video_Win(*aWTitle,Video_Win::eBasG,aSzF); aLastWX0 = aRes; } else { aWTitle = new Video_Win(*aLastW,Video_Win::eDroiteH,aSzTitle); aRes = new Video_Win(*aWTitle,Video_Win::eBasG,aSzF); } } ELISE_COPY(aWTitle->all_pts(),P8COL::yellow,aWTitle->odisc()); ELISE_COPY(aRes->all_pts(),P8COL::blue,aRes->odisc()); aLastW = aWTitle; mWins.push_back(new cWinIm(*mAppli,*aRes,*aWTitle,*mAppli->imageVis(aCpt))); if ((aKY==0) && (aKX==(mNb2W.x -1))) { aWY0XMax = aWTitle; } } aCpt++; } } Pt2di zoomWindowSize = mParam->SectionWindows().SzWZ().ValWithDef(round_ni(Pt2dr(mParam->SzTotIm().Val())*0.6)); mWZ = new Video_Win(*aWY0XMax,Video_Win::eDroiteH, zoomWindowSize); mZFON = new cFenOuiNon(*mWZ,Pt2di(200,20)); mVNameCase.push_back( cCaseNamePoint("Cancel",eCaseCancel) ); if (mParam->EnterName().Val()) { mVNameCase.push_back( cCaseNamePoint("Enter New",eCaseSaisie) ); } InitVNameCase(); mMenuNamePoint = new cFenMenu(*mWZ,Pt2di(120,20),Pt2di(1,mVNameCase.size())); if (mParam->EnterName().Val()) { mWEnter = new Video_Win(mMenuNamePoint->W(),Video_Win::eDroiteH,Pt2di(150,20)); mWEnter->move_translate(Pt2di(0,20)); ELISE_COPY(mWEnter->all_pts(),P8COL::yellow,mWEnter->odisc()); //mWEnter->move_to(Pt2di(100,20)); mWEnter->lower(); } ELISE_COPY(mWZ->all_pts(),P8COL::green,mWZ->odisc()); }
static Pt2di bench_op_buf_cat_PRand_centre(INT V) { return Pt2di(Pt2dr(V*(NRrandom3()-0.5),V*(NRrandom3()-0.5))); }
int GrShade_main(int argc,char ** argv) { std::string aNameIn; std::string aNameOut; std::string aNameCol=""; Pt2di aP0Glob(0,0),aSzGlob(0,0); INT aNbDir = 20; REAL aFZ = 1.0; REAL aPdsAnis = 0.95; INT aBrd = -1; std::string aTMNt = "real4"; std::string aTShade = "real4"; INT aDequant =0; INT aVisu = 0; REAL aHypsoDyn = -1.0; REAL aHypsoSat = 0.5; Pt2di aSzMaxDalles (3000,3000); INT aSzRecDalles = 300; std::string aModeOmbre="CielVu"; std::string modeOmbre[] = {aModeOmbre,"IgnE","Local","Med","Mixte"}; std::list<std::string> lModeOmbre(modeOmbre, modeOmbre + sizeof(modeOmbre) / sizeof(std::string) ); std::string aFileMasq=""; double aDericheFact=2.0; int aNbIterF = 4; double aFactExp = 0.95; double aDyn = 1.0; int aNbMed = 100; int aNbIterMed = 1; Tiff_Im::SetDefTileFile(1<<15); std::vector<double> aVPdsFiltre; std::string aModeColor = "IntensShade"; std::string modeColor[] = {aModeColor,"BackRGB","GrayBackRGB"}; std::list<std::string> lModeColor(modeColor, modeColor + sizeof(modeColor) / sizeof(std::string) ); double aTetaH = 25.0; double anAzimut = 0.0; double aDynMed = 1.0; ElInitArgMain ( argc,argv, LArgMain() << EAMC(aNameIn, "File name", eSAM_IsExistFile) , LArgMain() << EAM(aNameOut,"Out",true) << EAM(aNameCol,"FileCol",true, "Color file", eSAM_IsExistFile) << EAM(aVisu,"Visu",true) << EAM(aP0Glob,"P0",true) << EAM(aSzGlob,"Sz",true) << EAM(aFZ,"FZ",true) << EAM(aDynMed,"DynMed",true) << EAM(aPdsAnis,"Anisotropie",true) << EAM(aNbDir,"NbDir",true) << EAM(aBrd,"Brd",true) << EAM(aTMNt,"TypeMnt",true, "Type", eSAM_None, ListOfVal(GenIm::bits1_msbf, "")) << EAM(aTShade,"TypeShade",true, "Type", eSAM_None, ListOfVal(GenIm::bits1_msbf, "")) << EAM(aDequant,"Dequant",true) << EAM(aHypsoDyn,"HypsoDyn",true) << EAM(aHypsoSat,"HypsoSat",true) << EAM(aSzMaxDalles,"SzMaxDalles",true) << EAM(aSzRecDalles,"SzRecDalles",true) << EAM(aModeOmbre,"ModeOmbre",true,"in {CielVu,IgnE,Local,Med,Mixte}",eSAM_None,lModeOmbre) << EAM(aFileMasq,"Mask",true, "Mask file", eSAM_IsExistFile) << EAM(aDericheFact,"DericheFact",true) << EAM(aNbIterF,"NbIterF",true) << EAM(aFactExp,"FactExp",true) << EAM(aDyn,"Dyn",true) << EAM(aVPdsFiltre,"PdsF",true,"[CielVu,Local,Grad,Med]", eSAM_NoInit) << EAM(aModeColor,"ModeColor",true,"Color mode", eSAM_None, lModeColor) << EAM(aNbMed,"NbMed",true) << EAM(aNbIterMed,"NbIterMed",true) << EAM(aTetaH,"TetaH",true) << EAM(anAzimut,"Azimut",true) ); if (!MMVisualMode) { double aPdsDef = aVPdsFiltre.size() ? 0 : 1; for (int aK=aVPdsFiltre.size() ; aK<4 ; aK++) aVPdsFiltre.push_back(aPdsDef); double aSPdsF = 0; for (int aK=0 ; aK<4 ; aK++) aSPdsF += aVPdsFiltre[aK]; for (int aK=0 ; aK<4 ; aK++) aVPdsFiltre[aK] /= aSPdsF; std::string aDir,aNameFileIn; SplitDirAndFile(aDir,aNameFileIn,aNameIn); bool WithHypso = (aHypsoDyn>0) || (aNameCol != ""); // bool WithCol = (aNameCol != ""); if (aNameOut=="") aNameOut = StdPrefix(aNameIn) +std::string("Shade.tif"); Tiff_Im aFileIn = Tiff_Im::StdConvGen(aNameIn,1,true,false); if (aSzGlob== Pt2di(0,0)) aSzGlob = aFileIn.sz() -aP0Glob; Fonc_Num aFIn = aFileIn.in_gen(Tiff_Im::eModeCoulGray,Tiff_Im::eModeNoProl); { Tiff_Im ( aNameOut.c_str(), aSzGlob, GenIm::u_int1, Tiff_Im::No_Compr, WithHypso ? Tiff_Im::RGB : Tiff_Im::BlackIsZero ); } Tiff_Im aTifOut(aNameOut.c_str()); if (aSzMaxDalles.x<0) aSzMaxDalles = aSzGlob; Pt2di aPRD(aSzRecDalles,aSzRecDalles); cDecoupageInterv2D aDecoup ( Box2di(aP0Glob,aP0Glob+aSzGlob), aSzMaxDalles, Box2di(-aPRD,aPRD) ); Im2DGen aMnt = AllocImGen(aDecoup.SzMaxIn(),aTMNt); Im2DGen aShade = AllocImGen(aDecoup.SzMaxIn(),aTShade); cout << "SZ Max In " << aDecoup.SzMaxIn() << endl; REAL aRatio = ElMin(800.0/aSzGlob.x,700.0/aSzGlob.y); Video_Win * pW = aVisu ? Video_Win::PtrWStd(Pt2di(Pt2dr(aSzGlob)*aRatio)) : 0 ; aTetaH *= (2*PI)/360.0; anAzimut *= (2*PI)/360.0; for (int aKDec=0; aKDec<aDecoup.NbInterv() ; aKDec++) { Box2di aBoxIn = aDecoup.KthIntervIn(aKDec); Pt2di aSzIn = aBoxIn.sz(); Pt2di aP0In = aBoxIn.P0(); cout << "DEQ " << aDequant << "Sz In " << aSzIn <<endl; REAL aVMin; if (aDequant) { ElImplemDequantifier aDeq(aSzIn); aDeq.SetTraitSpecialCuv(true); aDeq.DoDequantif(aSzIn, trans(aFIn,aP0In),true); REAL aVMax; ELISE_COPY ( rectangle(Pt2di(0,0),aSzIn), aDeq.ImDeqReelle() * aFZ, aMnt.out() | VMax(aVMax) |VMin(aVMin) ); } else { ELISE_COPY ( rectangle(Pt2di(0,0),aSzIn), trans(aFIn,aP0In)*aFZ, aMnt.out()|VMin(aVMin) ); } Im2D_Bits<1> aIMasq(aSzIn.x,aSzIn.y,1); if (aFileMasq!="") { if (ELISE_fp::exist_file(aDir+aFileMasq)) aFileMasq = aDir+aFileMasq; double aDif=100; Tiff_Im aFM = Tiff_Im::StdConvGen(aFileMasq,1,true,false); ELISE_COPY ( select(rectangle(Pt2di(0,0),aSzIn),trans(!aFM.in_proj(),aP0In)), aVMin-aDif, aMnt.out() | (aIMasq.out() << 0) ); aVMin-= aDif; } if (aBrd>0) { cout << "VMin = " << aVMin <<endl; ELISE_COPY(aMnt.border(aBrd),aVMin-1000,aMnt.out()); } // Im2D_REAL4 aShade(aSzGlob.x,aSzGlob.y); ELISE_COPY(aShade.all_pts(),0,aShade.out()); if (pW) pW = pW->PtrChc(Pt2dr(aP0Glob-aP0In),Pt2dr(aRatio,aRatio)); REAL SPds = 0; REAL aSTot = 0; REAL Dyn = 1.0; if (aTShade != "u_int1") Dyn = 100; bool Done = false; if ( (aModeOmbre=="CielVu") || ((aModeOmbre=="Mixte") && (aVPdsFiltre[0] > 0.0)) ) { std::cout << "BEGIN CIEL" << endl; Done = true; for (int aK=0 ; aK< 2 ; aK++) { SPds = 0; for (int i=0; i<aNbDir; i++) { REAL Teta = (2*PI*i) / aNbDir ; Pt2dr U(cos(Teta),sin(Teta)); Pt2di aDir = Pt2di(U * (aNbDir * 4)); REAL Pds = (1-aPdsAnis) + aPdsAnis *ElSquare(1.0 - euclid(U,Pt2dr(0,1))/2); if (aK==1) Pds = (Pds*Dyn) / (2*aSTot); Symb_FNum Gr = (1-cos(PI/2-atan(gray_level_shading(aMnt.in())))) *255.0; cout << "Dir " << i << " Sur " << aNbDir << " P= " << Pds << endl; SPds += Pds; if (aK==1) { ELISE_COPY ( line_map_rect(aDir,Pt2di(0,0),aSzIn), Min(255*Dyn,aShade.in()+Pds*Gr), aShade.out() // | (pW ? (pW->ogray()<<(aShade.in()/SPds)) : Output::onul()) | (pW ? (pW->ogray()<<(Gr)) : Output::onul()) ); } } aSTot = SPds; } double aMul = (aModeOmbre=="Mixte") ? aVPdsFiltre[0] : 1.0; ELISE_COPY(aShade.all_pts(),aShade.in()*(aMul/SPds),aShade.out()); SPds = aMul; std::cout << "BEGIN CIEL" << endl; } if ( (aModeOmbre=="Local") || ((aModeOmbre=="Mixte") && (aVPdsFiltre[1] > 0.0)) ) { std::cout << "BEGIN LOCAL" << endl; Done = true; Fonc_Num aFonc = aMnt.in_proj(); Fonc_Num aMoy = aFonc; for (int aK=0 ; aK<aNbIterF; aK++) aMoy = canny_exp_filt(aMoy*aIMasq.in_proj(),aFactExp,aFactExp) / Max(0.1,canny_exp_filt(aIMasq.in_proj(),aFactExp,aFactExp)); double aMul = (aModeOmbre=="Mixte") ? aVPdsFiltre[1] : 1.0; ELISE_COPY ( rectangle(Pt2di(0,0),aSzIn), Max(0,Min(255, aShade.in() +(128+(aFonc-aMoy)*aDyn)* aMul)), aShade.out() ); SPds += aMul; std::cout << "END LOCAL" << endl; } if ( (aModeOmbre=="Med") || ((aModeOmbre=="Mixte") && (aVPdsFiltre[3] > 0.0)) ) { std::cout << "BEGIN MED" << endl; Done = true; Fonc_Num aFonc = round_ni(aMnt.in_proj()*aDynMed); int aVMax,aVMin; ELISE_COPY ( rectangle(Pt2di(-1,-1),aSzIn+Pt2di(1,1)), aFonc, VMin(aVMin)|VMax(aVMax) ); Fonc_Num aMoy = aFonc-aVMin; for (int aK=0 ; aK<aNbIterMed; aK++) aMoy = rect_median(aMoy,aNbMed,aVMax-aVMin+1); aMoy = aMoy + aVMin; double aMul = (aModeOmbre=="Mixte") ? aVPdsFiltre[3] : 1.0; ELISE_COPY ( rectangle(Pt2di(0,0),aSzIn), Max(0,Min(255, aShade.in() +(128+((aFonc-aMoy)*aDyn)/aDynMed)* aMul)), aShade.out() ); SPds += aMul; std::cout << "END MED" << endl; } if ( (aModeOmbre=="IgnE") || ((aModeOmbre=="Mixte") && (aVPdsFiltre[2] > 0.0)) ) { int aCpt=0; aCpt++; std::cout << "IGN E " << aCpt << " " << aKDec << "\n"; Done = true; if (aCpt>0) { Symb_FNum aGrad = deriche(aMnt.in_proj(),aDericheFact); Symb_FNum aGx = (aGrad.v0()); Symb_FNum aGy = (aGrad.v1()); Symb_FNum aNG = sqrt(1+Square(aGx)+Square(aGy)); Symb_FNum aNx (aGx/aNG); Symb_FNum aNy (aGy/aNG); Symb_FNum aNz (1/aNG); Pt2dr aDirS = Pt2dr::FromPolar(1.0,anAzimut) * Pt2dr(1,0); double aSx = aDirS.x * sin(aTetaH); double aSy = aDirS.y * sin(aTetaH); double aSz = cos(aTetaH); Symb_FNum aScal(aNx*aSx+aNy*aSy+aNz*aSz); std::cout << "AAAAAAAaa" << endl; double aMul = (aModeOmbre=="Mixte") ? aVPdsFiltre[2] : 1.0; ELISE_COPY ( rectangle(Pt2di(0,0),aSzIn), Max(0,aShade.in() + 255*aScal * aMul), aShade.out() ); SPds += aMul; std::cout << "BBBBbbb" << endl; } } if (! Done) { ELISE_ASSERT(false,"Unknown ModeOmbre"); } Fonc_Num aFoncRes = Max(0,Min(255,aShade.in()/SPds)); if (WithHypso) { Fonc_Num aFIntens = aFoncRes; Fonc_Num aFTeinte = trans(aFIn,aP0In)*aHypsoDyn; Fonc_Num aFSat = 255*aHypsoSat; if (aNameCol!="") { Tiff_Im aFileCol = Tiff_Im::StdConvGen(aDir+aNameCol,-1,true,false); Symb_FNum aFNC(trans(rgb_to_its(aFileCol.in()),aP0In)); if (aModeColor == "IntensShade") { aFIntens = aFoncRes; aFTeinte = aFNC.v1(); aFSat = aFNC.v2(); } else if (aModeColor == "BackRGB") { aFIntens = aIMasq.in()*aFoncRes + (1- aIMasq.in()) * aFNC.v0(); aFTeinte = aFNC.v1(); aFSat = aFNC.v2() * (1- aIMasq.in()); } else if (aModeColor == "GrayBackRGB") { aFIntens = aIMasq.in()*aFoncRes + (1- aIMasq.in()) * aFNC.v0(); aFTeinte = aFNC.v1(); aFSat = aFNC.v2()*(1-aIMasq.in()); } else { ELISE_ASSERT(false,"Unknown mode color"); } } aFoncRes = its_to_rgb(Virgule(aFIntens,aFTeinte,aFSat)); //aFoncRes = its_to_rgb(Virgule(aFoncRes,trans(aFIn,aP0In)*aHypsoDyn,255*aHypsoSat)); } /* if (WithCol) { Tiff_Im aFileCol(aNameCol.c_str()); Symb_FNum aFNC(trans(rgb_to_its(aFileCol.in()),aP0In)); aFoncRes = its_to_rgb(Virgule(aFoncRes,aFNC.v1(),aFNC.v2()*aHypsoSat)); // aFoncRes = aFileCol.in(); } */ // Tiff_Im::Create8BFromFonc(aNameOut,aShade.sz(),aShade.in()/SPds); cout << "WithHypso " << WithHypso << " DIM " << aFoncRes.dimf_out() << endl; Box2di aBoxOut = aDecoup.KthIntervOut(aKDec); ELISE_COPY ( rectangle(aBoxOut.P0()-aP0Glob,aBoxOut.P1()-aP0Glob), trans(aFoncRes,aP0Glob-aP0In), aTifOut.out() ); } return EXIT_SUCCESS; } else return EXIT_SUCCESS; }
Pt2dr cOneImLSQ::PVois(int aKx,int aKy) const { return mPImCur + Pt2dr(aKx*mTest.Step(),aKy*mTest.Step()); }
bool cOneTestLSQ::OK(const Pt2dr & aP) const { return mIm1->OK(Pt2dr(0,0)) && mIm2->OK(aP) ; }
//Pt2di Pt_of_DPT(const PtDelTest & PDT) { return PDT.pt();} Pt2dr Pt_of_DPT(const PtDelTest & PDT) { return Pt2dr(PDT.pt());} // __NEW
void operator () (PtDelTest & p1,PtDelTest & p2,bool ArcDegen) { if (! ArcDegen) //_w.draw_seg(p1.pt(),p2.pt(),_w.pdisc()(P8COL::blue)); _w.draw_seg(Pt2dr(p1.pt()),Pt2dr(p2.pt()),_w.pdisc()(P8COL::blue)); // __NEW }
void cZBuf::BasculerUnTriangle(cTriangle &aTri, bool doMask) { vector <Pt3dr> Sommets; aTri.getVertexes(Sommets); if (Sommets.size() == 3 ) { //Projection du terrain vers l'image Pt3dr A3 = mNuage->Euclid2ProfAndIndex(Sommets[0]); Pt3dr B3 = mNuage->Euclid2ProfAndIndex(Sommets[1]); Pt3dr C3 = mNuage->Euclid2ProfAndIndex(Sommets[2]); Pt2dr A2(A3.x, A3.y); Pt2dr B2(B3.x, B3.y); Pt2dr C2(C3.x, C3.y); Pt2dr AB = B2-A2; Pt2dr AC = C2-A2; REAL aDet = AB^AC; if (aDet==0) return; Pt2di A2i = round_down(A2); Pt2di B2i = round_down(B2); Pt2di C2i = round_down(C2); //On verifie que le triangle se projete entierement dans l'image //TODO: gerer les triangles de bord if (A2i.x < 0 || B2i.x < 0 || C2i.x < 0 || A2i.y < 0 || B2i.y < 0 || C2i.y < 0 || A2i.x >= mSzRes.x || B2i.x >= mSzRes.x || C2i.x >= mSzRes.x || A2i.y >= mSzRes.y || B2i.y >= mSzRes.y || C2i.y >= mSzRes.y) return; REAL zA = A3.z; REAL zB = B3.z; REAL zC = C3.z; Pt2di aP0 = round_down(Inf(A2,Inf(B2,C2))); aP0 = Sup(aP0,Pt2di(0,0)); Pt2di aP1 = round_up(Sup(A2,Sup(B2,C2))); aP1 = Inf(aP1,mSzRes-Pt2di(1,1)); if (doMask) { for (INT x=aP0.x ; x<= aP1.x ; x++) for (INT y=aP0.y ; y<= aP1.y ; y++) { Pt2dr AP = Pt2dr(x,y)-A2; // Coordonnees barycentriques de P(x,y) REAL aPdsB = (AP^AC) / aDet; REAL aPdsC = (AB^AP) / aDet; REAL aPdsA = 1 - aPdsB - aPdsC; if ((aPdsA>-Eps) && (aPdsB>-Eps) && (aPdsC>-Eps)) { mImMask.set(x, y, 1); } } } else { for (INT x=aP0.x ; x<= aP1.x ; x++) for (INT y=aP0.y ; y<= aP1.y ; y++) { Pt2dr AP = Pt2dr(x,y)-A2; // Coordonnees barycentriques de P(x,y) REAL aPdsB = (AP^AC) / aDet; REAL aPdsC = (AB^AP) / aDet; REAL aPdsA = 1 - aPdsB - aPdsC; if ((aPdsA>-Eps) && (aPdsB>-Eps) && (aPdsC>-Eps)) { REAL4 aZ = (float) (zA*aPdsA + zB*aPdsB + zC*aPdsC); if (aZ>mDataRes[y][x]) { mDataRes[y][x] = aZ; mImTriIdx.SetI(Pt2di(x,y),aTri.getIdx()); } } } } } }
Im2D_REAL4 cZBuf::BasculerUnMaillage(const cMesh &aMesh, const CamStenope &aCam) { mRes = Im2D_REAL4(mSzRes.x,mSzRes.y,mDpDef); mDataRes = mRes.data(); mImTriIdx = Im2D_INT4(mSzRes.x,mSzRes.y, mIdDef); vector <cTriangle> vTriangles; aMesh.getTriangles(vTriangles); vector <bool> vTrianglesPartiels; //0= ok 1=partiellement vu ou caché for (unsigned int aK =0; aK<vTriangles.size();++aK) { vTrianglesPartiels.push_back(false); } for (unsigned int aK =0; aK<vTriangles.size();++aK) { cTriangle aTri = vTriangles[aK]; vector <Pt3dr> Sommets; aTri.getVertexes(Sommets); if (Sommets.size() == 3) { Pt2dr A2 = aCam.R3toF2(Sommets[0]); Pt2dr B2 = aCam.R3toF2(Sommets[1]); Pt2dr C2 = aCam.R3toF2(Sommets[2]); Pt2dr AB = B2-A2; Pt2dr AC = C2-A2; REAL aDet = AB^AC; if (aDet!=0) { /* Pt2di A2i = round_down(A2); Pt2di B2i = round_down(B2); Pt2di C2i = round_down(C2); //On verifie que le triangle se projete entierement dans l'image //TODO: gerer les triangles de bord if (A2i.x < 0 || B2i.x < 0 || C2i.x < 0 || A2i.y < 0 || B2i.y < 0 || C2i.y < 0 || A2i.x >= mSzRes.x || B2i.x >= mSzRes.x || C2i.x >= mSzRes.x || A2i.y >= mSzRes.y || B2i.y >= mSzRes.y || C2i.y >= mSzRes.y) return;*/ Pt3dr center = aCam.OrigineProf(); REAL zA = euclid(Sommets[0] - center); //repris de ElNuage3DMaille ProfOfPtE() REAL zB = euclid(Sommets[1] - center); REAL zC = euclid(Sommets[2] - center); Pt2di aP0 = round_down(Inf(A2,Inf(B2,C2))); aP0 = Sup(aP0,Pt2di(0,0)); Pt2di aP1 = round_up(Sup(A2,Sup(B2,C2))); aP1 = Inf(aP1,mSzRes-Pt2di(1,1)); for (INT x=aP0.x ; x<= aP1.x ; x++) for (INT y=aP0.y ; y<= aP1.y ; y++) { Pt2dr AP = Pt2dr(x,y)-A2; // Coordonnees barycentriques de P(x,y) REAL aPdsB = (AP^AC) / aDet; REAL aPdsC = (AB^AP) / aDet; REAL aPdsA = 1 - aPdsB - aPdsC; if ((aPdsA>-Eps) && (aPdsB>-Eps) && (aPdsC>-Eps)) { REAL4 aZ = (float) (zA*aPdsA + zB*aPdsB + zC*aPdsC); if (aZ<mDataRes[y][x]) { int index = mImTriIdx.GetI(Pt2di(x,y)); if (index != mIdDef) vTrianglesPartiels[index] = true; mDataRes[y][x] = aZ; mImTriIdx.SetI(Pt2di(x,y),aTri.getIdx()); } } } } } } //on enleve les triangles partiellement vus for(int aK=0; aK < mSzRes.x; aK++) for (int bK=0; bK < mSzRes.y; bK++) { int index = mImTriIdx.GetI(Pt2di(aK,bK)); if (vTrianglesPartiels[index]) { mDataRes[bK][aK] = mDpDef; mImTriIdx.SetI(Pt2di(aK,bK),USHRT_MAX); } else if ((index != mIdDef) && (find(vTri.begin(), vTri.end(), index)==vTri.end())) vTri.push_back(index); } return mRes; }
int HomFilterMasq_main(int argc,char ** argv) { // MemoArg(argc,argv); MMD_InitArgcArgv(argc,argv); std::string aDir,aPat,aFullDir; bool ExpTxt=false; std::string PostPlan="_Masq"; std::string KeyCalcMasq; std::string KeyEquivNoMasq; std::string MasqGlob; double aResol=10; bool AcceptNoMask; std::string aPostIn= ""; std::string aPostOut= "MasqFiltered"; std::string aOriMasq3D,aNameMasq3D; cMasqBin3D * aMasq3D = 0; ElInitArgMain ( argc,argv, LArgMain() << EAMC(aFullDir,"Full name (Dir+Pat)", eSAM_IsPatFile), LArgMain() << EAM(PostPlan,"PostPlan",true,"Post to plan, Def : toto ->toto_Masq.tif like with SaisieMasq") << EAM(MasqGlob,"GlobalMasq",true,"Global Masq to add to all image") << EAM(KeyCalcMasq,"KeyCalculMasq",true,"For tuning masq per image") << EAM(KeyEquivNoMasq,"KeyEquivNoMasq",true,"When given if KENM(i1)==KENM(i2), don't masq") << EAM(aResol,"Resol",true,"Sub Resolution for masq storing, Def=10") << EAM(AcceptNoMask,"ANM",true,"Accept no mask, def = true if MasqGlob and false else") << EAM(ExpTxt,"ExpTxt",true,"Ascii format for in and out, def=false") << EAM(aPostIn,"PostIn",true,"Post for Input dir Hom, Def=") << EAM(aPostOut,"PostOut",true,"Post for Output dir Hom, Def=MasqFiltered") << EAM(aOriMasq3D,"OriMasq3D",true,"Orientation for Masq 3D") << EAM(aNameMasq3D,"Masq3D",true,"File of Masq3D, Def=AperiCloud_${OriMasq3D}.ply") ); #if (ELISE_windows) replace( aFullDir.begin(), aFullDir.end(), '\\', '/' ); #endif SplitDirAndFile(aDir,aPat,aFullDir); if (EAMIsInit(&PostPlan)) { CorrecNameMasq(aDir,aPat,PostPlan); } if (!EAMIsInit(&AcceptNoMask)) AcceptNoMask = EAMIsInit(&MasqGlob) || EAMIsInit(&aOriMasq3D); cInterfChantierNameManipulateur * anICNM = cInterfChantierNameManipulateur::BasicAlloc(aDir); std::string aKeyOri; if (EAMIsInit(&aOriMasq3D)) { anICNM->CorrecNameOrient(aOriMasq3D); if (! EAMIsInit(&aNameMasq3D)) { aNameMasq3D = aDir + "AperiCloud_" + aOriMasq3D + ".ply"; } aMasq3D = cMasqBin3D::FromSaisieMasq3d(aDir+aNameMasq3D); aKeyOri = "NKS-Assoc-Im2Orient@" + aOriMasq3D; } Im2D_Bits<1> aImMasqGlob(1,1); if (EAMIsInit(&MasqGlob)) aImMasqGlob = GetMasqSubResol(aDir+MasqGlob,aResol); const std::vector<std::string> * aVN = anICNM->Get(aPat); std::vector<Im2D_Bits<1> > aVMasq; std::vector<CamStenope *> aVCam; for (int aKN = 0 ; aKN<int(aVN->size()) ; aKN++) { std::string aNameIm = (*aVN)[aKN]; Tiff_Im aTF = Tiff_Im::StdConvGen(aNameIm,1,false); Pt2di aSzG = aTF.sz(); Pt2di aSzR (round_ni(Pt2dr(aSzG)/aResol)); Im2D_Bits<1> aImMasq(aSzR.x,aSzR.y,1); std::string aNameMasq = StdPrefix(aNameIm)+PostPlan + ".tif"; if (EAMIsInit(&KeyCalcMasq)) { aNameMasq = anICNM->Assoc1To1(KeyCalcMasq,aNameIm,true); } if (ELISE_fp::exist_file(aNameMasq)) { Im2D_Bits<1> aImMasqLoc = GetMasqSubResol(aDir+aNameMasq,aResol); ELISE_COPY(aImMasq.all_pts(),aImMasq.in() && aImMasqLoc.in(0),aImMasq.out()); } else { if (!AcceptNoMask) { std::cout << "For Im " << aNameIm << " file " << aNameMasq << " does not exist\n"; ELISE_ASSERT(false,"Masq not found"); } } if (EAMIsInit(&MasqGlob)) { ELISE_COPY(aImMasq.all_pts(),aImMasq.in() && aImMasqGlob.in(0),aImMasq.out()); } aVMasq.push_back(aImMasq); // Tiff_Im::CreateFromIm(aImMasq,"SousRes"+aNameMasq); if (aMasq3D!=0) { aVCam.push_back(anICNM->StdCamOfNames(aNameIm,aOriMasq3D)); } } std::string anExt = ExpTxt ? "txt" : "dat"; std::string aKHIn = std::string("NKS-Assoc-CplIm2Hom@") + std::string(aPostIn) + std::string("@") + std::string(anExt); std::string aKHOut = std::string("NKS-Assoc-CplIm2Hom@") + std::string(aPostOut) + std::string("@") + std::string(anExt); for (int aKN1 = 0 ; aKN1<int(aVN->size()) ; aKN1++) { for (int aKN2 = 0 ; aKN2<int(aVN->size()) ; aKN2++) { std::string aNameIm1 = (*aVN)[aKN1]; std::string aNameIm2 = (*aVN)[aKN2]; std::string aNameIn = aDir + anICNM->Assoc1To2(aKHIn,aNameIm1,aNameIm2,true); if (ELISE_fp::exist_file(aNameIn)) { bool UseMasq = true; if (EAMIsInit(&KeyEquivNoMasq)) { UseMasq = (anICNM->Assoc1To1(KeyEquivNoMasq,aNameIm1,true) != anICNM->Assoc1To1(KeyEquivNoMasq,aNameIm2,true) ); } TIm2DBits<1> aMasq1 ( aVMasq[aKN1]); TIm2DBits<1> aMasq2 ( aVMasq[aKN2]); ElPackHomologue aPackIn = ElPackHomologue::FromFile(aNameIn); ElPackHomologue aPackOut; for (ElPackHomologue::const_iterator itP=aPackIn.begin(); itP!=aPackIn.end() ; itP++) { Pt2dr aP1 = itP->P1(); Pt2dr aP2 = itP->P2(); Pt2di aQ1 = round_ni(aP1/aResol); Pt2di aQ2 = round_ni(aP2/aResol); bool Ok = ((aMasq1.get(aQ1,0) && aMasq2.get(aQ2,0)) || (! UseMasq)); if (Ok && aMasq3D) { Pt3dr aPTer= aVCam[aKN1]->PseudoInter(aP1,*(aVCam[aKN2]),aP2); if (! aMasq3D->IsInMasq(aPTer)) Ok = false; } if (Ok) { ElCplePtsHomologues aCple(aP1,aP2); aPackOut.Cple_Add(aCple); } } std::string aNameOut = aDir + anICNM->Assoc1To2(aKHOut,aNameIm1,aNameIm2,true); aPackOut.StdPutInFile(aNameOut); std::cout << "IN " << aNameIn << " " << aNameOut << " UseM " << UseMasq << "\n"; } } } // std::vector<cImFMasq *> mVIm; return 0; }
void cWindowXmlEditor::ModifyCase(cCaseX11Xml * aCase,int aKC) { aCase->Efface(P8COL::green); cWXXInfoCase & anIC = mVInfoCase[aKC]; std::string & aStr0 = anIC.mTree->GetUniqueVal(); std::string aStrInit = aStr0; aStr0 = mW.GetString(Pt2dr(aCase->P0Line()),mW.pdisc()(P8COL::black),mW.pdisc()(P8COL::red),aStr0); bool Ok = true; cElXMLTree * aFilter = anIC.mFilter; { if ((aFilter!=0) && aFilter->HasAttr("Type")) { bool CurrErrorOnXmlInit = GenereErrorOnXmlInit; GenereErrorOnXmlInit = false; const std::string & aType = aFilter->ValAttr("Type"); // std::cout << "TYPEEEE " << aType << "\n"; if (aType=="int") { int anInt; xml_init(anInt,anIC.mTree); } else if (aType=="double") { double aDouble; xml_init(aDouble,anIC.mTree); } else if (aType=="Pt2dr") { Pt2dr aPt; xml_init(aPt,anIC.mTree); } else if (aType=="Pt2di") { Pt2di aPt; xml_init(aPt,anIC.mTree); } else { std::cout << "For type = " << aType << "\n"; ELISE_ASSERT(false,"Bad Type Specif in filter Xml/X11"); } GenereErrorOnXmlInit = CurrErrorOnXmlInit; if (GotErrorOnXmlInit) { ShowWarn(std::string("String=[") +aStr0 + "] not valid for " + aType , "Clik in to continue"); // std::cout << "String=[" << aStr0 << "] not valid for " << aType << "\n"; Ok = false; aStr0 = aStrInit; } } } aCase->Efface(); aCase->string(-10,aStr0); if (Ok) anIC.mTimeModif = mTimeModif++; }
bool cOneTestLSQ::OneLSQItere() { if (!OK(Pt2dr(0,0))) return false; ClearStat(); int aCpt=0; RMat_Inertie aMat; double aDif = 0; for(int aKx=-mNbW; aKx<=mNbW; aKx++) { for(int aKy=-mNbW; aKy<=mNbW; aKy++) { Pt2dr aP2 = mIm2->PVois(aKx,aKy); Pt3dr aGV2 = mIm2->GetValDer(aP2); double aV1 = mValsIm1[aCpt]; // double aV1 = mIm1.GetVal(mIm1.PVois(aKx,aKy)); double aV2 = aGV2.z; double aGx = aGV2.x; double aGy = aGV2.y; aDif += ElSquare(aV1-aV2); aMat.add_pt_en_place(aV1,aV2); // Pour verifier la justesse des moindres carres if (0) { aV2 = 50 + 2 * aV1 - 0.5* aGx -0.25 * aGy; } mCov[IndK0][IndK0] += 1; mCov[IndK0][IndK1] += aV1; mCov[IndK0][IndKx] -= aGx; mCov[IndK0][IndKy] -= aGy; mCov[IndK1][IndK1] += aV1*aV1; mCov[IndK1][IndKx] -= aV1*aGx; mCov[IndK1][IndKy] -= aV1*aGy; mCov[IndKx][IndKx] += aGx*aGx; mCov[IndKx][IndKy] += aGx*aGy; mCov[IndKy][IndKy] += aGy*aGy; mSomI2[IndK0] += aV2; mSomI2[IndK1] += aV1 * aV2; mSomI2[IndKx] -= aV2 * aGx; mSomI2[IndKy] -= aV2 * aGy; aCpt++; } } for(int aK1=0; aK1<NbInc; aK1++) { mMatI2(0,aK1) = mSomI2[aK1]; for(int aK2=0; aK2<=aK1; aK2++) { mMatCov(aK1,aK2) = mMatCov(aK2,aK1) = mCov[aK2][aK1]; } } jacobi_diag(mMatCov,mValP,mVecP); double aVPMin = 1e10; for(int aK1=0; aK1<NbInc; aK1++) aVPMin = std::min(aVPMin,mValP(aK1,aK1)); if (aVPMin<1e-8) return false; mSolLSQ = gaussj(mMatCov) * mMatI2; mCorel0LSQ = aMat.correlation(); mDepLSQ = Pt2dr(mSolLSQ(0,2), mSolLSQ(0,3)); mDeps.push_back(mDepLSQ); return true; }
void cCaseX11Xml::Efface(Col_Pal aCoul) { mW.fill_rect(Pt2dr(mBox._p0),Pt2dr(mBox._p1),aCoul); }
void cAppliMICMAC::DoCorrelLeastQuare(const Box2di & aBoxOut,const Box2di & aBoxIn,const cCorrel2DLeastSquare & aClsq) { int aPer = aClsq.PeriodEch(); cOneTestLSQ aTest ( TheNbIterLine, PDV1()->LoadedIm().DataFloatIm()[0],PDV1()->LoadedIm().SzIm(), PDV2()->LoadedIm().DataFloatIm()[0],PDV2()->LoadedIm().SzIm(), CurEtape()->InterpFloat(), aClsq ); Pt2di aP0Red = round_up(Pt2dr(aBoxOut._p0) / double(aPer)); Pt2di aP1Red = round_up(Pt2dr(aBoxOut._p1) / double(aPer)); Pt2di aSzRed = aP1Red - aP0Red; Im2D_REAL8 aImDepX(aSzRed.x,aSzRed.y); Im2D_REAL8 aImDepY(aSzRed.x,aSzRed.y); Pt2di aPRed; const cOneNappePx & aPx1 = mLTer->KthNap(0); const cOneNappePx & aPx2 = mLTer->KthNap(1); for (aPRed.x=aP0Red.x ; aPRed.x<aP1Red.x ; aPRed.x++) { for (aPRed.y=aP0Red.y ; aPRed.y<aP1Red.y ; aPRed.y++) { // std::cout <<"REST " << aP1Red - aPRed << "\n"; Pt2di aP = aPRed * aPer; Pt2di aPLoc = aP-aBoxIn._p0; double aPx[2]; aPx[0] = aPx1.mTPxInit.get(aPLoc); aPx[1] = aPx2.mTPxInit.get(aPLoc); mCurEtape->GeomTer().PxDisc2PxReel(aPx,aPx); //aTest.SetPIm1(PDV1()->Geom().CurObj2Im(Pt2dr(aP),aPx)); //aTest.SetPIm2(PDV2()->Geom().CurObj2Im(Pt2dr(aP),aPx)); aTest.MinimByLSQandGolden ( PDV1()->Geom().CurObj2Im(Pt2dr(aP),aPx), PDV2()->Geom().CurObj2Im(Pt2dr(aP),aPx) ); double aPx0[2]={0,0}; Pt2dr aP20 = PDV2()->Geom().CurObj2Im(Pt2dr(aP),aPx0); Pt2dr aP2 = aTest.Im2().PImCur(); aImDepX.SetR(aPRed-aP0Red,aP2.x-aP20.x); aImDepY.SetR(aPRed-aP0Red,aP2.y-aP20.y); } } Tiff_Im aFileRX = mCurEtape->KPx(0).FileIm(); Tiff_Im aFileRY = mCurEtape->KPx(1).FileIm(); ELISE_COPY ( rectangle(aP0Red,aP1Red), trans(aImDepX.in(),-aP0Red), aFileRX.out() ); ELISE_COPY ( rectangle(aP0Red,aP1Red), trans(aImDepY.in(),-aP0Red), aFileRY.out() ); /* */ }
void bench_op_buf_cat ( Pt2di szIm ) { Pt2di p0 = Pt2di(Pt2dr(szIm.x*(NRrandom3()/2.1 -0.1),szIm.y *(NRrandom3()/2.1-0.1))); Pt2di p1 = Pt2di(Pt2dr(szIm.x*(1.1 -NRrandom3()/2.1),szIm.y *(1.1-NRrandom3()/2.1))); INT fact = 50; Im2D_REAL8 Im1(szIm.x,szIm.y); Im2D_REAL8 Im2(szIm.x,szIm.y); ELISE_COPY ( Im1.all_pts(), Virgule(unif_noise_4(3) * fact, unif_noise_4(3) * fact), Virgule(Im1.out(),Im2.out()) ); Box2di aBox(bench_op_buf_cat_PRand_centre(20),bench_op_buf_cat_PRand_centre(20)); aBox._p0.SetInf(Pt2di(0,0)); aBox._p1.SetSup(Pt2di(0,0)); bench_op_buf_cat<INT> ((INT *)0, FX,FY,Virgule(FX,FY), p0,p1); Fonc_Num RFonc = Im1.in(0); Fonc_Num IFonc = Iconv(Im1.in(0)); bench_op_buf_cat<INT> ( (INT *) 0, rect_som(IFonc,aBox), IFonc, rect_som(IFonc,aBox,true), p0,p1 ); bench_op_buf_cat<REAL> ( (REAL *) 0, rect_som(RFonc,aBox), RFonc, rect_som(RFonc,aBox,true), p0,p1 ); bench_op_buf_cat<REAL> ( (REAL *) 0, rect_min(RFonc,aBox), RFonc, rect_min(RFonc,aBox,true), p0,p1 ); { Fonc_Num f2 = Virgule(IFonc,1-IFonc,FX*1-IFonc); bench_op_buf_cat<INT> ( (INT *) 0, rect_max(f2,aBox), f2, rect_max(f2,aBox,true), p0,p1 ); } { Fonc_Num RhoTeta = Virgule(Im1.in(0),Im2.in(0)); REAL Ouv = NRrandom3(); bool Oriented = (NRrandom3() > 0.5); REAL RhoCalc = 0.1 + 2.0*NRrandom3(); bench_op_buf_cat<REAL> ( (REAL *) 0, RMaxLocDir(RhoTeta,Ouv,Oriented,RhoCalc,false), RhoTeta, RMaxLocDir(RhoTeta,Ouv,Oriented,RhoCalc,true), p0,p1 ); } bench_op_buf_cat<INT> ( (INT *) 0, rect_median(IFonc,aBox,256), IFonc, rect_median(IFonc,aBox,256,true), p0,p1 ); { Fonc_Num f2 = Virgule(IFonc,mod(IFonc*FX*FY,256)); bench_op_buf_cat<INT> ( (INT *) 0, rect_median(f2,aBox,256), f2, rect_median(f2,aBox,256,true), p0,p1 ); } }
void cASAMG::ComputeSubset(int aNbPts,cResumNuage & aRN) { Video_Win * aW = mAppli->Param().VisuLowPts().Val() ? TheWinIm() : 0; double aSzCel = sqrt(double(mSz.x*mSz.y)/aNbPts); Pt2di aNb2C = round_up(Pt2dr(mSz)/aSzCel); Pt2di aPK; Im2D_U_INT1 anImDist(mSz.x,mSz.y); TIm2D<U_INT1,INT> aTDist(anImDist); ELISE_COPY(mMasqN.all_pts(),mMasqN.in(),anImDist.out()); Chamfer::d32.im_dist(anImDist); if (aW) { ELISE_COPY(anImDist.all_pts(),mStdN->ImDef().in()!=0,aW->odisc()); ELISE_COPY(select(anImDist.all_pts(),anImDist.in()>0),P8COL::blue,aW->odisc()); ELISE_COPY(select(anImDist.all_pts(),anImDist.in()>10),P8COL::yellow,aW->odisc()); } int aNbSomTot = 0; std::vector<Pt2di> aVPts; std::vector<int> aVNb; for (aPK.x=0 ; aPK.x<aNb2C.x ; aPK.x++) { Pt2di aP0,aP1; aP0.x = (aPK.x*mSz.x) / aNb2C.x; aP1.x = ((aPK.x+1)*mSz.x) / aNb2C.x; for (aPK.y=0 ; aPK.y<aNb2C.y ; aPK.y++) { aP0.y = (aPK.y*mSz.y) / aNb2C.y; aP1.y = ((aPK.y+1)*mSz.y) / aNb2C.y; Pt2di aP; Pt2dr aPMoy(0,0); int aNbSom=0; if (aW) { aW->draw_rect(Pt2dr(aP0),Pt2dr(aP1),Line_St(aW->pdisc()(P8COL::green))); } for (aP.x=aP0.x; aP.x<aP1.x ; aP.x++) { for (aP.y=aP0.y; aP.y<aP1.y ; aP.y++) { if (mTMasqN.get(aP)) { aPMoy = aPMoy + Pt2dr(aP); aNbSom++; } } } if (aNbSom>0) { aPMoy = aPMoy/double(aNbSom); double aDBest = 1e10; Pt2di aPBest(0,0); for (aP.x=aP0.x; aP.x<aP1.x ; aP.x++) { for (aP.y=aP0.y; aP.y<aP1.y ; aP.y++) { if (mTMasqN.get(aP)) { double aDist = euclid(Pt2dr(aP),aPMoy) - std::min(6,aTDist.get(aP))/1.8; if (aDist<aDBest) { aDBest = aDist; aPBest = aP; } } } } aVPts.push_back(aPBest); aVNb.push_back(aNbSom); /* cLinkPtFuNu aPF(aPBest.x,aPBest.y,aNbSom); aVPTR.push_back(aPF); */ aNbSomTot += aNbSom; if (aW) { aW->draw_circle_abs(Pt2dr(aPBest),3.0,aW->pdisc()(P8COL::red)); } } } } aRN.Reset(aVPts.size()); aRN.mNbSom = aNbSomTot; for (int aK=0 ; aK<int(aVPts.size()); aK++) { aRN.mVX.push_back(aVPts[aK].x); aRN.mVY.push_back(aVPts[aK].y); aRN.mVNb.push_back(aVNb[aK]); } if (aW) { // aW->clik_in(); } }
Pt2dr cElHomographie::Direct(const Pt2dr & aP) const { return Pt2dr(mHX(aP),mHY(aP))/ mHZ(aP); }
Pt3dr cElNuage3DMaille_FromImProf<Type,TBase>::Loc_PtOfIndex(const tIndex2D & anI) const { return Loc_IndexAndProf2Euclid(Pt2dr(anI),ProfOfIndex(anI)); }
Pt2dr CentreRand() {return Pt2dr(sz.x * NRrandom3(),sz.y * NRrandom3());}
cElNuage3DMaille * cElNuage3DMaille::FromParam ( const cXML_ParamNuage3DMaille & aParamOri, const std::string & aDir, const std::string & aMasqSpec, double ExagZ, const cParamModifGeomMTDNuage * aPMG, bool WithEmptyData ) { cXML_ParamNuage3DMaille aParam = aParamOri; Box2di aBox(Pt2di(0,0),aParam.NbPixel()); bool Dequant = false; if (aPMG) { double aScale = aPMG->mScale; if (aScale != 1.0) { std::string aMes = "Scale=" + ToString(aScale); cElWarning::ScaleInNuageFromP.AddWarn(aMes,__LINE__,__FILE__); } Pt2di aP0 = round_down(aPMG->mBox._p0/aScale); Pt2di aP1 = round_up(aPMG->mBox._p1/aScale); aBox = Inf(aBox,Box2di(aP0,aP1)); aParam.NbPixel() = aBox.sz(); ElAffin2D aAfM2C = Xml2EL(aParam.Orientation().OrIntImaM2C()); aAfM2C = ElAffin2D::trans(-Pt2dr(aBox._p0)) * aAfM2C; aParam.Orientation().OrIntImaM2C().SetVal(El2Xml(aAfM2C)); Dequant = aPMG->mDequant; } std::string aMasq = aDir+aParam.Image_Profondeur().Val().Masq(); if (aMasqSpec!="") aMasq = aMasqSpec; GenIm::type_el aTypeEl = GenIm::real4; Fonc_Num aFMasq = 0; Fonc_Num aFProf = 1; if (! WithEmptyData) { aFMasq = trans(Tiff_Im::BasicConvStd(aMasq).in(0),aBox._p0); Tiff_Im aTP = Tiff_Im::BasicConvStd(aDir+aParam.Image_Profondeur().Val().Image()); aFProf = trans(aTP.in_proj()*ExagZ,aBox._p0); aTypeEl = aTP.type_el(); } if (aParam.Image_Profondeur().IsInit()) { bool aFaiscClassik = ( (aParam.Image_Profondeur().Val().GeomRestit()==eGeomMNTFaisceauIm1PrCh_Px1D) || (aParam.Image_Profondeur().Val().GeomRestit()==eGeomMNTFaisceauIm1PrCh_Px2D) || (aParam.Image_Profondeur().Val().GeomRestit()==eGeomMNTEuclid) || (aParam.Image_Profondeur().Val().GeomRestit()==eGeomMNTFaisceauPrChSpherik) ); bool aProfIsZ = ( (aParam.Image_Profondeur().Val().GeomRestit()==eGeomMNTFaisceauIm1ZTerrain_Px1D) || (aParam.Image_Profondeur().Val().GeomRestit()==eGeomMNTFaisceauIm1ZTerrain_Px2D) ); if (aFaiscClassik || aProfIsZ) { switch (aTypeEl) { case GenIm::int2 : if (Dequant) return new cElN3D_EpipGen<float,double>(aDir,aParam,aFMasq,aFProf,aProfIsZ,WithEmptyData,true); else return new cElN3D_EpipGen<INT2,INT>(aDir,aParam,aFMasq,aFProf,aProfIsZ,WithEmptyData,false); break; case GenIm::real4 : return new cElN3D_EpipGen<float,double>(aDir,aParam,aFMasq,aFProf,aProfIsZ,WithEmptyData,false); break; default : std::cout << "NAME " << aDir+aParam.Image_Profondeur().Val().Image() << "\n"; ELISE_ASSERT(false,"Type Image non gere dans cElNuage3DMaille::FromParam"); break; } } } ELISE_ASSERT(false,"cElNuage3DMaille::FromParam"); return 0; }
void Test_DBL() { Pt2dr aP0(-10,-20); Pt2dr aP1(1500,2000); Pt2di aNb(10,15); cDistorBilin aDBL1(aP0,aP1,aNb); Box2dr aBoxRab1 = aDBL1.BoxRab(0.3); //====================================================== // Verif interpol/extrapol de fon lineaire est exacte //====================================================== for (int aTime=0 ; aTime<10000 ; aTime++) { double aF = pow(2.0,NRrandC()*8); Pt2dr aPP = Pt2dr(NRrandC(),NRrandC()) * aF; aDBL1.InitAffine(aF,aPP); for (int aK=0 ; aK<10; aK++) { Pt2dr aP0 = aBoxRab1.RandomlyGenereInside(); Pt2dr aP1 = aDBL1.Direct(aP0); Pt2dr aQ1 = aPP + aP0 * aF; double aDist = euclid(aP1,aQ1); if (aDist>1e-9) { ELISE_ASSERT(false,"Test_DBL Affine"); } } } //============================ // Test copy //============================ for (int aK=0 ; aK<10000 ; aK++) { aDBL1.Randomize(); cDistorBilin aDBL2 = aDBL1; Pt2dr aP0 = aBoxRab1.RandomlyGenereInside(); Pt2dr aP1 = aDBL1.Direct(aP0); Pt2dr aP2 = aDBL2.Direct(aP0); double aDist = euclid(aP1,aP2); ELISE_ASSERT(aDist==0,"Test_DBL dist"); } //============================ // V_SetScalingTranslate //============================ for (int aTime=0 ; aTime<10000 ; aTime++) { double aF = pow(2.0,NRrandC()*8); Pt2dr aPP = Pt2dr(NRrandC(),NRrandC()) * aF; aDBL1.Randomize(); cDistorBilin aDBL2 = aDBL1; aDBL2.V_SetScalingTranslate(aF,aPP); Box2dr aBoxRab2 = aDBL2.BoxRab(0.3); for (int aK=0 ; aK<10; aK++) { Pt2dr aP0 = aBoxRab2.RandomlyGenereInside(); Pt2dr aP2 = aDBL2.Direct(aP0); Pt2dr aP1 = (aDBL1.Direct(aPP+aP0*aF)-aPP) /aF; double aDist = euclid(aP1 - aP2); ELISE_ASSERT(aDist<1e-9,"DBL-setScalingTranslate"); } } //============================ // Verif Inverse //============================ for (int aTime=0 ; aTime<100000 ; aTime++) { aDBL1.Randomize(0.01); for (int aK=0 ; aK<10; aK++) { Pt2dr aP0 = aBoxRab1.RandomlyGenereInside(); Pt2dr aP1 = aDBL1.Direct(aP0); Pt2dr aP2 = aDBL1.Inverse(aP1); double aDist = euclid(aP0 - aP2); // std::cout << "D= " << aDist << "\n"; ELISE_ASSERT(aDist<1e-5,"DBL-setScalingTranslate"); } } /* */ std::cout << "DONE Test cDistorBilin\n"; }
PS_Window PS_Display::w_centered_max(Pt2di sz,Pt2dr margin) { Box2dr b = depsd()->box_all_w(Pt2dr(sz),margin,Pt2di(1,1),Pt2dr(0.0,0.0)); return PS_Window(*this,sz,b._p0,b._p1); }
void cParamIntrinsequeFormel::AddCstrRegulDist(Pt2dr aP,double aPdsVal,double aPdsGrad,double aPdsD2) { InitStateOfFoncteur(mFER_Val,0); InitStateOfFoncteur(mFER_Dx,0); InitStateOfFoncteur(mFER_DxDy,0); InitStateOfFoncteur(mFER_Dxx,0); bool Show = false; // Val std::vector<double> aVPv(2,aPdsVal); mRegulDistValP1->SetEtat(aP); mRegulDistKnownVal->SetEtat(aP); std::vector<double> aRes; aRes = mSet.VAddEqFonctToSys(mFER_Val,aVPv,false); double aEps = CurFocale() / 50.0; // Grad std::vector<double> aVPGrad(2,aPdsGrad/(2.0*ElSquare(aEps))); // x mRegulDistDxP1->SetEtat(aP+Pt2dr( aEps,0)); mRegulDistDxP2->SetEtat(aP+Pt2dr(-aEps,0)); mRegulDistKnownDer->SetEtat(Pt2dr(2*aEps,0)); aRes = mSet.VAddEqFonctToSys(mFER_Dx,aVPGrad,false); // y mRegulDistDxP1->SetEtat(aP+Pt2dr(0, aEps)); mRegulDistDxP2->SetEtat(aP+Pt2dr(0,-aEps)); mRegulDistKnownDer->SetEtat(Pt2dr(0,2*aEps)); aRes = mSet.VAddEqFonctToSys(mFER_Dx,aVPGrad,false); if (Show) std::cout << aRes.size() << "GG " << aRes[0]/aEps << " " << aRes[1]/aEps << "\n"; // Deriv sec std::vector<double> aVPCourb(2,aPdsD2/ElSquare(aEps*aEps)); // xx P1 + P2 - 2* P3 mRegulDistDxxP1->SetEtat(aP+Pt2dr( aEps,0)); mRegulDistDxxP2->SetEtat(aP+Pt2dr(-aEps,0)); mRegulDistDxxP3->SetEtat(aP); aRes= mSet.VAddEqFonctToSys(mFER_Dxx,aVPCourb,false); if (Show) std::cout << aRes.size() << "Dxxxx " << aRes[0]/ElSquare(aEps) << " " << aRes[1]/ElSquare(aEps) << "\n"; // yy mRegulDistDxxP1->SetEtat(aP+Pt2dr(0, aEps)); mRegulDistDxxP2->SetEtat(aP+Pt2dr(0,-aEps)); mRegulDistDxxP3->SetEtat(aP); aRes = mSet.VAddEqFonctToSys(mFER_Dxx,aVPCourb,false); if (Show) std::cout << aRes.size() << "Dyyy " << aRes[0]/ElSquare(aEps) << " " << aRes[1]/ElSquare(aEps) << "\n"; // yy mRegulDistDxyP1->SetEtat(aP+Pt2dr( aEps, aEps)); mRegulDistDxyP2->SetEtat(aP+Pt2dr(-aEps,-aEps)); mRegulDistDxyP3->SetEtat(aP+Pt2dr(-aEps, aEps)); mRegulDistDxyP4->SetEtat(aP+Pt2dr( aEps,-aEps)); aRes = mSet.VAddEqFonctToSys(mFER_DxDy,aVPCourb,false); if (Show) std::cout << aRes.size() << "DXXYY " << aRes[0]/ElSquare(aEps) << " " << aRes[1]/ElSquare(aEps) << "\n"; }
Pt3dr cPushB_PhysMod::Rough_GroundSpeed(double anY) const { double XMil = mSz.x / 2.0; return RoughPtIm2GeoC_Init(Pt2dr(XMil,anY+0.5)) - RoughPtIm2GeoC_Init(Pt2dr(XMil,anY-0.5)); }
void cOctaveDigeo::SetBoxInOut(const Box2di & aBoxIn,const Box2di & aBoxOut) { mBoxCurIn = Box2dr(Pt2dr(aBoxIn._p0)/mNiv,Pt2dr(aBoxIn._p1)/mNiv); mBoxCurOut = Box2di(aBoxOut._p0/mNiv,aBoxOut._p1/mNiv); }
Video_Win Video_Win::WStd(Pt2di sz,REAL zoom,Video_Win Soeur,bool SetClikCoord) { Video_Win W (Soeur.disp(),Soeur.sop(),Pt2di(50,50),Pt2di(Pt2dr(sz)*zoom)); return W.chc(Pt2dr(-0.5,-0.5),Pt2dr(zoom,zoom),SetClikCoord); }