示例#1
0
void Revert(Im2D_U_INT1  anIm)
{ 

     for (INT y=0; y<anIm.ty() ; y++)
         for (INT x1=0,x2 =anIm.tx()-1; x1<x2 ;x1++,x2-- )
	     ElSwap(anIm.data()[y][x1],anIm.data()[y][x2]);
}
void  EHFS_ScoreGrad::MakeImGradRhoTeta
      ( 
           Im2D_U_INT1 OutRho, 
           Im2D_U_INT1 OutTeta,
           Im2D_INT1   InPutGx, 
           Im2D_INT1   InPutGy,
           INT1 def
      )
{
    VerifSize(OutRho);
    VerifSize(OutTeta);
    MakeImGradXY(mImLocGX,mImLocGY,InPutGx,InPutGy,def);

    U_INT1 ** dRho  = OutRho.data();
    U_INT1 ** dTeta = OutTeta.data();
    INT1 **   dGx   = mImLocGX.data();
    INT1 **   dGy   = mImLocGY.data();

    for (INT y=0; y<= 2* mNbYMax ; y++)
        for (INT x=0; x<=mNbX ; x++)
        {
            Pt2dr rt = Pt2dr::polar(Pt2dr(dGx[y][x],dGy[y][x]),PI); 
            dRho[y][x] = ElMin(255,round_ni(rt.x));
            dTeta[y][x] =  mod(round_ni(rt.y*128.0/PI),256);
        }
}
示例#3
0
文件: b_0_36.cpp 项目: jakexie/micmac
       static bool verif_equal(Im2D_U_INT1 Im1,Im2D_U_INT1 Im2)
       {
           INT Dif;

           ELISE_COPY(Im1.all_pts(),Abs(Im1.in()-Im2.in()),sigma(Dif));
           BENCH_ASSERT(Dif==0);
           return Dif == 0;
       }
