コード例 #1
0
void Write_Vignette(string aDir, string aNameOut,vector<double> aParam,string aDirOut, Pt2di aSz){

    //Bulding the output file system
    ELISE_fp::MkDirRec(aDir + aDirOut);

    //Reading the image and creating the objects to be manipulated
    aNameOut=aDir + aDirOut + aNameOut;
    Tiff_Im aTF=Tiff_Im(aNameOut.c_str(), aSz, GenIm::real4, Tiff_Im::No_Compr, Tiff_Im::BlackIsZero);

    Im2D_REAL4  aIm(aSz.x,aSz.y);

    ELISE_COPY
    (
        aTF.all_pts(),
        aTF.in(),
        aIm.out()
    );

    REAL4 ** aData = aIm.data();

    for (int aY=0 ; aY<aSz.y  ; aY++)
        {
            for (int aX=0 ; aX<aSz.x  ; aX++)
            {
                double x0=aSz.x/2;
                double y0=aSz.y/2;
                double D=pow(aX-x0,2)+pow(aY-y0,2);
                double aCor=1+aParam[0]*D+aParam[1]*pow(D,2)+aParam[2]*pow(D,3);
                if(aCor<1){aData[aY][aX]=1;}else{aData[aY][aX]=aCor;}
            }
        }

        Tiff_Im  aTOut
        (
            aNameOut.c_str(),
            aSz,
            GenIm::real4,
            Tiff_Im::No_Compr,
            Tiff_Im::BlackIsZero
        );

        ELISE_COPY
            (
                aTOut.all_pts(),
                aIm.in(),
                aTOut.out()
            );

}
コード例 #2
0
ファイル: vecto_skel.cpp プロジェクト: archeos/micmac-archeos
INT EL_API_VECTO::ParamFile::GetThresh
    (
         const std:: string  & aName,
	 INT aTresh
    )
{
    if (aTresh != DefThresh)
        return aTresh;

    GenIm::type_el type = Tiff_Im(aName.c_str()).type_el();
    if (signed_type_num(type))
       return 0;
    else
       return 1 << (nbb_type_num(type)-1);
}
コード例 #3
0
ファイル: vecto_skel.cpp プロジェクト: archeos/micmac-archeos
EL_API_VECTO::ParamFile::ParamFile
              (
                      const ElSTDNS string & aName,
                      bool Inferieur ,
                      int  Threshold 

              )  :
	      ParamFonc
	      (
	          Pt2d2complex(Tiff_Im(aName.c_str()).sz()),
		  Inferieur,
		  GetThresh(aName,Threshold)
              ),
              _TiffNameFile (aName)
{
}
コード例 #4
0
ファイル: CPP_TestJB.cpp プロジェクト: archeos/micmac-archeos
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;
}
コード例 #5
0
int Jeremy_main( int argc, char **argv )
{
    if ( argc<2 ) return EXIT_FAILURE;

    Tiff_Im tiff(argv[1]);
    cout << '[' << argv[1] << "]: sz = " << tiff.sz() << 'x' << tiff.nb_chan() << ' ' << eToString(tiff.type_el()) << endl;
    Im2DGen image = tiff.ReadIm();
    cout << '[' << argv[1] << "]: sz = " << image.sz() << ' ' << eToString(image.TypeEl()) << endl;

    ELISE_COPY
    (
        image.all_pts(),
        Virgule( image.in(), image.in(), image.in() ),
        Tiff_Im(
            "toto.tif",
            image.sz(),
            image.TypeEl(),
            Tiff_Im::No_Compr,
            Tiff_Im::RGB,
            ArgOpTiffMDP(argv[1])/*Tiff_Im::Empty_ARG*/ ).out()
    );

    return EXIT_SUCCESS;
}
コード例 #6
0
ファイル: CPP_TestJB.cpp プロジェクト: archeos/micmac-archeos
void convolute()
{
	const string filename = "61.030.tif";

	REAL sigma = 3.2;
	int nbShift = 15;
	double epsilon = 0.001;
	int surEch = 10;
	ConvolutionKernel1D<INT> kernel;
	integralGaussianKernel<INT>(sigma, nbShift, epsilon, surEch, kernel);
	const vector<INT> &c = kernel.coefficients();

	cout << "kernel.size() = " << kernel.size() << endl;

	for (size_t i = 0; i < kernel.size(); i++)
		cout << c[i] << ' ';
	cout << endl;

	ConvolutionHandler<U_INT2> convolutionHandler;
	cConvolSpec<U_INT2> *convolution1d = convolutionHandler.getConvolution(kernel);

	cout << "convolution is " << ( !convolution1d->IsCompiled() ? "not " : "") << "compiled" << endl;
 

	Tiff_Im tiff(filename.c_str());
	cout << "[" << filename << "]: " << tiff.sz() << 'x' << tiff.nb_chan() << ' ' << eToString(tiff.type_el()) << endl;
	Im2DGen src_gen = tiff.ReadIm();
	Im2D_U_INT2 image0;
	if (tiff.type_el() != GenIm::u_int1) ELISE_ERROR_EXIT("bad type");
	{
		U_INT1 *src = ((Im2D_U_INT1 *) &src_gen)->data_lin();

		image0.Resize(tiff.sz());

		cout << "src_gen.sz() = " << src_gen.sz() << " image0.sz() = " << image0.sz() << endl;

		U_INT2 *dst = image0.data_lin();
		size_t i = size_t(image0.tx()) * size_t(image0.ty());
		while (i--) *dst++ = (U_INT2)(*src++) * 257;
	}

	Im2D_U_INT2 image1(image0.tx(), image0.ty());
	Im2D_U_INT2 *src = &image0, *dst = &image1;
	int nbConvol = 10;
	while (nbConvol--)
	{
		convolution<U_INT2>((const U_INT2 **)src->data(), src->tx(), src->ty(), *convolution1d, dst->data());
		ElSwap<Im2D_U_INT2 *>(src, dst);
	}

	Im2D_U_INT1 imageToWrite(src->tx(), src->ty());
	{
		U_INT2 *itSrc = src->data_lin();
		U_INT1 *itDst = imageToWrite.data_lin();
		size_t i = size_t(src->tx()) * size_t(src->ty());
		while (i--) *itDst++ = (U_INT1)((*itSrc++) / 257);
	}
	ELISE_COPY
	(
		imageToWrite.all_pts(),
		imageToWrite.in(),
		Tiff_Im(
			"toto.tif",
			imageToWrite.sz(),
			GenIm::u_int1,
			Tiff_Im::No_Compr,
			Tiff_Im::BlackIsZero,
			Tiff_Im::Empty_ARG ).out()
	);
}
コード例 #7
0
cTmpReechEpip::cTmpReechEpip
(
        bool aConsChan,
        const std::string & aNameOri,
        Box2dr aBoxImIn,
        ElDistortion22_Gen * anEpi,
        Box2dr aBox,
        double aStep,
        const std::string & aNameOut,
        const std::string & aPostMasq,
        int aNumKer ,
        bool Debug
) :
    mBoxImIn(aBoxImIn),
    mEpi    (anEpi),
    mStep   (aStep),
    mP0     (aBox._p0),
    mSzEpi  (aBox.sz()),
    mSzRed  (round_up (aBox.sz() / aStep) + Pt2di(1,1)),
    mRedIMasq  (mSzRed.x,mSzRed.y,0),
    mRedTMasq  (mRedIMasq),
    mRedImX    (mSzRed.x,mSzRed.y),
    mRedTImX   (mRedImX),
    mRedImY    (mSzRed.x,mSzRed.y),
    mRedTImY   (mRedImY)
{



    cInterpolateurIm2D<REAL4> * aPtrSCI = 0;


    if (aNumKer==0)
    {
        aPtrSCI = new cInterpolBilineaire<REAL4>;
    }
    else 
    {
      
       cKernelInterpol1D * aKer = 0;
       if (aNumKer==1)
          aKer = new cCubicInterpKernel(-0.5);
       else
          aKer = new cSinCardApodInterpol1D(cSinCardApodInterpol1D::eTukeyApod,aNumKer,aNumKer/2,1e-4,false);

       aPtrSCI =  new  cTabIM2D_FromIm2D<REAL4>   (aKer,1000,false);
       // cTabIM2D_FromIm2D<REAL4>   aSSCI (&aKer,1000,false);
    }

    cInterpolateurIm2D<REAL4> & aSCI = *aPtrSCI;



    Pt2di aPInd;

    for (aPInd.x=0 ; aPInd.x<mSzRed.x ; aPInd.x++)
    {
       for (aPInd.y=0 ; aPInd.y<mSzRed.y ; aPInd.y++)
       {
          bool Ok= false;
          Pt2dr aPEpi = ToFullEpiCoord(aPInd);
          Pt2dr aPIm =  anEpi->Inverse(aPEpi);
          if ((aPIm.x>mBoxImIn._p0.x) && (aPIm.y>mBoxImIn._p0.y) && (aPIm.x<mBoxImIn._p1.x) && (aPIm.y<mBoxImIn._p1.y))
          {
               Pt2dr aPEpi2 = anEpi->Direct(aPIm);
               if (euclid(aPEpi-aPEpi2) < 1e-2)
               {
                    Ok= true;
                    mRedTMasq.oset(aPInd,Ok);
               }
          }
          mRedTImX.oset(aPInd,aPIm.x);
          mRedTImY.oset(aPInd,aPIm.y);
       }
    }
    ELISE_COPY(mRedIMasq.all_pts(),dilat_d8(mRedIMasq.in(0),4),mRedIMasq.out());


    Tiff_Im aTifOri = Tiff_Im::StdConvGen(aNameOri.c_str(),aConsChan ? -1 :1 ,true);
    Tiff_Im aTifEpi  = Debug                       ?
                       Tiff_Im(aNameOut.c_str())     :
                       Tiff_Im
                       (
                           aNameOut.c_str(),
                           mSzEpi,
                           aTifOri.type_el(),
                           Tiff_Im::No_Compr,
                           aTifOri.phot_interp()
                       )                            ;

    Tiff_Im aTifMasq = aTifEpi;
    bool ExportMasq = (aPostMasq!="NONE");

// std::cout << "POSTMAS " << aPostMasq << "\n";

    if (ExportMasq)
    {
        std::string aNameMasq = StdPrefix(aNameOut)+ aPostMasq  +".tif";
        aTifMasq =  Debug                         ?
                    Tiff_Im(aNameMasq.c_str())    :
                    Tiff_Im
                    (
                        aNameMasq.c_str(),
                        mSzEpi,
                        GenIm::bits1_msbf,
                        Tiff_Im::No_Compr,
                        Tiff_Im::BlackIsZero
                    )                             ;
    }





    int aNbBloc=2000;
    int aBrd = aNumKer+10;
    Pt2di aSzBrd(aBrd,aBrd);

    int aX00 = 0;
    int aY00 = 0;

    for (int aX0=aX00 ; aX0<mSzEpi.x ; aX0+=aNbBloc)
    {
         int aX1 = ElMin(aX0+aNbBloc,mSzEpi.x);
         for (int aY0=aY00 ; aY0<mSzEpi.y ; aY0+=aNbBloc)
         {
// std::cout << "X0Y0 " << aX0 << " " << aY0 << "\n";

             int aY1 = ElMin(aY0+aNbBloc,mSzEpi.y);

             Pt2di aP0Epi(aX0,aY0);
             Pt2di aSzBloc(aX1-aX0,aY1-aY0);

             TIm2D<REAL4,REAL8> aTImX(aSzBloc);
             TIm2D<REAL4,REAL8> aTImY(aSzBloc);
             TIm2DBits<1>       aTImMasq(aSzBloc,0);

             Pt2dr aInfIm(1e20,1e20);
             Pt2dr aSupIm(-1e20,-1e20);
             bool  NonVide= false;

             for (int anX =aX0 ; anX<aX1  ; anX++)
             {
                 for (int anY =aY0 ; anY<aY1  ; anY++)
                 {
                     Pt2dr aIndEpi (anX/mStep , anY/mStep);
                     Pt2di aPIndLoc (anX-aX0,anY-aY0);
                     if (mRedTMasq.get(round_down(aIndEpi)))
                     {
                        double aXIm = mRedTImX.getr(aIndEpi,-1,true);
                        double aYIm = mRedTImY.getr(aIndEpi,-1,true);

                        if ((aXIm>0) && (aYIm>0))
                        {
                            // aTImMasq.oset(aPIndLoc,1);
                            aTImX.oset(aPIndLoc,aXIm);
                            aTImY.oset(aPIndLoc,aYIm);

                            aInfIm  = Inf(aInfIm,Pt2dr(aXIm,aYIm));
                            aSupIm  = Sup(aSupIm,Pt2dr(aXIm,aYIm));
                            NonVide= true;
                        }
                     }
                 }
             }
             Pt2di aP0BoxIm = Sup(Pt2di(0,0),Pt2di(round_down(aInfIm) - aSzBrd));
             Pt2di aP1BoxIm = Inf(aTifOri.sz(),Pt2di(round_down(aSupIm) + aSzBrd));
             Pt2di aSzIm = aP1BoxIm - aP0BoxIm;
             NonVide = NonVide && (aSzIm.x>0) && (aSzIm.y>0);
             if (NonVide)
             {

                 // std::vector<Im2D_REAL4>  aVIm;

                 std::vector<Im2D_REAL4>  aVIm= aTifOri.VecOfImFloat(aSzIm);

                 ELISE_COPY
                 (
                     rectangle(Pt2di(0,0),aSzIm),
                     trans(aTifOri.in(),aP0BoxIm),
                     StdOut(aVIm)
                 );

                 std::vector<Im2D_REAL4>  aVImEpi = aTifEpi.VecOfImFloat(aSzBloc);
                 ELISE_ASSERT(aVImEpi.size()==aVIm.size(),"Incohe in nb chan, cTmpReechEpip::cTmpReechEpip");

                 for (int aKIm=0 ; aKIm <int(aVImEpi.size()) ; aKIm++)
                 {
                      TIm2D<REAL4,REAL8> aImEpi(aVImEpi[aKIm]);
                      REAL4 ** aDataOri = aVIm[aKIm].data();
                      for (int anX =0 ; anX<aSzBloc.x ; anX++)
                      {
                           for (int anY =0 ; anY<aSzBloc.y ; anY++)
                           {

                               Pt2di aIndEpi(anX,anY);
                               aImEpi.oset(aIndEpi,0);
                               Pt2di anIndEpiGlob  = aIndEpi + aP0Epi;

                               Pt2dr aIndEpiRed (anIndEpiGlob.x/mStep , anIndEpiGlob.y/mStep);
                               if (mRedTMasq.get(round_down(aIndEpiRed),0))
                               {
                                   double aXIm = mRedTImX.getr(aIndEpiRed,-1,true);
                                   double aYIm = mRedTImY.getr(aIndEpiRed,-1,true);
                                   Pt2dr aPImLoc = Pt2dr(aXIm,aYIm) - Pt2dr(aP0BoxIm);
                                   double aV= 128;
                                   if ((aPImLoc.x>aNumKer+2) && (aPImLoc.y>aNumKer+2) && (aPImLoc.x<aSzIm.x-aNumKer-3) && (aPImLoc.y<aSzIm.y-aNumKer-3))
                                   {
                                       aTImMasq.oset(aIndEpi,1);
                                       aV = aSCI.GetVal(aDataOri,aPImLoc);
                                       // aV= 255;
                                   }
                                   aImEpi.oset(aIndEpi,aV);
                               }
                           }
                      }
                 }
                 ELISE_COPY
                 (
                     rectangle(aP0Epi,aP0Epi+aSzBloc),
                     Tronque(aTifEpi.type_el(),trans(StdInput(aVImEpi),-aP0Epi)),
                     aTifEpi.out()
                 );
             }
             if (ExportMasq)
             {
                ELISE_COPY
                (
                    rectangle(aP0Epi,aP0Epi+aSzBloc),
                    trans(aTImMasq._the_im.in(0),-aP0Epi),
                    aTifMasq.out()
                );
             }
             // std::cout << "ReechDONE " <<  aX0 << " "<< aY0 << "\n";

         }
    }
}
コード例 #8
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
*/


}
コード例 #9
0
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;
}
コード例 #10
0
int Luc_main_truc(int argc, char ** argv)
{
    /*
    std::string aFullPattern, aOri, aNameOut="PointsCordinates.txt";
    //Reading the arguments
    ElInitArgMain
        (
        argc, argv,
        LArgMain()  << EAMC(aFullPattern, "Images Pattern 1", eSAM_IsPatFile)
                    << EAMC(aOri, "Orientation", eSAM_IsPatFile),
        LArgMain()  << EAM(aNameOut, "Out", true, "Output file (txt)")
        );

    string aPattern, aNameDir;
    SplitDirAndFile(aNameDir, aPattern, aFullPattern);

    //Reading input files
    list<string> ListIm = RegexListFileMatch(aNameDir, aPattern, 1, false);
    int nbIm = ListIm.size();

    string oriFileName = aNameDir + aNameOut;
    FILE *f = fopen(oriFileName.c_str(), "w");

    for (int i = 1; i <= nbIm; i++)
    {
        //Processing the image
        string aNameIm = ListIm.front();
        ListIm.pop_front();
        string aNameOut = aNameDir + aNameIm + ".tif";

        //Loading the camera
        string aNameCam = "Ori-" + aOri + "/Orientation-" + aNameIm + ".xml";
        cInterfChantierNameManipulateur * anICNM = cInterfChantierNameManipulateur::BasicAlloc(aNameDir);
        CamStenope * aCam = CamOrientGenFromFile(aNameCam, anICNM);
        cout << aNameIm << " [ " << aCam->VraiOpticalCenter().x << " , " << aCam->VraiOpticalCenter().y << " , " << aCam->VraiOpticalCenter().z << " ]" << endl;
        fprintf(f, "%s %0.6f %0.6f %0.6f\n", aNameIm, aCam->VraiOpticalCenter().x, aCam->VraiOpticalCenter().y, aCam->VraiOpticalCenter().z);

    }
    fclose(f);



    */

    std::string aFullPattern1, aFullPattern2, aFile3D1, aFile3D2, aOri, aDirOut = "Visualisation/";
    int aSzW = 1;
    double aSzMovArea = 5;
    //Reading the arguments
    ElInitArgMain
        (
        argc, argv,
        LArgMain()	<< EAMC(aFullPattern1, "Images Pattern 1", eSAM_IsPatFile)
                    << EAMC(aFullPattern2, "Images Pattern 2", eSAM_IsPatFile)
                    << EAMC(aFile3D1, "File 3D 1", eSAM_IsPatFile)
                    << EAMC(aFile3D2, "File 3D 2", eSAM_IsPatFile)
                    << EAMC(aOri, "Orientation", eSAM_IsPatFile),
        LArgMain()	<< EAM(aDirOut, "Out", true, "Output folder (end with /) and/or prefix (end with another char)")
                    << EAM(aSzMovArea, "SzMovArea", true, "Max magnitude of movement in meters (def=5)")
        );

    //Creating vector of images
    std::string aDir, aPatIm1, aPatIm2;
    SplitDirAndFile(aDir, aPatIm1, aFullPattern1);
    SplitDirAndFile(aDir, aPatIm2, aFullPattern2);
    cInterfChantierNameManipulateur * aICNM = cInterfChantierNameManipulateur::BasicAlloc(aDir);
    const std::vector<std::string> * aSetIm1 = aICNM->Get(aPatIm1);
    const std::vector<std::string> * aSetIm2 = aICNM->Get(aPatIm2);
    std::vector<std::string> aVectIm1 = *aSetIm1;
    std::vector<std::string> aVectIm2 = *aSetIm2;

    cout << "Set 1 size : " << aVectIm1.size() << endl;
    cout << "Set 1 : " << aVectIm1 << endl;
    cout << "Set 2 size : " << aVectIm2.size() << endl;
    cout << "Set 2 : " << aVectIm2 << endl;

    //loading 3D models
    cElNuage3DMaille * info3D1 = cElNuage3DMaille::FromFileIm(aFile3D1);
    cElNuage3DMaille * info3D2 = cElNuage3DMaille::FromFileIm(aFile3D2);
    cout << "Sz geom 1: " << info3D1->SzGeom() << endl;
    cout << "Sz geom 2: " << info3D2->SzGeom() << endl;
    cout << "Resol geom 1: " << info3D1->ResolSolGlob() << endl;
    cout << "Resol geom 2: " << info3D2->ResolSolGlob() << endl;

    //Loading images
    vector<SpatioTempImage> aGrIm1 = LoadGrpImages(aDir, aPatIm1, aOri);
    vector<SpatioTempImage> aGrIm2 = LoadGrpImages(aDir, aPatIm2, aOri);
    cout << "Loaded " << aGrIm1.size() << " images for group 1 and " << aGrIm2.size() << " for group 2" << endl;


    //Bulding the output file system
    ELISE_fp::MkDirRec(aDir + aDirOut);
    std::string aNameOut = "banane.tif";
    //Reading the image and creating the objects to be manipulated
    aNameOut = aDir + aDirOut + aNameOut;

    Pt2di aSz( info3D1->SzGeom().x , info3D1->SzGeom().y );

    Tiff_Im aTF = Tiff_Im(aNameOut.c_str(), aSz, GenIm::real4, Tiff_Im::No_Compr, Tiff_Im::BlackIsZero);

    Im2D_REAL4  aIm(aSz.x, aSz.y);

    ELISE_COPY
        (
        aTF.all_pts(),
        aTF.in(),
        aIm.out()
        );

    REAL4 ** aData = aIm.data();


    for (int aY = aSzW; aY < aSz.y - aSzW; aY++)
    {
        for (int aX = aSzW; aX < aSz.x - aSzW; aX++)
        {
            /*******************************
            HOW TO
            //transform XY pixel coordinates to terrain coordinates
            Pt2dr pos2DPtIm1; pos2DPtIm1.x = 10050 + aX*0.14999999999999999*2; pos2DPtIm1.y = 10350 - aY*0.14999999999999999*2;
            //Go back to pix coordinates
            pos2DPtIm1 = info3D->Plani2Index(pos2DPtIm1);
            ********************************/
            Pt2dr pos2DMNT( aX , aY );
            //Test if there is data
            if (info3D1->CaptHasData(pos2DMNT)){
                //Get 3D info at XY
                Pt3d<double> pos3DMNT = info3D1->PreciseCapteur2Terrain(pos2DMNT);
                //cout << "pos3DMNT1 = " << pos3DMNT << endl;
                //Get Im1(i,j)
                Pt2di pos2DIm1( int(aGrIm1[0].aCamera->Ter2Capteur(pos3DMNT).x) , int(aGrIm1[0].aCamera->Ter2Capteur(pos3DMNT).y) );
                cout << "pos2DIm1 = " << pos2DIm1 << endl;
                //Extracting window from Im1
                Im2D_U_INT1 aWindow1 = Window_Maker(aGrIm1[0], pos2DIm1, 1);

                Fonc_Num aScoreMin = 100;
                /*
                for (int bX = pos3DMNT.x - aSzMovArea; bX <= pos3DMNT.x + aSzMovArea; bX++)
                {
                    for (int bY = pos3DMNT.y - aSzMovArea; bY <= pos3DMNT.y + aSzMovArea; bY++)
                    {
                        Pt2di aPos(int(aGrIm2[0].aCamera->Ter2Capteur(pos3DMNT).x), int(aGrIm2[0].aCamera->Ter2Capteur(pos3DMNT).y));
                        //Extracting window from Im2
                        Im2D_U_INT1 aWindow2 = Window_Maker(aGrIm2[0], aPos, 1);
                        double aScore = Correlator(&aWindow1, &aWindow2);
                        if (aScore < aScoreMin)
                        {
                            //CACACACACACACACCACACACACA TESTER SI PT EXIST DANS INFO3D2=====================================================================================
                            aScoreMin = aScore;
                            Pt2dr aPos2D(bX, bY);
                            Pt3dr aPos3D = info3D2->PreciseCapteur2Terrain(info3D2->Plani2Index(aPos2D));
                            cout << "pos set 1 = " << pos3DMNT << endl;
                            cout << "pos set 2 = " << aPos3D << endl;
                            aData[aY][aX] = square_euclid(pos3DMNT, aPos3D);
                            cout << aData[aY][aX] << endl;
                        }
                    }
                }


                //Get Im2(i,j)
                Pt2di pos2DIm2( int(aGrIm2[0].aCamera->Ter2Capteur(pos3DMNT).x) , int(aGrIm2[0].aCamera->Ter2Capteur(pos3DMNT).y) );
                cout << "pos2DIm2 = " << pos2DIm2 << endl;
                //Define researsh area in pixels from input info in meters
                int aSzMovAreaPix = aSzMovArea / aGrIm2[0].aCamera->ResolutionSol();
                cout <<"Pouet"<<endl;
                double aScoreMin = 100;
                for (int bX = pos2DIm2.x - aSzMovAreaPix; bX <= pos2DIm2.x + aSzMovAreaPix; bX++)
                {
                    for (int bY = pos2DIm2.y - aSzMovAreaPix; bY <= pos2DIm2.y + aSzMovAreaPix; bY++)
                    {
                        Pt2di aPos( bX, bY );
                        //Extracting window from Im2
                        vector<vector<float> > aWindow2 = Window_Maker(aGrIm2[0], aPos, 1);
                        cout << aWindow2 << endl;
                        double aScore = Correlator(aWindow1, aWindow2);
                        cout << aScore << endl;
                        if (aScore < aScoreMin)
                        {
                            aScoreMin = aScore;
                            Pt2dr aPosR(aPos.x, aPos.y);
                            cout << "aPos " << aPos << endl;
                            cout << "aPosR " << aPosR << endl;

                            Pt3dr aPosPt3D = aGrIm2[0].aCamera->PreciseCapteur2Terrain(aPosR);
                            cout << aPosPt3D << endl;
                            Pt2dr aPos2DPtIm2 = info3D2->Plani2Index(aPosR);
                            cout << aPos2DPtIm2 << endl;
                            aData[aY][aX] = square_euclid(pos3DMNT, info3D2->PreciseCapteur2Terrain(aPos2DPtIm2));
                            cout << aData[aY][aX] << endl;
                        }
                    }
                }
                */

            }
            else
            {
                aData[aY][aX] = 1;
                //cout << "not in Masq" << endl;
            }
        }
    }

    Tiff_Im  aTOut
        (
        aNameOut.c_str(),
        aSz,
        GenIm::real4,
        Tiff_Im::No_Compr,
        Tiff_Im::BlackIsZero
        );

    ELISE_COPY
        (
        aTOut.all_pts(),
        aIm.in(),
        aTOut.out()
        );

    return 0;

}