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)); }
Box2di cWindowXmlEditor::PrintTag(Pt2di aP0,cElXMLTree * aTree,int aMode,int aLevel,cElXMLTree * aFilter) { if ((!mXmlMode) && (aMode!=0)) return Box2di(aP0-Pt2di(0,1),aP0-Pt2di(0,1)); std::string aTag = ((aMode == -1) ? "</" : "<") + aTree->ValTag() + ((aMode==0) ? "/>" : ">"); if (!mXmlMode) aTag = " " + aTree->ValTag() + " : "; Pt2di aSz = mW.SizeFixedString(aTag); Pt2di aP1 = aP0 + aSz; mW.fill_rect(Pt2dr(aP0)-Pt2dr(1,1),Pt2dr(aP1)+Pt2dr(1,1),mW.pgray()(mGrayTag)); if (aMode!=0) mW.draw_rect(Pt2dr(aP0)-Pt2dr(2,2),Pt2dr(aP1)+Pt2dr(2,2),Line_St(mW.pdisc()(P8COL::blue),2)); mW.fixed_string(Pt2dr(aP0)+Pt2dr(0,aSz.y), aTag.c_str(),mW.pdisc()(P8COL::black),false); Box2di aRes (aP0-mPRab,aP1+ mPRab); if ((aMode ==0) && mFirstDraw) { Pt2di aQ0 (aP0.x+aSz.x+5,aP0.y-4); Pt2di aQ1 (EndXOfLevel(aLevel)-5,aP0.y+aSz.y+4); mVCase.push_back(cCaseX11Xml::Alloc(mW,Box2di(aQ0,aQ1),P8COL::yellow)); mVInfoCase.push_back(cWXXInfoCase(aTree,aFilter)); } 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))); } }
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 cMMTP::ContAndBoucheTrou() { int aDist32Close = 6; int aNbErod = 6; // 1- Quelques fitre morpho de base, pour calculer les points eligibles au bouche-trou int aLabelOut = 0; //int aLabelIn = 1; int aLabelClose = 2; int aLabelFront = 3; ELISE_COPY(mImMasqInit.all_pts(),mImMasqInit.in(),mImLabel.out()); ELISE_COPY(mImLabel.border(2),aLabelOut,mImLabel.out()); // 1.1 calcul des point dans le fermeture ELISE_COPY ( select ( mImLabel.all_pts(), close_32(mImLabel.in(0),aDist32Close) && (mImLabel.in()==aLabelOut) ), aLabelClose, mImLabel.out() ); ELISE_COPY(mImLabel.border(2),aLabelOut,mImLabel.out()); // 1.2 erosion de ces points Neighbourhood V4 = Neighbourhood::v4(); Neighbourhood V8 = Neighbourhood::v8(); Neigh_Rel aRelV4(V4); Liste_Pts_U_INT2 aLFront(2); ELISE_COPY ( select ( mImLabel.all_pts(), (mImLabel.in(0)==aLabelClose) && (aRelV4.red_max(mImLabel.in(0)==aLabelOut)) ), aLabelFront, mImLabel.out() | aLFront ); for (int aK=0 ; aK<aNbErod ; aK++) { Liste_Pts_U_INT2 aLNew(2); ELISE_COPY ( dilate ( aLFront.all_pts(), mImLabel.neigh_test_and_set(Neighbourhood::v4(),2,3,20) ), aLabelFront, aLNew ); aLFront = aLNew; } ELISE_COPY(select(mImLabel.all_pts(),mImLabel.in()==aLabelFront),0,mImLabel.out()); // Au cas ou on ferait un export premature ELISE_COPY(mImMasqFinal.all_pts(),mImLabel.in()!=0,mImMasqFinal.out()); int aSomMaskF; ELISE_COPY(mImMasqFinal.all_pts(),mImLabel.in()==1,sigma(aSomMaskF)); if (aSomMaskF < 100) return; // std::cout << "aSomMaskFaSomMaskF " << aSomMaskF << "\n"; // 2- Dequantifiication, adaptee au image a trou Im2D_REAL4 aProfCont(mSzTiep.x,mSzTiep.y,0.0); { Im2D_INT2 aPPV = BouchePPV(mImProf,mImLabel.in()==1); ElImplemDequantifier aDeq(mSzTiep); aDeq.DoDequantif(mSzTiep,aPPV.in()); ELISE_COPY(aProfCont.all_pts(),aDeq.ImDeqReelle(),aProfCont.out()); ELISE_COPY(select(aProfCont.all_pts(),mImLabel.in()!=1),0,aProfCont.out()); } //Im2D_REAL4 aImInterp(mSzTiep.x,mSzTiep.y); TIm2D<REAL4,REAL8> aTInterp(mContBT); // 3- Bouchage "fin" des trour par moinde L2 // 3.1 Valeur initial // Filtrage gaussien Fonc_Num aFMasq = (mImLabel.in(0)==1); Fonc_Num aFProf = (aProfCont.in(0) * aFMasq); for (int aK=0 ; aK<3 ; aK++) { aFMasq = rect_som(aFMasq,1) /9.0; aFProf = rect_som(aFProf,1) /9.0; } ELISE_COPY ( mContBT.all_pts(), aFProf / Max(aFMasq,1e-9), mContBT.out() ); // On remet la valeur init au point ayant un valeur propre ELISE_COPY ( select(mContBT.all_pts(),mImLabel.in()==1), aProfCont.in(), mContBT.out() ); // Et rien en dehors de l'image ELISE_COPY ( select(mContBT.all_pts(),mImLabel.in()==0), 0, mContBT.out() ); // 3.2 Iteration pour regulariser les points interpoles { std::vector<Pt2di> aVInterp; { Pt2di aP; for (aP.x=0 ; aP.x<mSzTiep.x ; aP.x++) { for (aP.y=0 ; aP.y<mSzTiep.y ; aP.y++) { if (mTLab.get(aP)==aLabelClose) aVInterp.push_back(aP); } } } for (int aKIter=0 ; aKIter<20 ; aKIter++) { std::vector<double> aVVals; for (int aKP=0 ; aKP<int(aVInterp.size()) ; aKP++) { double aSom=0; double aSomPds = 0; Pt2di aPK = aVInterp[aKP]; for (int aKV=0 ; aKV<9 ; aKV++) { Pt2di aVois = aPK+TAB_9_NEIGH[aKV]; if (mTLab.get(aVois)!=0) { int aPds = PdsGaussl9NEIGH[aKV]; aSom += aTInterp.get(aVois) * aPds; aSomPds += aPds; } } ELISE_ASSERT(aSomPds!=0,"Assert P!=0"); aVVals.push_back(aSom/aSomPds); } for (int aKP=0 ; aKP<int(aVInterp.size()) ; aKP++) { aTInterp.oset(aVInterp[aKP],aVVals[aKP]); } } } /* */ #ifdef ELISE_X11 if(0 && TheWTiePCor) { ELISE_COPY ( mImLabel.all_pts(), mContBT.in()*7, TheWTiePCor->ocirc() ); TheWTiePCor->clik_in(); ELISE_COPY ( mImLabel.all_pts(), nflag_close_sym(flag_front4(mImLabel.in(0)==1)), TheWTiePCor->out_graph(Line_St(TheWTiePCor->pdisc()(P8COL::black))) ); TheWTiePCor->clik_in(); ELISE_COPY ( mImLabel.all_pts(), mImLabel.in(0), TheWTiePCor->odisc() ); TheWTiePCor->clik_in(); ELISE_COPY ( mImLabel.all_pts(), mImMasqFinal.in(0), TheWTiePCor->odisc() ); TheWTiePCor->clik_in(); } #endif }
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(); }
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(); } }