示例#4
0
void bench_i1_eq_i2(Im2D_U_INT1 i1,Im2D_U_INT1 i2)
{
    INT nb_dif;

    ELISE_COPY(i1.all_pts(),Abs(i1.in()-i2.in()),sigma(nb_dif));

    BENCH_ASSERT(nb_dif ==0);
}
示例#5
0
void  CalcMaxLoc<Type,TypeBase,Compare>::FiltrMaxLoc_BCVS
      (
          ElSTDNS vector<Pt2di> & Pts,
          Im2D<Type,TypeBase> Im,
          REAL  FactInf,
          REAL  TolGeom,
          Pt2di SzVois,
          Im2D_U_INT1 Marq
      )
{
    Pt2di SzIm = Inf(Im.sz(),Marq.sz());
    Box2di BoxIm(Pt2di(0,0),SzIm);

    Marq.raz();
    mBufFiltr.clear();


    INT4 ** dIm = Im.data();

    for (INT kp1=0; kp1<(INT)Pts.size() ; kp1++)
    {
        ELISE_ASSERT
        (
           BoxIm.contains(Pts[kp1]),
           "GenMaxLoc::FiltrMaxLoc_BCVS"
        );
    }
    
	{
    for (INT kp1=0; kp1<(INT)Pts.size() ; kp1++)
    {
        Pt2di p1 = Pts[kp1];
        Box2di BoxP1(p1-SzVois,p1+SzVois);
        INT v1 = dIm[p1.y][p1.x];
        INT Vinf = round_up(v1*FactInf);
        bool Refut = false;
   

        for (INT kp2=0 ; (kp2<(INT)Pts.size())&&(!Refut)  ; kp2++)
        {
            Pt2di p2 = Pts[kp2];
            if (    (kp1!= kp2)
                 && CmpTot(v1,dIm[p2.y][p2.x],p1,p2)
                 && BoxP1.contains(p2)
                 && BandeConnectedVsup(p1,p2,Im,Vinf,TolGeom,Marq)
               )
               Refut = true;
        }
        if (! Refut)
           mBufFiltr.push_back(p1);
    }
	}
    Pts = mBufFiltr;
}
示例#6
0
void drawPoint(Im2D_U_INT1 &aImage, const Pt2dr &aPoint, U_INT1 aValue, unsigned int aSize)
{
	const int sizei = (int)aSize;
	int x = round_ni(aPoint.x), y = round_ni(aPoint.y);

	if (x < 0 || x >= aImage.tx() || y < 0 || y >= aImage.ty())
	{
		ELISE_WARNING("point (" << x << ',' << y << ") out of rectangle " << aImage.sz());
		return;
	}

	drawPoint(aImage, x, y, aValue);
	for (int j = -sizei; j <= sizei; j++)
		for (int i = -sizei; i < sizei; i++)
		{
			drawPoint(aImage, x + i, y + j, aValue);
		}
}
示例#7
0
Im2D_U_INT1 cOneImageOfLayer::MakeImagePrio
     (
         Im2D_U_INT1              aImIn,
         int                      aDeZoom,
         int                      aSzBox
     )
{
// std::cout << "cOneImageOfLayer::MakeImagePrio\n";
    if ((aDeZoom==1) && (aSzBox<=0)) return aImIn;
    TIm2D<U_INT1,INT> aTImIn(aImIn);

    Pt2di aSzOut = aImIn.sz() / aDeZoom;
    Im2D_U_INT1 aImOut(aSzOut.x,aSzOut.y);
    TIm2D<U_INT1,INT> aTImOut(aImOut);

    int pNoDef = mVPrio[mTheNoLayer];

    Pt2di aPBox(aSzBox,aSzBox);
    Pt2di aPOut;

// std::cout << "SZZZ " << aImIn.sz() << aSzOut << "\n";
    for (aPOut.x=0 ; aPOut.x<aSzOut.x; aPOut.x++)
    {
        for (aPOut.y=0 ; aPOut.y<aSzOut.y; aPOut.y++)
        {
            const Pt2di aPIn = aPOut*aDeZoom;
            int aLabC = aTImIn.getproj(aPIn);
            int aPrio = mVPrio[aLabC];
            const Pt2di aP0In = aPIn-aPBox;
            const Pt2di aP1In = aPIn+aPBox;
            Pt2di aQIn;
            for (aQIn.x = aP0In.x ;aQIn.x<=aP1In.x; aQIn.x++)
            {
                  for (aQIn.y = aP0In.y ;aQIn.y<=aP1In.y; aQIn.y++)
                  {
                      int aLab = aTImIn.getproj(aQIn);
                      if (aLab!= aLabC)
                      {
                         ElSetMin(aPrio,pNoDef);
                      }
                      ElSetMin(aPrio,mVPrio[aLab]);
                  }
            }

            aTImOut.oset
            (
                aPOut,
                (aPrio<=pNoDef) ? mVLabOfPrio[aPrio] : aLabC
            );
        }
    }
    return aImOut;
}
示例#8
0
void cMMTP::MaskProgDyn(const cParamFiltreDepthByPrgDyn & aParam)
{
    std::cout << "BEGIN MASK PRGD\n";
    mImMasqFinal = FiltrageDepthByProgDyn(mContBT,mImLabel,aParam);
    std::cout << "END MASK PRGD\n";
    
#ifdef ELISE_X11
    if(TheWTiePCor)
    {
           ELISE_COPY(mImLabel.all_pts(),mImLabel.in(),TheWTiePCor->odisc());
           ELISE_COPY
           (
                 select(mImLabel.all_pts(),mImMasqFinal.in() && (mImLabel.in()==1)),
                 P8COL::green,
                 TheWTiePCor->odisc()
           );
           ELISE_COPY
           (
                 select(mImLabel.all_pts(),mImMasqFinal.in() && (mImLabel.in()==2)),
                 P8COL::blue,
                 TheWTiePCor->odisc()
           );
           TheWTiePCor->clik_in();
    }
#endif
}
示例#9
0
void save_tiff(const string &aFilename, Im2D_U_INT1 &aRed, Im2D_U_INT1 &aGreen, Im2D_U_INT1 &aBlue)
{
	ELISE_DEBUG_ERROR(aRed.sz() != aGreen.sz() || aRed.sz() != aBlue.sz(), "save_tiff", "invalid sizes " << aRed.sz() << ' ' << aGreen.sz() << ' ' << aBlue.sz());

	ELISE_COPY
	(
		aRed.all_pts(),
		Virgule(aRed.in(), aGreen.in(), aBlue.in()),
		Tiff_Im(
			aFilename.c_str(),
			aRed.sz(),
			GenIm::u_int1,
			Tiff_Im::No_Compr,
			Tiff_Im::RGB,
			Tiff_Im::Empty_ARG ).out()
	);

	if ( !ELISE_fp::exist_file(aFilename)) ELISE_ERROR_EXIT("failed to save TIFF image [" << aFilename << "]");
	cout << '\t' << "-- TIFF file [" << aFilename << "] created" << endl;
}
示例#10
0
void cMMTP::MaskRegulMaj(const cParamFiltreDetecRegulProf & aParam)
{
   double aPasPx =  mAppli.CurEtape()->GeomTer().PasPxRel0();
   Im2D_REAL4 anIm(mSzTiep.x,mSzTiep.y);
   ELISE_COPY(anIm.all_pts(),mImProf.in()*aPasPx,anIm.out());
    
   Im2D_Bits<1>   aNewMasq = FiltreDetecRegulProf(anIm,mImMasqInit,aParam);

#ifdef ELISE_X11
    if(TheWTiePCor)
    {
           std::cout << "SHOW FiltreDetecRegulProf\n";
           ELISE_COPY(mImLabel.all_pts(),mImMasqInit.in(),TheWTiePCor->odisc());
           ELISE_COPY
           (
                 select(mImLabel.all_pts(),aNewMasq.in()),
                 P8COL::green,
                 TheWTiePCor->odisc()
           );
           TheWTiePCor->clik_in();
    }
#endif
   mImMasqInit = aNewMasq;
}
示例#11
0
void getGrayImages(const string &aFilename, Im2D_U_INT1 &oGrayImage0, Im2D_U_INT1 &oGrayImage1, Im2D_U_INT1 &oGrayImage2)
{
	getGrayImage(aFilename, oGrayImage0);

	oGrayImage1.Resize(oGrayImage0.sz());
	oGrayImage1.dup(oGrayImage0);

	oGrayImage2.Resize(oGrayImage0.sz());
	oGrayImage2.dup(oGrayImage0);
}
示例#12
0
EHFS_ScoreIm::EHFS_ScoreIm 
(
    REAL         Step,
    REAL         Width,
    REAL         LentghMax,
    Im2D_U_INT1  ImGlob,
    REAL         CostChg,
    REAL         VminRadiom
)   :
    ElHoughFiltSeg(Step,Width,LentghMax,ImGlob.sz()),
    mImLoc     (SzMax().x,SzMax().y),
    mGainIfSeg (mImLoc.data()[mNbYMax]),
    mImGlob    (ImGlob),
    mCostChg   (CostChg),
    mVminRadiom (VminRadiom)
{
}
示例#13
0
static Im2D_U_INT1 Im2(Im2D_U_INT1 Im1,Im2D_REAL4 XPar)
{
    if (ImCox)
        return Im2D_U_INT1::FromFile("/home/pierrot/Data/Cox/pm-2.pgm");

    Im2D_U_INT1 aRes(SzI.x,SzI.y);
    ELISE_COPY
    (
         aRes.all_pts(),
	 AUC(
	      Im1.in_proj()[Virgule(FX+XPar.in(),FY)]
	      * (0.9 + 0.2 *unif_noise_4(6))
	    + (unif_noise_4(2)-0.5)*20
	 ),
	 aRes.out()
    );
    return aRes;
}
示例#14
0
void   EHFS_ScoreGrad::MakeImMaxLoc(Im1D_U_INT1 ImMaxLoc,Im2D_U_INT1 InRho)
{
    VerifSize(ImMaxLoc);
    VerifSize(InRho);

    U_INT1 *  dMax = ImMaxLoc.data();
    U_INT1 ** dRho = InRho.data();

    for (INT x=0; x<=mNbX ; x++)
    {
         INT yMaxL1 = mNbYMax;
         while ((yMaxL1<2*mNbYMax) && (dRho[yMaxL1][x]<=dRho[yMaxL1+1][x]))
               yMaxL1++;

         INT yMaxL2 = mNbYMax;
         while ((yMaxL2>0) && (dRho[yMaxL2][x]<=dRho[yMaxL2-1][x]))
               yMaxL2--;

        dMax[x] = (ElAbs(yMaxL1-mNbYMax)>ElAbs(yMaxL2-mNbYMax)) ? yMaxL1  : yMaxL2;
    }
}
示例#15
0
文件: b_0_21.cpp 项目: jakexie/micmac
void bench_fr_front_to_surf
     (
          Flux_Pts       front,
          Im2D_U_INT1    i0,
          Neighbourhood  v
     )
{
     Pt2di sz (i0.tx(),i0.ty());

     Im2D_U_INT1 i1(sz.x,sz.y,0);
     ELISE_COPY(i0.all_pts(),i0.in(),i1.out());

     ELISE_COPY
     (
          dilate
          (
               select
               (
                    i1.all_pts(),
                    i1.in()==1
               ),
               sel_func(v,i1.in()==0)
          ),
          2,
          i1.out()
     );

     ELISE_COPY(front,2,i0.out());

     INT dif;
     ELISE_COPY
     (
          i1.all_pts(),
          Abs(i1.in()-i0.in()),
          sigma(dif)
     );

      BENCH_ASSERT(dif == 0);
}
示例#16
0
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;
}
示例#17
0
void drawPoint(Im2D_U_INT1 &aImage, int aX, int aY, U_INT1 aValue)
{
	if (aX >=0 && aX < aImage.tx() && aY >= 0 && aY < aImage.ty()) aImage.data()[aY][aX] = aValue;
}
示例#18
0
文件: b_0_36.cpp 项目: jakexie/micmac
 static void Set(Im2D_U_INT1 I,Box2di box,INT val)
 {
     ELISE_COPY ( rectangle(box), val, I.out());
 }
