Пример #1
0
void cResul_RL::MakeFile(const std::string & aName,double aDyn,bool IsSigned) 
{
    Fonc_Num aFonc = aDyn * mResidu.in()/Max(mPds.in(),1e-5);

    if (IsSigned)
        aFonc = 128 + aFonc;

    Tiff_Im::Create8BFromFonc(aName,mSz,Max(0,Min(255,aFonc)));
}
Пример #2
0
void cImage_LumRas::CalculShadeByDiff()
{

   mImShade.Resize(mAppli.mImGr.sz());

   std::string aNameOut = mDir+ "LumRas_"+StdPrefix(mName) + ".tif";
   Tiff_Im TifTest
           (
                 aNameOut.c_str(),
                 mIm.sz(),
                 // GenIm::u_int1,
                 GenIm::real4,
                 Tiff_Im::No_Compr,
                 Tiff_Im::BlackIsZero
           );

    Fonc_Num aFRas  =  FLoc(6,50,mIm);
    Fonc_Num aFStd  =  FLoc(6,50,mAppli.mImGr);
    Tiff_Im::Create8BFromFonc("Test-Ras.tif",mIm.sz(),aFRas*100);
    Tiff_Im::Create8BFromFonc("Test-Std.tif",mIm.sz(),aFStd*100);
// Fonc_Num     cImage_LumRas::FLoc(int aNbIter,int aSzW,Fonc_Num aF)

   ELISE_COPY(mImShade.all_pts(),(aFRas-aFStd),mImShade.out());

   ELISE_COPY
   (
      TifTest.all_pts(),
      // Max(0,Min(255,128 * (1 + 2*mImShade.in()))),
      mImShade.in(),
      TifTest.out()
   );

}
Пример #3
0
Fonc_Num     cImage_LumRas::FLoc(int aNbIter,int aSzW,Im2D_U_INT2 anIm)
{
   Fonc_Num aFMasq = mAppli.mImMasq.in(0);
   Fonc_Num aF = anIm.in(0);


   Fonc_Num aFMoy =  0;

   if (0)
      aFMoy =  FMoy(aNbIter,aSzW,aF*aFMasq) / Max(1e-2,FMoy(aNbIter,aSzW,aFMasq)) ;
   else if (0)
      aFMoy = MoyGlobImage(aF);
   else if (1)
   {
        Pt2di aSz = anIm.sz();
        Im2D_REAL4 aIMoy (aSz.x,aSz.y);
        ::MoyByCC(true, TIm2DBits<1>(mAppli.mImMasq),0,TIm2D<U_INT2,INT>(anIm),TIm2D<REAL4,REAL8>(aIMoy));
        aFMoy = aIMoy.in();

Tiff_Im::Create8BFromFonc("TestMasq.tif",aSz,mAppli.mImMasq.in()*255);
        //Tiff_Im::Create8BFromFonc("Test.tif",aSz,aFMoy); std::cout << "CCCCCCCCCC\n"; getchar();
   }

   return  (aF / Max(1e-2,aFMoy)) * aFMasq;
}
template <class Type,class TBase> cElNuage3DMaille * cElN3D_EpipGen<Type,TBase>::V_ReScale
                                    (
                                        const Box2dr &aBox,
                                        double aScale,
                                        const cXML_ParamNuage3DMaille & aNewParam,
                                        Im2D_REAL4 anImPds,
                                        std::vector<Im2DGen*> aVNewAttr,
                                        std::vector<Im2DGen*> aVOldAttr
                                    ) 
{
    // RatioResolAltiPlani();

    // Im2DGen * anOld = this->mAttrs[0]->Im();


   // Fonc_Num aFoncProf = this->ReScaleAndClip(this->mImDef.in(0)*this->mIm.in(0),aBox._p0,aScale)/Max(1e-5,anImPds.in());

    /*
       for (int aKA=0 ; aKA<int(mAttrs.size()) ; aKA++)
       {
            Im2DGen * anOld = this->mAttrs[aKA]->Im();
            Im2DGen * aNew = anOld->ImOfSameType(Pt2di(aSz));

            aRes->mAttrs.push_back(new cLayerNuage3DM(aNew,mAttrs[aKA]->Name()));
        }
        aRes->mGrpAttr = mGrpAttr;
    */

   double aDifStd = 0.5;
   if (aNewParam.RatioResolAltiPlani().IsInit() && (aNewParam.Image_Profondeur().IsInit()))
   {
        ElAffin2D aAfM2C = Xml2EL(this->mParams.Orientation().OrIntImaM2C());
        double aResol = (euclid(aAfM2C.I10()) + euclid(aAfM2C.I01()))/2.0;

        aDifStd  = (1/aResol) * (1/this->mParams.Image_Profondeur().Val().ResolutionAlti())   * (this->mParams.RatioResolAltiPlani().Val()) ;
        aDifStd *= 0.5;
   }

   Im2D_REAL4 aRedProf = ReduceImageProf(aDifStd,this->mImDef,this->mIm,aBox,aScale,anImPds,aVNewAttr,aVOldAttr);
   Fonc_Num  aFoncProf = aRedProf.in();



   cElN3D_EpipGen<float,double> * aRes = new cElN3D_EpipGen<float,double>
                                             (
                                                 this->mDir,
                                                 aNewParam,
                                                 anImPds.in(0) > 0.1,
                                                 aFoncProf,
                                                 //   this->ReScaleAndClip(this->mImDef.in(0)*this->mIm.in(0),aBox._p0,aScale)/Max(1e-5,anImPds.in()),
                                                 mProfIsZ,
                                                 this->mEmptyData,
                                                 false
                                             );

   return aRes;
}
Пример #5
0
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);
   }

}
Пример #6
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;
}
Пример #7
0
void cMMTP::DoOneEnv(Im2D_REAL4 anEnvRed,Im2D_Bits<1> aNewM,bool isMax,const cXML_ParamNuage3DMaille & aTargetNuage,const cXML_ParamNuage3DMaille & aCurNuage,double aRedFact)
{
    int aSign  = isMax ? 1 : - 1;
    int aDefVal = -(aSign * 32000);


    Fonc_Num  aFMasqBin;
    Fonc_Num fChCo = Virgule(FX,FY)/ (aRedFact);
    Fonc_Num aRes = FoncChCoordWithMasq(anEnvRed.in(aDefVal),aNewM.in(0),fChCo,aDefVal,aFMasqBin);

    aRes = aRes + mDilatAlti * aSign;
    aRes  =  isMax ? rect_max(aRes,mDilatPlani)  : rect_min(aRes,mDilatPlani);
    aRes = ::AdaptDynOut(aRes,aTargetNuage,aCurNuage);

    Tiff_Im  aFileRes = FileEnv(isMax?"EnvMax":"EnvMin",false);
    ELISE_COPY(rectangle(mBoxOutEnv._p0,mBoxOutEnv._p1),trans(aRes * aFMasqBin,-mBoxInEnv._p0),aFileRes.out());

    if (isMax)
    {
        Tiff_Im  aFileMasq = FileEnv("EnvMasq",true);
        ELISE_COPY(rectangle(mBoxOutEnv._p0,mBoxOutEnv._p1),trans(aFMasqBin,-mBoxInEnv._p0),aFileMasq.out());
    }
}
Пример #8
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
}
Пример #9
0
void  cMMTP::ConputeEnveloppe(const cComputeAndExportEnveloppe & aCAEE,const cXML_ParamNuage3DMaille & aCurNuage)
{

   mNameTargetEnv = mAppli.WorkDir() + TheDIRMergeEPI()  +  mAppli.PDV1()->Name() + "/NuageImProf_LeChantier_Etape_1.xml";

   mNameTargetEnv = aCAEE.NuageExport().ValWithDef(mNameTargetEnv);
   cXML_ParamNuage3DMaille aTargetNuage = StdGetFromSI(mNameTargetEnv,XML_ParamNuage3DMaille);
   mZoomTargetEnv = aTargetNuage.SsResolRef().Val();
   mSzTargetEnv =  aTargetNuage.NbPixel();
   double aZoomRel = mAppli.CurEtape()->DeZoomTer()/mZoomTargetEnv;

   mBoxOutEnv._p0 = round_ni(Pt2dr(mBoxOutGlob._p0) * aZoomRel);
   mBoxOutEnv._p1 = round_ni(Pt2dr(mBoxOutGlob._p1) * aZoomRel);
   mBoxInEnv._p0 = round_ni(Pt2dr(mBoxInGlob._p0) * aZoomRel);
   mBoxInEnv._p1 = round_ni(Pt2dr(mBoxInGlob._p1) * aZoomRel);



   ELISE_ASSERT(mP0Tiep==Pt2di(0,0),"Too lazy to handle box maping");


   double aPasPx =  mAppli.CurEtape()->GeomTer().PasPxRel0();
//=============== READ PARAMS  ====================
   double  aStepSsEch = aCAEE.SsEchFilter().Val();
   int     aSzFiltrer = aCAEE.SzFilter().Val();
   double  aProp = aCAEE.ParamPropFilter().Val();

   int     aDistProl = round_up(  ElMax(aCAEE.ProlResolCur().Val(),aCAEE.ProlResolCible().Val()/aZoomRel) /aStepSsEch);
   double  aDistCum =  (aCAEE.ProlDistAddMax().Val()  / (aPasPx*  aZoomRel));
   double aDistAdd =   (aCAEE.ProlDistAdd().Val()*aStepSsEch )  / (aPasPx);

   std::cout << "DIST CUM " << aDistCum << " DADD " << aDistAdd << "\n";


//===================================

    ElTimer aChrono;

    int     aSeuilNbV = 2 * (1+2*aSzFiltrer); // Au moins une bande de 2 pixel pour inferer qqch
    Pt2di aSzRed = round_up(Pt2dr(mSzTiep)/aStepSsEch);

    Im2D_Bits<1>    aMasqRed(aSzRed.x,aSzRed.y,0);
    TIm2DBits<1>    aTMR(aMasqRed);
/*
    TIm2D<INT2,INT> aPMaxRed(aSzRed);
    TIm2D<INT2,INT> aPMinRed(aSzRed);
*/
    TIm2D<REAL4,REAL> aPMaxRed(aSzRed);
    TIm2D<REAL4,REAL> aPMinRed(aSzRed);

    // Calcul du filtre de reduction
    Pt2di aPRed;
    for (aPRed.y = 0 ; aPRed.y<aSzRed.y ; aPRed.y++)
    {
        for (aPRed.x = 0 ; aPRed.x<aSzRed.x ; aPRed.x++)
        {
             Pt2di aPR1 = round_ni(Pt2dr(aPRed)*aStepSsEch);
             int anX0 = ElMax(0,aPR1.x-aSzFiltrer);
             int anX1 = ElMin(mSzTiep.x-1,aPR1.x+aSzFiltrer);
             int anY0 = ElMax(0,aPR1.y-aSzFiltrer);
             int anY1 = ElMin(mSzTiep.y-1,aPR1.y+aSzFiltrer);
             std::vector<REAL> aVVals;
             Pt2di aVoisR1;
             for (aVoisR1.x=anX0 ; aVoisR1.x<=anX1 ; aVoisR1.x++)
             {
                  for (aVoisR1.y=anY0 ; aVoisR1.y<=anY1 ; aVoisR1.y++)
                  {
                     if (mTImMasqInit.get(aVoisR1))
                        aVVals.push_back( mTCBT.get(aVoisR1));
                        // aVVals.push_back( mTImProf.get(aVoisR1));
                  }
             }
             if (int(aVVals.size()) >= aSeuilNbV)
             {
                  REAL4 aVMax = KthValProp(aVVals,aProp);
                  REAL4 aVMin = KthValProp(aVVals,1-aProp);
                  aPMaxRed.oset(aPRed,aVMax);
                  aPMinRed.oset(aPRed,aVMin);
                  aTMR.oset(aPRed,1);
                  ELISE_ASSERT(aVMin<=aVMax,"Mic>Max !!!! in BasicMMTiep");
             }
             else
             {
                  aPMaxRed.oset(aPRed,-32000);
                  aPMinRed.oset(aPRed, 32000);
             }
        }
    }
    //Tiff_Im::Create8BFromFonc("TDifInit.tif",aSzRed,Max(0,Min(255,Iconv(aPMaxRed._the_im.in()-aPMinRed._the_im.in()))));

    Im2D_Bits<1> aNewM(1,1);
    Im2D_REAL4  aNewMax = ProlongByCont (aNewM,aMasqRed,aPMaxRed._the_im,aDistProl,aDistAdd,aDistCum);
    Im2D_REAL4  aNewMin = ProlongByCont (aNewM,aMasqRed,aPMinRed._the_im,aDistProl,-aDistAdd,aDistCum);
    ELISE_COPY(select(aNewM.all_pts(),!aNewM.in()),0,aNewMax.out()|aNewMin.out());

    // fChCo = Virgule(FX,FY)/ (aStepSsEch * aZoomRel);
    // fMasq = aNewM.in(0)[fChCo];
    // fMasqBin = fMasq>0.5;


    mDilatPlani = ElMax(aCAEE.DilatPlaniCible().Val(),round_up(aCAEE.DilatPlaniCur().Val()*aZoomRel));
    mDilatAlti  = ElMax(aCAEE.DilatAltiCible ().Val(),round_up(aCAEE.DilatPlaniCur().Val()*aZoomRel));
    
    DoOneEnv(aNewMax,aNewM,true ,aTargetNuage,aCurNuage,aStepSsEch * aZoomRel);
    DoOneEnv(aNewMin,aNewM,false,aTargetNuage,aCurNuage,aStepSsEch * aZoomRel);


    Fonc_Num  aFMasqBin;
    Fonc_Num fChCo = Virgule(FX,FY)/ aZoomRel;

std::cout  << "ZRRRR  " << aZoomRel <<  " 1/Z " << (1/aZoomRel) 
           <<   " ;; " << mAppli.CurEtape()->DeZoomTer() << " , " << mZoomTargetEnv << "\n";
// Tiff_Im::CreateFromIm(mContBT,DirOfFile(mNameTargetEnv)+"CONTBT.tif");


    Fonc_Num aFoncProf = FoncChCoordWithMasq(mContBT.in(0),mImMasqFinal.in(0),fChCo,0,aFMasqBin);
    aFoncProf = ::AdaptDynOut(aFoncProf,aTargetNuage,aCurNuage);

    Tiff_Im aFileProf = FileEnv("Depth",false);
    ELISE_COPY(rectangle(mBoxOutEnv._p0,mBoxOutEnv._p1),trans(aFoncProf,-mBoxInEnv._p0),aFileProf.out());


    Tiff_Im aFileMasq = FileEnv("Masq",true);
    ELISE_COPY(rectangle(mBoxOutEnv._p0,mBoxOutEnv._p1),trans(aFMasqBin,-mBoxInEnv._p0),aFileMasq.out());


#ifdef ELISE_X11
   if (0 && TheWTiePCor)
   {
       ELISE_COPY(TheWTiePCor->all_pts(),aFMasqBin,TheWTiePCor->odisc());
       std::cout << "AAAAAAAAAAAAAAAAAAAAa\n";
       TheWTiePCor->clik_in();
       ELISE_COPY(TheWTiePCor->all_pts(),aFileMasq.in(),TheWTiePCor->odisc());
       std::cout << "bbBBbbBBBBBBBbbb\n";
       TheWTiePCor->clik_in();
   }
#endif
}
Пример #10
0
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
*/


}
Пример #11
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();

}
Пример #12
0
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;
}