コード例 #1
0
Im2D_U_INT1 Icone(const std::string & aName,const Pt2di & aSzCase,bool Floutage,bool Negatif)
{
   cElBitmFont & aFont = cElBitmFont::BasicFont_10x8() ;

   Im2D_Bits<1> aImBin = aFont.MultiLineImageString(aName,Pt2di(0,5),-aSzCase,0);
   ELISE_COPY(aImBin.border(3),1,aImBin.out());
   ELISE_COPY(aImBin.border(1),0,aImBin.out());

   Pt2di  aSz = aImBin.sz();
   Im2D_U_INT1 aRes(aSz.x,aSz.y);

   if (Negatif)
   {
      ELISE_COPY(line(Pt2di(0,0),aSz),1,aImBin.oclip());
      ELISE_COPY(line(Pt2di(aSz.x,0),Pt2di(0,aSz.y)),1,aImBin.oclip());
      ELISE_COPY(aImBin.all_pts(),!aImBin.in(),aImBin.out());
   }

   ELISE_COPY
   (
      aRes.all_pts(),
      (!aImBin.in(0)) *255,
      aRes.out()
   );


   if (Floutage)
   {
       ELISE_COPY
       (
            aRes.all_pts(),
            (  Negatif                                   ?
               Max(aRes.in(),rect_som(aRes.in(0),1)/9.0) :
               Min(aRes.in(),rect_som(aRes.in(0),1)/9.0)
            ),
            aRes.out()
       );

   }

   return aRes;
}
コード例 #2
0
void ElGrowingSetInd::insert(const INT& anInd)
{
   if (anInd  >= mCapa)
   {
       while (anInd >= mCapa) 
             mCapa *= 2;
       Im2D_Bits<1>  aNewBuzy (mCapa,1,0);
       ELISE_COPY(mBuzyIndexes.all_pts(),mBuzyIndexes.in(),aNewBuzy.out());
       mBuzyIndexes = aNewBuzy;
   }
   AssertValideIndexe(anInd);
   if (! PrivMember(anInd))
   {
      PrivSet(anInd,true);
      mIndexes.push_back(anInd);
   }
}
コード例 #3
0
ファイル: MMMaskByTP.cpp プロジェクト: jakexie/micmac-archeos
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
}
コード例 #4
0
ファイル: MMMaskByTP.cpp プロジェクト: jakexie/micmac-archeos
void  cAppliMICMAC::DoMasqueAutoByTieP(const Box2di& aBoxLoc,const cMasqueAutoByTieP & aMATP)
{

   std::cout << "cAppliMICMAC::DoMasqueAutoByTieP " << aBoxLoc << "\n";

   // std::cout <<  "*-*-*-*-*-*- cAppliMICMAC::DoMasqueAutoByTieP    "<< mImSzWCor.sz() << " " << aBox.sz() << mCurEtUseWAdapt << "\n";


   ElTimer aChrono;
   mMMTP = new cMMTP(aBoxLoc,mBoxIn,mBoxOut,*this);

    // Si il faut repartir d'un masque initial calcule a un de zool anterieur
    if (aMATP.TiePMasqIm().IsInit())
    {
       int aDZ = aMATP.TiePMasqIm().Val().DeZoomRel();
       int aDil = aMATP.TiePMasqIm().Val().Dilate();

       std::string aNameMasq = NameImageMasqOfResol(mCurEtape->DeZoomTer()*aDZ);
       Tiff_Im aTM(aNameMasq.c_str());
       Pt2di aSZM = aTM.sz();
       Im2D_Bits<1> aM(aSZM.x,aSZM.y);
       ELISE_COPY(aM.all_pts(),aTM.in(),aM.out());

       Im2D_Bits<1> aNewM = mMMTP->ImMasquageInput();
       ELISE_COPY
       (
             aNewM.all_pts(),
             dilat_32(aM.in(0)[Virgule(FX,FY)/double(aDZ)],aDil*3),
              aNewM.out()
       );
    }

    if (aMATP.mmtpFilterSky().IsInit())
    {
         Im2D_REAL4 * anIm = mPDV1->LoadedIm().FirstFloatIm();
         ELISE_ASSERT(anIm!=0,"Incohe in mmtpFilterSky");
         // Pt2di aSz = anIm->sz();
         Pt2di aSz = mMMTP->ImMasquageInput().sz();

         const cmmtpFilterSky & aFS = aMATP.mmtpFilterSky().Val();
         int aSeuilNbPts = round_ni(aSz.x*aSz.y*aFS.PropZonec().Val());

         Im2D_U_INT1 aImLabel(aSz.x,aSz.y);
         TIm2D<U_INT1,INT> aTLab(aImLabel);

         Fonc_Num FHGlob = FoncHomog(*anIm,aFS.SzKernelHom().Val(),aFS.PertPerPix().Val());
         ELISE_COPY(aImLabel.all_pts(),FHGlob,aImLabel.out());
         FiltrageCardCC(true,aTLab,1,2,aSeuilNbPts);

         Im2D_Bits<1> aNewM = mMMTP->ImMasquageInput();
         ELISE_COPY(select(aImLabel.all_pts(),aImLabel.in()==1),0,aNewM.out());
/*
         Video_Win * aW = Video_Win::PtrWStd(anIm->sz());
         ELISE_COPY(anIm->all_pts(),aImLabel.in(), aW->odisc());
         std::cout << "AAAAAAAAAAAAAAAAAaaaSkkkkkkYYyyyyy\n"; getchar();
*/
          
    }

 #ifdef ELISE_X11
   if (aMATP.Visu().Val())
   {
       Pt2dr aSzW = Pt2dr(aBoxLoc.sz());
       TheScaleW = ElMin(1000.0,ElMin(TheMaxSzW.x/aSzW.x,TheMaxSzW.y/aSzW.y));  // Pour l'instant on accepts Zoom>1 , donc => 1000

       // TheScaleW = 0.635;
       aSzW = aSzW * TheScaleW;

       TheWTiePCor= Video_Win::PtrWStd(round_ni(aSzW));
       TheWTiePCor=  TheWTiePCor->PtrChc(Pt2dr(0,0),Pt2dr(TheScaleW,TheScaleW),true);
       for (int aKS=0 ; aKS<mVLI[0]->NbScale() ; aKS++)
       {
           Im2D_REAL4 * anI = mVLI[0]->FloatIm(aKS);
           ELISE_COPY(anI->all_pts(),Max(0,Min(255,anI->in()/50)),TheWTiePCor->ogray());
       }
/*
       {
           ELISE_COPY(TheWTiePCor->all_pts(),mMMTP->ImMasquageInput().in(),TheWTiePCor->odisc());
           std::cout << "HERISE THE MAKSE \n"; getchar();
       }
*/
   }
#endif 
   std::string  aNamePts = mICNM->Assoc1To1
                           (
                              aMATP.KeyImFilePt3D(),
                              PDV1()->Name(),
                              true
                           );
   mTP3d = StdNuage3DFromFile(WorkDir()+aNamePts);

   cMasqBin3D * aMasq3D = 0;
//#if (ELISE_QT_VERSION >= 4)
   if (aMATP.Masq3D().IsInit())
   {
         aMasq3D  = cMasqBin3D::FromSaisieMasq3d(WorkDir()+aMATP.Masq3D().Val());
         std::vector<Pt3dr> aNewVec;
         for (int aK=0 ; aK<int(mTP3d->size()) ; aK++)
         {
              Pt3dr aP = (*mTP3d)[aK];
              if (aMasq3D->IsInMasq(aP))
                aNewVec.push_back(aP);
         }
         *mTP3d = aNewVec;
   }
// #endif

   std::cout << "== cAppliMICMAC::DoMasqueAutoByTieP " << aBoxLoc._p0 << " " << aBoxLoc._p1 << " Nb=" << mTP3d->size() << "\n"; 
   std::cout << " =NB Im " << mVLI.size() << "\n";


   cXML_ParamNuage3DMaille aXmlN =  mCurEtape->DoRemplitXML_MTD_Nuage();


   {
       cElNuage3DMaille *  aNuage = cElNuage3DMaille::FromParam(mPDV1->Name(),aXmlN,FullDirMEC());
       if (aMasq3D)
       {
           mMMTP->SetMasq3D(aMasq3D,aNuage,Pt2dr(mBoxIn._p0));
           mGLOBMasq3D = aMasq3D;
           mGLOBNuage = aNuage;
       }

       for (int aK=0 ; aK<int(mTP3d->size()) ; aK++)
       {
           Pt3dr aPE = (*mTP3d)[aK];
           Pt3dr aPL2 = aNuage->Euclid2ProfPixelAndIndex(aPE);


           int aXIm = round_ni(aPL2.x) - mBoxIn._p0.x;
           int aYIm = round_ni(aPL2.y) - mBoxIn._p0.y;
           int aZIm = round_ni(aPL2.z) ;


           MakeDerivAllGLI(aXIm,aYIm,aZIm);
           CTPAddCell(aMATP,aXIm,aYIm,aZIm,false);

           ShowPoint(Pt2dr(aXIm,aYIm),P8COL::red,0);
       }
   }



   OneIterFinaleMATP(aMATP,false);
   mMMTP->ExportResultInit();
   mMMTP->FreeCel();
 #ifdef ELISE_X11
   if (TheWTiePCor)
   {
       std::cout << "End croissance \n";
       TheWTiePCor->clik_in();
   }
 #endif
   const cComputeAndExportEnveloppe * aCAEE = aMATP.ComputeAndExportEnveloppe().PtrVal();


   if (aMATP.ParamFiltreRegProf().IsInit())
      mMMTP->MaskRegulMaj(aMATP.ParamFiltreRegProf().Val());
   mMMTP->ContAndBoucheTrou();
   if (aMATP.FilterPrgDyn().IsInit())
      mMMTP->MaskProgDyn(aMATP.FilterPrgDyn().Val());


   if (aCAEE)
   {
       mMMTP->ConputeEnveloppe(*aCAEE,aXmlN);
       if (aCAEE->EndAfter().Val()) return;
   }


/*
   if (aMATP.ParamFiltreRegProf().IsInit())
      mMMTP->MaskRegulMaj(aMATP.ParamFiltreRegProf().Val());
   mMMTP->ContAndBoucheTrou();
   if (aMATP.FilterPrgDyn().IsInit())
      mMMTP->MaskProgDyn(aMATP.FilterPrgDyn().Val());
*/



   // A CONSERVER , SAUV FINAL ...:

   std::string aNameMasq =  NameImageMasqOfResol(mCurEtape->DeZoomTer());

   Im2D_Bits<1> aImMasq0 = mMMTP->ImMasqFinal();
   ELISE_COPY(aImMasq0.all_pts(), aImMasq0.in(), Tiff_Im(aNameMasq.c_str()).out());
   
   std::string aNameImage = FullDirMEC() +aXmlN.Image_Profondeur().Val().Image();
   // Pour forcer le resultat flotant 
   Tiff_Im::CreateFromIm(mMMTP->ImProfFinal(),aNameImage.c_str());
/*
   ELISE_COPY(aImProf.all_pts(), aImProf.in(), Tiff_Im(aNameImage.c_str()).out());

       Im2D_REAL4   ImProfFinal() {return  mContBT;}   // image dequant et trous bouches
*/


}