示例#19
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
}
示例#20
0
bool CalcMaxLoc<Type,TypeBase,Compare>::BandeConnectedVsup 
     (
            Pt2di p1,
            Pt2di p2,
            Im2D<Type,TypeBase> Im,
            Type  VInf,
            REAL Tol,
            Im2D_U_INT1 Marq   
     )
{
    if (p1==p2)
       return true;

    Pt2di Sz = Inf(Im.sz(),Marq.sz());

    Box2di Box(Pt2di(0,0), Sz);

    if (!(Box.contains(p1) && Box.contains(p2)))
       return false;

    U_INT1 ** dMarq = Marq.data();
    Type **     dIm = Im.data();

    mBufCC.clear();
    mBufCC.push_back(p1);
    dMarq[p1.y][p1.x] = 1;
  
    Pt2dr aPR1(p1.x,p1.y);
    Pt2dr aPR2(p2.x,p2.y);
    SegComp seg12(aPR1,aPR2);

    bool got = false;
    for (INT kBuf=0 ; (kBuf!=(INT)mBufCC.size()) && (! got) ; kBuf++)
    {
         Pt2di pBuf = mBufCC[ kBuf];
         for (INT kV=0 ; kV< 8; kV++)
         {
             Pt2di pVois = pBuf + TAB_8_NEIGH[kV];
             if (
                        Box.contains(pVois)
                   &&  (dMarq[pVois.y][pVois.x] == 0)
                   &&  (! mCmp(dIm[pVois.y][pVois.x],VInf))
                   &&  (seg12.BoxContains(Pt2dr(pVois),1.0,Tol))
                )
             {
                 if (pVois==p2) 
                    got = true;
                 dMarq[pVois.y][pVois.x] = 1;
                 mBufCC.push_back(pVois);
             }
         }
    }

	{
    for (INT kBuf=0 ; kBuf<(INT)mBufCC.size() ; kBuf++)
    {
        Pt2di pBuf = mBufCC[ kBuf];
        dMarq[pBuf.y][pBuf.x] = 0;
    }
	}

    return got;
}
示例#21
0
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();

}