void ElImplemDequantifier::Test() { INT Z=2; Pt2di aSZ = mSzReel - Pt2di(2,2); Video_Win aW = Video_Win::WStd(aSZ,Z); aW.set_title("Image Quant"); Video_Win aW2 = Video_Win::WStd(aSZ,Z); Video_Win aW3 = Video_Win::WStd(aSZ,Z); Video_Win aW4 = Video_Win::WStd(aSZ,Z); aW2.set_title("Deq"); aW3.set_title("Deq+Cuv"); aW4.set_title("FRELLE"); Fonc_Num aFR = sin(FX/20.0) * sin(FY/20.0) * 3 + FX/70.0; // aFR = 5 * (1- (Square(FX-aSZ.x/2)+Square(FY-aSZ.y/2))/square_euclid(aSZ/2)); Fonc_Num aFonc = round_ni (aFR); Fonc_Num aBase = 0;// aFonc; REAL Ampl = 90.0; ELISE_COPY(aW.all_pts(),(aFonc -aBase)*Ampl,aW.ocirc()); DoDequantif(aSZ,aFonc,true); ELISE_COPY ( aW2.all_pts(), (ImDeqReelle()-aBase)*Ampl, aW2.ocirc()); SetTraitSpecialCuv(true); DoDequantif(aSZ,aFonc,true); ELISE_COPY ( aW3.all_pts(), (ImDeqReelle()-aBase)*Ampl, aW3.ocirc()); ELISE_COPY ( aW4.all_pts(), (aFR-aBase)*Ampl, aW4.ocirc()); /* Video_Win aW4 = Video_Win::WStd(aSZ,Z); ELISE_COPY ( aW3.all_pts(), Moy(Moy( aF.in(0),3),3) *Ampl, aW3.ocirc() ); ELISE_COPY ( aW3.all_pts(), Moy(Moy( ImDeqReelle(),3),3) *Ampl, aW4.ocirc() ); */ while(1) getchar(); }
void cASAMG::TestDifProf(const cASAMG & aNE) const { Im2D_REAL4 aImDif(mSz.x,mSz.y,1000); TIm2D<REAL4,REAL8> aTDif(aImDif); Pt2di anIndex; for (anIndex.x=0 ; anIndex.x <mSz.x ; anIndex.x++) { for (anIndex.y=0 ; anIndex.y <mSz.y ; anIndex.y++) { if (mTMasqN.get(anIndex)) { Pt3dr aPE = mStdN->PtOfIndex(anIndex); aTDif.oset(anIndex,aNE.SignedDifProf(aPE)); } } } Video_Win * aW = TheWinIm(); if (aW) { ELISE_COPY ( aImDif.all_pts(), Min(255,Abs(aImDif.in()*300)), aW->ogray() ); aW->clik_in(); } }
cCaseNamePoint * cX11_Interface::GetIndexNamePoint() { Video_Win aW = mMenuNamePoint->W(); aW.raise(); for (int aK=0 ; aK<int(mVNameCase.size()) ; aK++) { int aGr = (aK%2) ? 255 : 200 ; Pt2di aPCase(0,aK); mMenuNamePoint->ColorieCase(aPCase,aW.prgb()(aGr,aGr,aGr),1); cCaseNamePoint & aCNP = mVNameCase[aK]; mMenuNamePoint->StringCase(aPCase,aCNP.mFree ? aCNP.mName : "***" ,true); } Clik aClk = aW.clik_in(); //aW.lower(); Pt2di aKse = mMenuNamePoint->Pt2Case(Pt2di(aClk._pt)); cCaseNamePoint * aRes = &(mVNameCase[aKse.y]); //cout << aRes->mName << " Type " << aRes->mTCP << endl; if (! aRes->mFree) return 0; return aRes; }
void cElHJaFacette::Show(REAL aDirH,INT aCoul,bool WithBox) { Video_Win aW = *(mPlan->W()); aW.hach(mVPt,Pt2dr::FromPolar(1.0,aDirH),3.0,aW.pdisc()(aCoul)); if (WithBox) { aW.draw_rect(mBox._p0,mBox._p1,aW.pdisc()(aCoul)); } }
Video_Win Video_Win::WStd(Pt2di sz,REAL zoom,bool all_pal,bool SetClikCoord) { Video_Win * aPW = PtrWStd(Pt2di(Pt2dr(sz)*zoom),all_pal); Video_Win aRes = aPW->chc(Pt2dr(-0.5,-0.5),Pt2dr(zoom,zoom),SetClikCoord); delete aPW; return aRes; }
void cAppliOptimTriplet::ShowPoint(cImOfTriplet * aIm,Pt2df aP,int aCoul,int aRay) { Video_Win * aW = aIm->W(); if (aW) { Pt2dr aPr(aP.x,aP.y); aPr = aIm->Im()->CS()->R3toF2(PZ1(aPr)); aW->draw_circle_abs(aPr,aRay,Line_St(aW->pdisc()(aCoul))); } }
Output Video_Win::WiewAv(Pt2di sz,Pt2di szmax) { REAL zoom = ElMin(szmax.x/(REAL)sz.x,szmax.y/(REAL)sz.y); Video_Win res = WStd(sz,zoom,false); Video_Win w0 = res.chc(Pt2dr(0,0),Pt2dr(1,1)); ELISE_COPY(w0.all_pts(),P8COL::black,w0.odisc()); return res.odisc() << (int) P8COL::red; }
void cEtalonnage::TestVisuFTM() { INT aSzPh = 4100; INT aSz = 800; REAL aZ = aSz / REAL(aSzPh); Video_Win aW = Video_Win::WStd(Pt2di(aSzPh,aSzPh),aZ); std::vector<std::string> mVNames = mParam.AllImagesCibles(); for ( std::vector<string>::const_iterator iTN = mVNames.begin(); iTN != mVNames.end(); iTN++ ) { std::string aName = NamePointeResult(*iTN,false,true); cout << aName << "\n"; ELISE_fp aFile(aName.c_str(),ELISE_fp::READ); string buf; bool GotEOF = false; while (! GotEOF) { //aFile.fgets(buf,NbBuf,GotEOF,false); aFile.fgets(buf,GotEOF); if (GotEOF) { } if ((!GotEOF) && (buf[0] != '#')) { INT anId; REAL anX,anY,aL; sscanf(buf.c_str(),"%d %lf %lf %lf",&anId,&anX,&anY,&aL); if (anId>=0) { INT aCoul = P8COL::red; if (aL > 1.0) aCoul = P8COL::blue; if (aL > 1.5) aCoul = P8COL::green; aW.draw_circle_abs ( Pt2dr(anX,anY), aL*10.0, aW.pdisc()(aCoul) ); } } } } getchar(); }
void VisuParalx(Video_Win aW,Fonc_Num f,REAL & aV0,REAL & aV1,bool CalcV) { if (CalcV) ELISE_COPY ( aW.all_pts(),Rconv(f),VMin(aV0) | VMax(aV1)); ELISE_COPY ( aW.all_pts(), AUC(round_ni((f-aV0) * (255.0/(aV1-aV0)))), aW.ogray() ); }
void PutFileText(Video_Win aW,const std::string & aName) { ELISE_fp aFile (aName.c_str(),ELISE_fp::READ); int aCpt=0; char * aCstr = 0; while ((aCstr = aFile.std_fgets())) { aW.fixed_string(Pt2dr(10,15*aCpt +20),aCstr,aW.pdisc()(P8COL::black),true); aCpt++; } aFile.close(); }
void BenchRoy() { REAL aV0,aV1; INT ParMin = -25; INT ParMax = 25; Pt2di aP0 =ImCox ? Pt2di(350,300) :Pt2di(20,20); Pt2di aP1 =ImCox ? Pt2di(470,450) :Pt2di(SzI.x-20,SzI.y-20); Im2D_U_INT1 aI2 = Im1(); Im2D_REAL4 XPar = XParalaxe(); Im2D_U_INT1 aI1 = Im2(aI2,XPar); // Revert(aI2); Revert(aI1); if (Visu) { Video_Win aWParX = Video_Win::WStd(aI1.sz(),1); aWParX.set_title("ParX Vraie"); VisuParalx(aWParX,XPar.in(),aV0,aV1,true); } Im2D_INT2 aRes = TestCoxRoy ( 2, aI1, aI2, aP0, aP1, ParMin, ParMax ); if (Visu) { Fonc_Num FRes = trans(aRes.in(0),-aP0); Video_Win aWParX = Video_Win::WStd(aI1.sz(),1); aWParX.set_title("ParX Calc"); VisuParalx(aWParX,FRes,aV0,aV1,false); } }
void cX11_Interface::DrawZoom(const Pt2dr & aPGlob) { double aZoom = 10.0; Pt2dr aPIm = aPGlob- Pt2dr(mAppli->DecRech()); Pt2dr aPMil = Pt2dr(mWZ->sz())/(2.0*aZoom); Video_Win aWC = mWZ->chc(aPIm-aPMil,Pt2dr(aZoom,aZoom)); ELISE_COPY ( aWC.all_pts(), mAppli->ImRechVisu().in(0), aWC.ogray() ); aWC.draw_circle_abs(aPIm,4.0,Line_St(aWC.pdisc()(P8COL::blue),3.0)); }
void bench_delaunay() { Pt2di sz (950,950); Disc_Pal Pdisc = Disc_Pal::P8COL(); Elise_Set_Of_Palette SOP(NewLElPal(Pdisc)); Video_Display Ecr((char *) NULL); Ecr.load(SOP); Video_Win W (Ecr,SOP,Pt2di(50,50),sz); for (INT nb = 100; nb < 500 ; nb +=50) { std::list<PtDelTest> L; ElFilo<PtDelTest> Pts; for (INT k= 0; k< nb; k++) { PtDelTest pt ( (INT)( 10 + (sz.x -20) * NRrandom3()), (INT)( 10 + (sz.y -20) * NRrandom3()) ); // Pts.pushlast(pt); L.push_back(pt); //W.draw_circle_loc(pt.pt(),4,Pdisc(P8COL::red)); W.draw_circle_loc(Pt2dr(pt.pt()),4,Pdisc(P8COL::red)); // __NEW } DelTestAct Act(W); Delaunay_Mediatrice ( L.begin(), L.end(), Pt_of_DPT, Act, 200.0, (PtDelTest *) 0 ); // W.clik_in(); W.clear(); } }
Video_Win * Video_Win::PtrWStd(Pt2di sz,bool all_pal,const Pt2dr & aScale) { Disc_Pal Pdisc = Disc_Pal::PNCOL(); Gray_Pal Pgr (30); Circ_Pal Pcirc = Circ_Pal::PCIRC6(30); RGB_Pal Prgb (2,2,2); Elise_Set_Of_Palette SOP(NewLElPal(Pdisc)+Elise_Palette(Pgr)+Elise_Palette(Prgb)+Elise_Palette(Pcirc)); if (! all_pal) SOP = Elise_Set_Of_Palette (NewLElPal(Pdisc)); Video_Display Ecr((char *) NULL); Ecr.load(SOP); Video_Win * aRes = new Video_Win (Ecr,SOP,Pt2di(50,50),sz); aRes = aRes->PtrChc(Pt2dr(0,0),aScale); return aRes; }
void cICL_Courbe::AddSeg ( Pt2dr P0, bool isP0OnCerle, Pt2dr P1, bool isP1OnCerle ) { if (pW) { pW->draw_arrow ( ToLoc(P0), ToLoc(P1), Line_St(pW->pdisc()(P8COL::blue),2), Line_St(pW->pdisc()(P8COL::blue),2), 10.0 ); pW->draw_circle_loc ( ToLoc(P0), 5.0, pW->pdisc()(isP0OnCerle?P8COL::yellow : P8COL::green) ); pW->draw_circle_loc ( ToLoc(P1), 5.0, pW->pdisc()(isP1OnCerle?P8COL::yellow : P8COL::green) ); } mVArcs.push_back(cICL_Arc(P0,isP0OnCerle,P1,isP1OnCerle)); }
void ShowIm2(Im2D_INT2 aZ,Video_Win aW) { INT zMax,zMin; ELISE_COPY(aZ.all_pts(),aZ.in(),VMax(zMax)|VMin(zMin)); cout << "Z = [" << zMin << " , " << zMax << "]\n"; ELISE_COPY ( aZ.all_pts(), Max(0,Min(255,aZ.in())), // (aZ.in()-zMin) * (255.0/(zMax-zMin)), aW.ogray() ); }
void TestXmlX11() { Video_Win aW = Video_Win::WStd(Pt2di(700,800),1.0); cElXMLTree aFullTreeParam("EnvVino.xml"); cWXXVinoSelector aSelector("FXDiv10.tif"); cElXMLTree aFilter("FilterVino.xml"); cWindowXmlEditor aWX(aW,true,aFullTreeParam.Fils().front(),&aSelector,&aFilter); // cWXXTreeSelector aSelId; aWX.TopDraw(); aWX.Interact(); aW.clear(); aW.clik_in(); aWX.TopDraw(); aWX.Interact(); aFullTreeParam.StdShow("SORTIE.xml"); }
void lena_for_ever() { Video_Display Ecr((char *) NULL); Gray_Pal Pgray (30); Disc_Pal Pdisc = Disc_Pal::P8COL(); Elise_Set_Of_Palette SOP(newl(Pgray)+Pdisc); Ecr.load(SOP); Video_Win W (Ecr,SOP,Pt2di(50,50),Pt2di(SZX,SZY)); Elise_File_Im FLena("../IM_ELISE/lena",2,SXY,GenIm::u_int1,1,0); Im2D_U_INT1 I(SZX,SZY); ELISE_COPY ( W.all_pts(), FLena.in(), W.ogray() | I.out() ); bench_dilate_simple(W,I); bench_zonec_simple(W,I); }
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(); } }
std::vector<Pt2dr> cICL_Courbe::GetPoly(INT NbPtsMax,bool ForceLosange) { ELISE_ASSERT(pW!=0,"cICL_Courbe::GetPoly()"); static bool First = true; if (! First) pW->clik_in(); First = false; pW->clear(); pW->draw_circle_loc ( ToLoc(Pt2dr(0,0)), mScale, pW->pdisc()(P8COL::red) ); std::vector<Pt2dr> aRes; while (true) { Clik aCl = pW->clik_in(); Pt2dr aP = (Pt2dr(aCl._pt)-mP0) / mScale; if (NbPtsMax-1 == INT(aRes.size())) aCl._b = 3; if (ForceLosange && (aRes.size()==3)) { aP = aRes[0]+ aRes[2] - aRes[1]; aCl._b = 3; } pW->draw_circle_loc(ToLoc(aP),3.0,pW->pdisc()(P8COL::green)); if (! aRes.empty()) pW->draw_seg(ToLoc(aRes.back()),ToLoc(aP),pW->pdisc()(P8COL::green)); aRes.push_back(aP); if (aCl._b == 3) { pW->draw_seg(ToLoc(aRes[0]),ToLoc(aP),pW->pdisc()(P8COL::green)); return aRes; } } return aRes; }
void cImOfTriplet::InitW(const Pt2dr & aSzMax) { mW = new Video_Win (Video_Win::LoadTiffWSzMax(mIm->Name(),aSzMax,mZoomW)); mW->set_title(mIm->Name().c_str()); }
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()); }
void cElHJaPlan3D::Show ( Video_Win aW, INT aCoul, bool ShowDroite, bool ShowInterEmpr ) { if (aCoul >=0) ELISE_COPY(aW.all_pts(),aCoul,aW.ogray()); Box2dr aBoxW(Pt2dr(0,0),Pt2dr(aW.sz())); for (INT aK=0; aK<INT(mVInters.size()) ; aK++) { cElHJaDroite * aDr =mVInters[aK]; if (aDr) { ElSeg3D aSeg = aDr->Droite(); Pt3dr aQ0 = aSeg.P0(); Pt3dr aQ1 = aSeg.P1(); Pt2dr aP0(aQ0.x,aQ0.y); Pt2dr aP1(aQ1.x,aQ1.y); Seg2d aS(aP0,aP1); Seg2d aSC = aS.clipDroite(aBoxW); if (ShowDroite && (! aSC.empty())) { aW.draw_seg(aSC.p0(),aSC.p1(),aW.pdisc()(P8COL::magenta)); } } } tFullSubGrPl aSGrFul; if (ShowInterEmpr) { for (tItSomGrPl itS=mGr->begin(aSGrFul) ; itS.go_on() ; itS++) { aW.draw_circle_loc ( (*itS).attr().Pt(), 4.0, aW.pdisc()(P8COL::blue) ); for (tItArcGrPl itA=(*itS).begin(aSGrFul) ; itA.go_on() ; itA++) { tSomGrPl &s1 = (*itA).s1(); tSomGrPl &s2 = (*itA).s2(); if (&s1 < &s2) { aW.draw_seg ( s1.attr().Pt(), s2.attr().Pt(), aW.pdisc()(P8COL::black) ); } } } } // for (INT aK=0 ; aK<INT(mFacOblig.size()) ; aK++) // mFacOblig[aK]->Show(PI/2.0,P8COL::cyan,false); }
void VisuGray(Video_Win aW,Fonc_Num aFonc) { REAL aMax,aMin; ELISE_COPY(aW.all_pts(),Rconv(aFonc),VMax(aMax)|VMin(aMin)); ELISE_COPY(aW.all_pts(),(aFonc-aMin)*255.0/(aMax-aMin),aW.ogray()); }
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); }
void cElHJaFacette::ShowCont(INT aCoul,Video_Win aW) { INT aNb = (int) mVPt.size(); for (INT aK=0 ; aK<aNb ; aK++) aW.draw_seg(mVPt[aK],mVPt[(aK+1)%aNb],aW.pdisc()(aCoul)); }
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 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 FiltreRemoveBorderHeter(Im2D_REAL4 anIm,Im2D_U_INT1 aImMasq,double aCostRegul,double aCostTrans) { Pt2di aSz = anIm.sz(); double aVMax,aVMin; ELISE_COPY(aImMasq.border(1),0,aImMasq.out()); ELISE_COPY(aImMasq.all_pts(),aImMasq.in()!=0,aImMasq.out()); ELISE_COPY(anIm.all_pts(),anIm.in(),VMax(aVMax)|VMin(aVMin)); Video_Win * aW = Video_Win::PtrWStd(aSz); ELISE_COPY(anIm.all_pts(),(anIm.in()-aVMin) * (255.0/(aVMax-aVMin)),aW->ogray()); std::cout << "VMAX " << aVMax << "\n"; //ELISE_COPY(aW->all_pts(),aImMasq.in(),aW->odisc()); //aW->clik_in(); ELISE_COPY ( aW->all_pts(), nflag_close_sym(flag_front8(aImMasq.in_proj()!=0)), aW->out_graph(Line_St(aW->pdisc()(P8COL::red))) ); cParamFiltreDepthByPrgDyn aParam = StdGetFromSI(Basic_XML_MM_File("DefFiltrPrgDyn.xml"),ParamFiltreDepthByPrgDyn); aParam.CostTrans() = aCostTrans; aParam.CostRegul() = aCostRegul; Im2D_Bits<1> aNewMasq = FiltrageDepthByProgDyn(anIm,aImMasq,aParam); ELISE_COPY ( select(aNewMasq.all_pts(),aNewMasq.in()), 2, aImMasq.out() ); TIm2D<U_INT1,INT> aTMasq(aImMasq); FiltrageCardCC(false,aTMasq,2,0,100); Neighbourhood aNV4=Neighbourhood::v4(); Neigh_Rel aNrV4 (aNV4); ELISE_COPY ( conc ( select(select(aImMasq.all_pts(),aImMasq.in()==1),aNrV4.red_sum(aImMasq.in()==0)), aImMasq.neigh_test_and_set(aNV4,1,0,256) ), 3, Output::onul() ); ELISE_COPY ( aNewMasq.all_pts(), aImMasq.in(), aW->odisc() ); /* ELISE_COPY ( aW->all_pts(), nflag_close_sym(flag_front8(aNewMasq.in_proj())), aW->out_graph(Line_St(aW->pdisc()(P8COL::green))) ); */ aW->clik_in(); }
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; }