예제 #1
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();

}
예제 #2
0
void cAppliApero::InitPointsTerrain
     (
          std::list<Pt3dr>  & aL, 
          const cGPtsTer_By_ImProf & aGBI
     )
{
   const CamStenope * aMasterCam = 0;
   if (aGBI.ImMaitresse().IsInit())
      aMasterCam = PoseFromName(aGBI.ImMaitresse().Val())->CurCam();

   std::string aNF =  DC() + aGBI.File();
   Im2D_REAL4 aMnt = Im2D_REAL4::FromFileStd(aNF);
   TIm2D<REAL4,REAL8> aTMnt(aMnt);
   Pt2di aSz = aMnt.sz();

   int aNb = aGBI.NbPts();
   Pt2di aPtNbXY(0,0);
   Pt2dr aPtPas(0,0);
   if (aGBI.OnGrid())
   {
      double aPas = sqrt(aSz.x*aSz.y/double(aNb));
      aPtNbXY = Pt2di
              (
	         round_up(aSz.x/aPas),
	         round_up(aSz.y/aPas)
              );

       aNb = aPtNbXY.x * aPtNbXY.y;
       aPtPas = Pt2dr(double(aSz.x)/aPtNbXY.x,double(aSz.y)/aPtNbXY.y);
   }

   for (int aKP=0 ; aKP<aNb ; aKP++)
   {
       Pt2dr aPPl(0,0);

       if (aGBI.OnGrid())
       {
           int aKX = aKP %  aPtNbXY.x;
           int aKY = aKP /  aPtNbXY.x;
	   double aMul = 0.5 * aGBI.RandomizeInGrid().Val();
           aPPl = Pt2dr
	          (
		      (aKX+0.5+aMul*NRrandC())*aPtPas.x,
		      (aKY+0.5+aMul*NRrandC())*aPtPas.y
                  );
           // std::cout  << aKX << " " << aKY << " " << aNb << " "<< aPtNbXY << "\n";
	   // std::cout << aPtPas << "\n";
       }
       else
       {
          aPPl = Pt2dr(aSz.x*NRrandom3(),aSz.y*NRrandom3());
       }

       
       // std::cout << aPPl << "\n";
       double aZ = aTMnt.getr(aPPl);

       aZ = aGBI.Origine().z + aZ *  aGBI.Step().z;
       aPPl = Pt2dr
              (
	           aGBI.Origine().x+aPPl.x*aGBI.Step().x,
	           aGBI.Origine().y+aPPl.y*aGBI.Step().y
	      );
       Pt3dr aPTer(aPPl.x,aPPl.y,aZ);


       if (aMasterCam)
       {
           if (aGBI.DTMIsZ().Val())
              aPTer = aMasterCam->ImEtZ2Terrain(aPPl,aZ);
           else
              aPTer = aMasterCam->ImEtProf2Terrain(aPPl,aZ);
       }
       aL.push_back(aPTer);
   }
}
예제 #3
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;
}