예제 #1
0
void ElImplemDequantifier::OnePasse
     (
                  INT aPBegin, INT aStepP,INT aPend,
                  INT aNbV,INT * aTabV,INT * aTabP
     )
{
    for (INT aP0=aPBegin; aP0!=aPend ; aP0+=aStepP)
    {
        INT aQuant0 = lDQ[aP0];
        if (aQuant0 != eValOut)
        {
            for (INT aKV=0; aKV<aNbV ; aKV++)
            {
                INT aPV = aP0 + aTabV[aKV];
                // INT aQuantV = lDQ[aPV];
                if (lDQ[aPV] == aQuant0)
                {
                   INT aPds = aTabP[aKV];
                   ElSetMin(mDPL[aP0],mDPL[aPV]+aPds);
                   ElSetMin(mDM[aP0],mDM[aPV]+aPds);
                }
            }
        }
    }
}
예제 #2
0
Im2D_U_INT1 cOneImageOfLayer::MakeImagePrio
     (
         Im2D_U_INT1              aImIn,
         int                      aDeZoom,
         int                      aSzBox
     )
{
// std::cout << "cOneImageOfLayer::MakeImagePrio\n";
    if ((aDeZoom==1) && (aSzBox<=0)) return aImIn;
    TIm2D<U_INT1,INT> aTImIn(aImIn);

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

    int pNoDef = mVPrio[mTheNoLayer];

    Pt2di aPBox(aSzBox,aSzBox);
    Pt2di aPOut;

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

            aTImOut.oset
            (
                aPOut,
                (aPrio<=pNoDef) ? mVLabOfPrio[aPrio] : aLabC
            );
        }
    }
    return aImOut;
}
예제 #3
0
void cIncListInterv::AddInterv(const cIncIntervale & anInterv,bool CanOverlap)
{
   if (anInterv.Sz()==0 )
      return;
   for (tCSetIII anIt =  mMap.begin() ; anIt!= mMap.end() ; anIt++)
   {
       ELISE_ASSERT
       (
           anIt->Id() != anInterv.Id(),
           "Ambiguous Key in cIncListInterv::AddInterv"
       );
       if (CanOverlap)
          mMayOverlap = true;
       else
       {
           ELISE_ASSERT
           (
                ! (anInterv.Overlap(*anIt)),
               "Overlapping interval in cIncListInterv::AddInterv"
           );
       }
   }

   mMap.insert(anInterv);
   ElSetMin(mI0Min,anInterv.I0Alloc());
   ElSetMax(mI1Max,anInterv.I1Alloc());
   mSurf += anInterv.Sz();
}
예제 #4
0
bool cOneImageOfLayer::LoadFileRed(const std::string & aNameRed)
{
    if ( !ELISE_fp::exist_file(aNameRed))  
       return false;
    mIm = Im2D_U_INT1::FromFileStd(aNameRed);
    mTIm = TIm2D<U_INT1,INT>(mIm);
    Pt2di aSzR = mIm.sz();
    mLabMin = 1000000;
    mLabMax = -1000000;
    Pt2di aP;
    for (aP.x=0 ; aP.x<aSzR.x; aP.x++)
    {
        for (aP.y=0 ; aP.y<aSzR.y; aP.y++)
        {
            int aLab = mTIm.get(aP);
            if (aLab != mTheNoLayer)
            {
               ElSetMin(mLabMin,aLab);
               ElSetMax(mLabMax,aLab);
           }
        }
    }
    std::cout  << "Labels, Min: " << mLabMin << " , Max :" << mLabMax << "\n";
    return true;
}
예제 #5
0
void  HPoly
      (
           ActionSeg &             Act,
           ElFifo<Pt2dr> &   f,
           Pt2dr                   dir,
           REAL                    esp
      )
{
     REAL omax = -1e50;
     REAL omin =  1e50;

     SegComp s0 (Pt2dr(0,0),dir);

     for (INT k=0; k<f.nb() ; k++)
     {
          REAL ord = s0.ordonnee(f[k]);
          ElSetMax(omax,ord);
          ElSetMin(omin,ord);
     }
     
     for (REAL ord = round_up(omin/esp) *esp; ord<omax; ord += esp)
     {
          Pt2dr p0 = s0.from_rep_loc(Pt2dr(0.0,ord));
          ClipSeg(Act,f,Seg2d(p0,p0+s0.tangente()));
     }
      
}
예제 #6
0
void ComputeIntervaleDelta
              (
                  INT & aDzMin,
                  INT & aDzMax,
                  INT aZ,
                  INT MaxDeltaZ,
                  INT aZ1Min,
                  INT aZ1Max,
                  INT aZ0Min,
                  INT aZ0Max
              )
{
      aDzMin =   aZ0Min-aZ;
      if (aZ != aZ1Min)
         ElSetMax(aDzMin,-MaxDeltaZ);

      aDzMax = aZ0Max-1-aZ;
      if (aZ != aZ1Max-1)
         ElSetMin(aDzMax,MaxDeltaZ);

       // Si les intervalles sont vides, on relie
       // les bornes des intervalles a tous les points
       if (aDzMin > aDzMax)
       {
          if (aDzMax <0)
             aDzMin = aDzMax;
          else
             aDzMax = aDzMin;
       }
}
예제 #7
0
bool  cImage::PIMsValideVis(const Pt3dr & aPTer)
{
   if (mPImsNuage==0) return true;

   Pt2dr aPIm = mPImsNuage->Terrain2Index(aPTer);
   Pt2di aIPIm = round_ni(aPIm);


   double aProfMax= -1e20;
   double aProfMin= 1e20;
   int aDil = round_up(mPNSeuilPlani);

   for (int aDx= -aDil ; aDx <= aDil ; aDx++)
   {
       for (int aDy= -aDil ; aDy <= aDil ; aDy++)
       {
            Pt2di aPVois(aIPIm.x+aDx,aIPIm.y+aDy);
            if ((mPImsNuage->IndexHasContenu(aPVois)) && (euclid(Pt2dr(aPVois)-aPIm)<mPNSeuilPlani))
            {
                double aProfNu = mPImsNuage->ProfEnPixel(aPVois);
                ElSetMax(aProfMax,aProfNu);
                ElSetMin(aProfMin,aProfNu);
            }
       }
   }


   Pt3dr aTerInNu = mPImsNuage->Euclid2ProfPixelAndIndex(aPTer);
   double aProfTer = aTerInNu.z;

    return (aProfTer >= (aProfMin-mPNSeuilAlti)) && (aProfTer<=(aProfMax+mPNSeuilAlti));

/*
std::cout << "Valll   BBBBBBB\n";
   if (! aEnv->IndexHasContenuForInterpol(aPIm))
   {
       // A Parametrer eventuellement
       return false;
   }

   Pt3dr aTerInNu = aEnv->Euclid2ProfPixelAndIndex(aPTer);
   double aProfTer = aTerInNu.z;
   double aProfNu = aEnv->ProfInterpEnPixel(aPIm);

   bool isDessus = (aProfTer >= aProfNu);

std::cout << "Valll   CCCCCCC " << aProfTer << " " << aProfNu << " \n";

   return aMin ?  isDessus : (! isDessus);
*/

  return false;

}
예제 #8
0
REAL   SquareDistPointPoly(const ElFifo<Pt2dr> & f,Pt2dr pt)
{
     if ( PointInPoly(f,pt))
        return 0;

     REAL d2 = 1e40;

     for (INT k=0; k<f.nb() ; k++)
         ElSetMin
         (
            d2,
            SegComp(f[k],f[k+1]).square_dist_seg(pt)
         );

     return d2;
}
예제 #9
0
void ElImplemDequantifier::QuickSetDist(INT aNbStep)
{
    ELISE_COPY(mDistPlus.all_pts(),eMaxDist,mDistPlus.out());
    ELISE_COPY(mDistMoins.all_pts(),eMaxDist,mDistMoins.out());




    for (INT aP0=0; aP0<mNbPts ; aP0++)
    {
        INT aQuant0 = lDQ[aP0];
        if (aQuant0 != eValOut)
        {
            for (INT aKV=0; aKV<mNbVYm ; aKV++)
            {
                INT aPV = aP0 + mVYm[aKV];
                INT aQuantV = lDQ[aPV];
                if (aQuantV != eValOut)
                {
                   INT aPds = mPdsYm[aKV];
                   if (aQuantV<aQuant0)
                   {
                       ElSetMin(mDPL[aPV],aPds-1);
                       ElSetMin(mDM[aP0],aPds-1);
                   }
                   else if (aQuantV>aQuant0)
                   {
                       ElSetMin(mDPL[aP0],aPds-1);
                       ElSetMin(mDM[aPV],aPds-1);
                   }
                   else 
                   {
                      ElSetMin(mDPL[aP0],mDPL[aPV]+aPds);
                      ElSetMin(mDM[aP0],mDM[aPV]+aPds);
                   }
                }
            }
        }
    } 

    OnePasseInverseVideo();

    for (INT aK=0; aK<aNbStep ; aK++)
    {
       OnePasseVideo();
       OnePasseInverseVideo();
    }

    if (mTraitCuv)
    {
       TraitCuv(mDPL,mDM);
       TraitCuv(mDM ,mDPL);
    }
}
예제 #10
0
void cIncEnsembleCamera::OptimJacobi
     (
          std::list<cIncSetLiaison *> *  aListSL,
          const std::vector<cFonctrPond> &     aFoncAux
     )
{
    mListSl = aListSL;
    mFoncsAux = aFoncAux;
    SetOpt();
    ELISE_ASSERT(mL2Opt,"Need L2 Sys for OptimJacobi");

    mSysL2->GetMatr(mMatrL2,mMatrtB);
    jacobi_diag(mMatrL2,mMatrValP,mMatrVecP);

    mtBVecP = mMatrtB * mMatrVecP;

cElRanGen aR;
Im1D_REAL8 P0 = CurVals();
Im1D_REAL8 mImBest  = CurVals();


REAL aScInit = ScoreCur(false);
REAL aScMin = aScInit;
REAL aScAmMin = aScInit;
for (INT aTest =0 ; aTest < 100 ; aTest ++)
{
    SetPtCur(P0.data());
    Im1D_REAL8 aDir( NbVal(),0.0);
    

    for (INT aK = 0 ; aK < NbVal() ; aK++)
    {
        ELISE_ASSERT(mMatrValP(aK,aK) != 0,"Jcobi ");
        REAL Val = (mtBVecP(aK,0) /  ElAbs(mMatrValP(aK,aK)))  ;

	REAL aRan = aR.cNRrandom3()  ;

        if (aRan < 0.25)
        {
             Val = 0;
        }
        else if (aRan < 0.5)
	;
	/*
        {
             Val = Val; 
        }
	*/
        else
            Val *=  3 * aR.cNRrandom3() -1;
     

        for (INT aY =0 ; aY< NbVal() ; aY++)
            aDir.data()[aY] += mMatrVecP(aK,aY) * Val;

    }

    ELISE_COPY(aDir.all_pts(),P0.in() + aDir.in(),aDir.out());
    SetPtCur(aDir.data());
    REAL aSc = ScoreCur(false);

if (aSc < aScMin)
{
    ElSetMin(aScMin,aSc);

    for (INT aK= 0 ; aK< 10 ; aK++)
        OneItereDevL1( aK < 3);

    REAL aSc = ScoreCur(false);
    if (aSc < aScAmMin)
    {
         aScAmMin = aSc;
         ELISE_COPY(mImBest.all_pts(),CurVals().in(),mImBest.out());
    }
   
}
    cout  <<  aScMin << " " << aScInit  << " " << aSc <<  " " << aScAmMin << "\n";
}
    SetPtCur(mImBest.data());
}
예제 #11
0
	void 	Scale_Im_Compr<TObj,TLut,TInd>::DoItReduce()
{
    ElTimer aTimer;

	for (INT wy=this->_pW0.y; wy<this->_pW1.y; wy++)
	{
		INT yU0 = round_down(this->y_to_user(wy-0.5));
		INT yU1 = round_up(this->y_to_user(wy+0.5));


		ElSetMax(yU0,0);
		ElSetMin(yU1,this->_SzU.y-1);

		for (INT ux= this->_pW0.x -(Scale_Im_Compr<TObj,TLut,TInd>::RAB) ;
			ux<this->_pW1.x +(Scale_Im_Compr<TObj,TLut,TInd>::RAB); ux++)
			this->_l0[ux] = 0;



		INT pdsTot = 0;

		if (yU0<yU1)
		{

			for (INT uy= yU0; uy<=yU1 ; uy++)
			{
				REAL yW0 = std::max(this->y_to_window(uy-0.5),wy-0.5);
				REAL yW1 = std::min(this->y_to_window(uy+0.5),wy+0.5);
				
				INT pds = round_ni((yW1-yW0) * this->_CoeffPds);
				if (pds > 0)
				{
					pdsTot += 0;
					_CurPds = pds;
					DeCompr
					(
					        _dim->lpckb(uy),
						*this,
						this->_xU0,
						this->_xU1,
						_dim->per()
					);
					pdsTot += pds;
				}
			}
			if (pdsTot)
			{
				
				{
				for (INT ux= this->_pW0.x ;  ux<this->_pW1.x +(Scale_Im_Compr<TObj,TLut,TInd>::RAB) ; ux++)
					this->_l0[ux] += this->_l0[ux-1];
				}
				INT pxy = pdsTot * this->_CoeffPds;

				{
				for (INT ux= this->_pW0.x ;  ux<this->_pW1.x ; ux++)
					this->_l0[ux] /= pxy;
                }

                mTimeUnCompr += aTimer.uval();
				RasterUseLine
				(
					Pt2di(this->_pW0.x,wy),
					Pt2di(this->_pW1.x,wy+1),
					this->_line
				);
                aTimer.reinit();
			}
		}
	}
} 
예제 #12
0
파일: b_0_48.cpp 프로젝트: jakexie/micmac
void Optim_L1FormLin::CombinConjMinLoc
     (
        ElFilo<REAL>&  dic,
        ElFilo<INT> &  Subset,
        ElFilo<INT> &  FlagPos
     )
{
    CPT ++;
    INT NbF = (1<<_NbForm);
    for (INT k=dic.nb() ;k<NbF ; k++)
        dic.pushlast(1e20);

    FlagPos.clear();

    CombinConjMinLoc(dic,Subset,FlagPos,0,0,0);

    INT NbMin0 =0;
    INT NbMin1 =0;

    REAL M0 = 1e80,M1 = -1e80;

	{
    for (INT k=0 ; k< FlagPos.nb(); k++)
    {


        REAL VN = TestNeighConjMinLoc(FlagPos[k],dic);
        REAL V0 = dic[FlagPos[k]];

        if (V0 < VN)
           NbMin0 ++;
        if (V0 <=  VN)
        {
           NbMin1 ++;
           ElSetMin(M0,V0);
           ElSetMax(M1,V0);
        }

/*
        {
          show_flag(FlagPos[k]);
          cout << " : " << dic[FlagPos[k]];
          if (V0 <= VN) 
             cout << " ** ";
          cout << "\n";
        }
*/
    }
	}

/*
    if ((NbMin0!=1) || (NbMin1!=1))
        cout << NbMin0 << " " << NbMin1 << "\n";
*/

    BENCH_ASSERT(NbMin0 <= 1);
    BENCH_ASSERT(NbMin1 >= 1);

   cout << "MINS = " << M0 << " " << M1 << "\n";
   BENCH_ASSERT(std::abs(M0-M1)<epsilon);


   {
    for (INT k=0 ; k< FlagPos.nb(); k++)
        dic[FlagPos[k]] = 1e20;

   }
}
예제 #13
0
cOneImageOfLayer::cOneImageOfLayer
(
      cAppliApero & anAppli,
      const  cLayerImageToPose & aLIP,
      const std::string & aNameIm,
      cOneImageOfLayer *  aLayerTer
)  :
   mAppli       (anAppli), 
   mIm          (1,1),
   mTIm         (mIm),
   mVPrio       (256,255),
   mVLabOfPrio  (256,mTheNoLayer),
   mDeZoom      (aLIP.FactRed()),
   mLayerTer    (aLayerTer),
   mCam         (0),
   mGRRF        (0),
   mSysCam      (0)
{
    const cLayerTerrain * aLT = aLIP.LayerTerrain().PtrVal();
    if (aLT)
    {
       if (mLayerTer) // On dans une image en train de se "brancher" vers le terrain
       {
            mLabMin = mLayerTer->mLabMin;
            mLabMax = mLayerTer->mLabMax;
            std::string aNameCam = mAppli.DC()+ mAppli.ICNM()->Assoc1To1(aLT->KeyAssocOrImage(),aNameIm,true);
            mCam = Cam_Gen_From_File(aNameCam,aLT->TagOri().Val(),mAppli.ICNM());
            return;
       }
       else // On est en train de creer le layer terrain lui meme
       {
           std::string aNameGeoR = mAppli.DC()+ mAppli.ICNM()->Assoc1To1(aLT->KeyAssocGeoref().Val(),aNameIm,true);
           mGRRF = cGeoRefRasterFile::FromFile(aNameGeoR);
           if (aLT->ZMoyen().IsInit())
              mZMoy = aLT->ZMoyen().Val();
           else
              mZMoy = mGRRF->ZMoyen();

           mSysCam = cSysCoord::FromFile(mAppli.DC()+aLT->SysCoIm());
       }
    }
    std::string aNameRed =  mAppli.DC()+ mAppli.ICNM()->Assoc1To1(aLIP.KeyNameRed().Val(),aNameIm,true);
    if (mDeZoom==1)  
    {
        aNameRed =  mAppli.DC()+aNameIm;
    }
    if (LoadFileRed(aNameRed))
       return;

    // ON LOADE l'IMAGE REDUITE ,  INITIALISE les tailles, ALLOUE la memoire

    for (int aK=0 ; aK<int(aLIP.EtiqPrio().size()); aK++) 
    {
       mVPrio[aLIP.EtiqPrio()[aK]] = aK;
    }
    ElSetMin(mVPrio[mTheNoLayer],int(aLIP.EtiqPrio().size()));

    for (int aK=0 ; aK<256; aK++) 
    {
       mVLabOfPrio[mVPrio[aK]] = aK;
    }
    

    Im2D_U_INT1 aImZ1 = Im2D_U_INT1::FromFileStd(anAppli.DC()+aNameIm);
    Im2D_U_INT1 aImTmp = MakeImagePrio(aImZ1,mDeZoom,mDeZoom/2);


    int aFCoh = aLIP.FactCoherence().Val();
    int aSzBox =  (aFCoh>=0) ? ((aFCoh+mDeZoom-1)/mDeZoom) : 0;
    mIm = MakeImagePrio(aImTmp,1,aSzBox);
    mTIm = TIm2D<U_INT1,INT>(mIm);




    Tiff_Im::CreateFromIm(mIm,aNameRed);
    bool OkLoad = LoadFileRed(aNameRed);
    ELISE_ASSERT(OkLoad,"Incoh in cOneImageOfLayer::cOneImageOfLayer");

    std::cout << "   ==== LAB = " << mLabMin << " " << mLabMax << "\n";
}
예제 #14
0
cElNuageLaser::cElNuageLaser
(
     const std::string & aNameFile,
     const char *  aNameOri,
     const char *  aNameGeomCible ,
     const char *  aNameGeomInit

)  :
   mVPts (),
   mQt   (0)
{
   std::string aNameBin = StdPrefix(aNameFile) + ".tif";
   if (! ELISE_fp::exist_file(aNameBin))
   {
       INT aNb = 3;
       FILE * aFP = ElFopen(aNameFile.c_str(),"r");
       ELISE_ASSERT(aFP!=0,"Cannot Open File for Laser Data");

       char Buf[10000];
       INT aCpt =0;
       while (aNb>=3)
       {
           aNb=0;
           char * got = fgets(Buf,10000,aFP);
           Pt3dr aP;
           if (got)
           {
              aNb = sscanf(Buf,"%lf %lf %lf",&aP.x,&aP.y,&aP.z);
           }
	   if (aNb>=3)
              mVPts.push_back(aP);
	   aCpt++;
       }

       INT aNbPts = (INT) mVPts.size();
       Im2D_REAL8 aImPts(aNbPts,3);
       REAL ** aData = aImPts.data();
       for (INT aK=0 ; aK<aNbPts ; aK++)
       {
	   Pt3dr aP = mVPts[aK];
           aData[0][aK] = aP.x;
           aData[1][aK] = aP.y;
           aData[2][aK] = aP.z;
       }

       Tiff_Im aFile
	       (
                  aNameBin.c_str(),
		  Pt2di(aNbPts,3),
		  GenIm::real8,
		  Tiff_Im::No_Compr,
		  Tiff_Im::BlackIsZero,
		     Tiff_Im::Empty_ARG
		  +  Arg_Tiff(Tiff_Im::ANoStrip())
               );
       ELISE_COPY(aImPts.all_pts(),aImPts.in(),aFile.out());
   }
   else
   {
       Tiff_Im aFile(aNameBin.c_str());
       Pt2di aSz = aFile.sz();
       Im2D_REAL8 aImPts(aSz.x,aSz.y);
       ELISE_COPY(aImPts.all_pts(),aFile.in(),aImPts.out());

       REAL ** aD = aImPts.data();
       mVPts.reserve(aSz.x);
       for (INT aK=0 ; aK<aSz.x ; aK++)
       {
           Pt3dr aP(aD[0][aK],aD[1][aK],aD[2][aK]);
           mVPts.push_back(aP);
       }
   }


   Ori3D_Std * aOri = 0;
   eModeConvGeom aMode = eConvId;

   if (aNameOri)
   {
       if (!strcmp(aNameGeomInit,"GeomCarto"))
       {
           if (!strcmp(aNameGeomCible,"GeomCarto"))
           {
               aMode = eConvId;
           }
           else if (!strcmp(aNameGeomCible,"GeomTerrain"))
           {
               aMode = eConvCarto2Terr;
           }
           else if (!strcmp(aNameGeomCible,"GeomTerIm1"))
           {
               aMode = eConvCarto2TerIm;
           }
           else
           {
              ELISE_ASSERT(false,"Bad GeomCible in cElNuageLaser::cElNuageLaser");
           }
       }
       else
       {
           ELISE_ASSERT(false,"Bad GeomInit in cElNuageLaser::cElNuageLaser");
       }
       if (aMode != eConvId)
          aOri = new Ori3D_Std (aNameOri) ;
   }

   for (INT aK=0 ; aK<INT( mVPts.size()); aK++)
   {
       Pt3dr aP = mVPts[aK];
       if (aOri)
       {
          if (aMode == eConvCarto2Terr)
             aP = aOri->carte_to_terr(aP);
          else if (aMode == eConvCarto2TerIm)
          {
             aP = aOri->carte_to_terr(aP);
             Pt2dr aP2 = aOri->to_photo(aP);
             aP.x = aP2.x;
             aP.y = aP2.y;
          }
          mVPts[aK] = aP;
       }

       REAL  aZ   =  aP.z;
       Pt2dr aP2 (aP.x,aP.y);
       if (aK==0)
       {
           mZMax = mZMin = aZ;
           mPInf =mPSup = aP2;
       }
       ElSetMin(mZMin,aZ);
       ElSetMax(mZMax,aZ);
       mPInf.SetInf(aP2);
       mPSup.SetSup(aP2);
   }
   delete aOri;
}
void cMatrCorresp::Normalize
     (
          const cOneModeleAnalytique &      aModele,
          const cGeomDiscFPx &              aGT,
	  cPriseDeVue &               aPDV1,
          const cGeomImage &                aGeom1,
	  cPriseDeVue &               aPDV2,
          const cGeomImage &                aGeom2
     )
{
    const cReCalclCorrelMultiEchelle * aRCCME=GetOnlyUseIt(aModele.ReCalclCorrelMultiEchelle());

    bool isNuage3D = (aModele.TypeModele() == eTMA_Nuage3D);

    // A voir, sans doute un peu severe pour eTMA_Nuage3D
    if (isNuage3D)
    {
         mImZ = Im2D_REAL4(mSz.x,mSz.y,0.0);
	 mTImZ = TIm2D<REAL4,REAL8>(mImZ);
    }
    else
    {
        ELISE_ASSERT
        (
            aGeom1.IsId(),
            "Modele Analytique supose Geom1=Identite "
        );
    }

    double aVXY2[theDimPxMax];
    Pt2di aPRas;
    Im2D_REAL4 aIRCC(mSz.x,mSz.y,0.0);
    for (aPRas.x=0 ; aPRas.x<mSz.x ; aPRas.x++)
    {
        for (aPRas.y=0 ; aPRas.y<mSz.y ; aPRas.y++)
        {
           double aPds = mTImPds.get(aPRas);
           if ( aPds > 0)
           {
               Pt2dr aPTer
                     (
                         mTImX1.get(aPRas)/aPds,
                         mTImY1.get(aPRas)/aPds
                     );
               for (int aK=0; aK<mNBXY2; aK++)
               {
                   aVXY2[aK] = mDXY2[aK][aPRas.y][aPRas.x]/ aPds;
               }

               aGT.PxDisc2PxReel(aVXY2,aVXY2);
               aPTer = aGT.RDiscToR2(aPTer);

	       if (isNuage3D)
	       {
	             Pt3dr aPE = aGeom1.Restit2Euclid(aPTer,aVXY2);
                     mTImX1.oset(aPRas,aPE.x);
                     mTImY1.oset(aPRas,aPE.y);
                     mTImZ.oset(aPRas,aPE.z);
		     if (aPRas.y==0) 
		         std::cout << aPRas.x << "\n";
	       }
	       else
	       {
               
                   Pt2dr aQ1 =  aGeom1.Objet2ImageInit_Euclid(aPTer,aVXY2);
                   Pt2dr aQ2 =  aGeom2.Objet2ImageInit_Euclid(aPTer,aVXY2);


	           if (aRCCME!=0)
	           {
	               bool aMMin = aRCCME->AgregMin().Val();
	               double aCorAgr = aMMin ? 1e10 : 0;
		       int aNb=0;

		       for 
		       (
		           std::list<Pt2di>::const_iterator itScSz=aRCCME->ScaleSzW().begin();
		           itScSz!=aRCCME->ScaleSzW().end();
		           itScSz++
		       )
		       {
                           aNb++;
		           cMC_PairIm * aPair = mPairs[itScSz->x];
		           if (aPair==0)
		           {
	                       mPairs[itScSz->x] = new cMC_PairIm(itScSz->x,aGT,aPDV1,aPDV2);
		               aPair = mPairs[itScSz->x];
		           }
                           double aCor = aPair->Correl(aPTer,itScSz->y,aVXY2);
		           if (aMMin)
		              ElSetMin(aCorAgr,aCor);
                           else
		              aCorAgr += aCor;
		       }

                       if (! aMMin)
		          aCorAgr /= aNb;

                       aIRCC.data()[aPRas.y][aPRas.x] = (REAL4)aCorAgr;
                       // std::cout << "COR = " << aCorAgr << "\n";
		       if (aCorAgr < aRCCME->Seuil() )
		       {
                          aPds =  0;
		          mTImPds.oset(aPRas,0);
		       }
	           }

                   if (aPds > 0)
	           {
                      mPackHomInit.Cple_Add(ElCplePtsHomologues(aQ1,aQ2,aPds));

                      aQ1 =  aGeom2.CorrigeDist1(aQ1);
                      aQ2 =  aGeom2.CorrigeDist2(aQ2);
                      mPackHomCorr.Cple_Add(ElCplePtsHomologues(aQ1,aQ2,aPds));
                  }
	      }
           }
        }
    }


    if (aRCCME && (aRCCME->DoImg().Val()))
    {
        std::string aName=   mAppli.FullDirResult()
	                   + std::string("CorME_")
	                   + mAppli.NameChantier()
			   + std::string(".tif");
        Tiff_Im::Create8BFromFonc(aName,aIRCC.sz(),Max(0,Min(255,128*(1+aIRCC.in()))));

    }
}
예제 #16
0
파일: b_0_48_1.cpp 프로젝트: jakexie/micmac
GMCube::GMCube(std::string aName)  :
    mP0     (0,0),
    mSz     (20000,20000),
    aFp     ( aName.c_str(),ELISE_fp::READ),
    mX0     ( aFp.read_REAL8()),
    mY0     ( aFp.read_REAL8()),
    mZ0     ( aFp.read_REAL8()),
    mStepXY ( aFp.read_REAL8()),
    mStepZ  ( aFp.read_REAL8()),
    mTx     ( aFp.read_INT4()),
    mTy     ( aFp.read_INT4()),
    mTz     ( aFp.read_INT4()),
    mIZmin  ( mTx, mTy),
    mIZmax  ( mTx, mTy),
    mZoom   (1.0),
    mW      (Video_Win::WStd(Pt2di(mTx,mTy),mZoom)),
    mW2     (Video_Win::WStd(Pt2di(mTx,mTy),mZoom)),
    mW3     (Video_Win::WStd(Pt2di(200,100),mZoom)),
    mW4     (Video_Win::WStd(Pt2di(mTx,mTy),mZoom)),
    mDisp   (mW2.disp())
{

   mSz = Inf(mSz,Pt2di(mTx,mTy));


   INT aNbZ =0;
   long aDeb = aFp.tell();
   INT aMaxZ =0;

   INT aVMax = -1000000;
   INT aVMin = 100000;
   for(INT y=0;y<mTy;++y)
   {

      for(INT x=0;x<mTx;++x)
      {
          INT2 zM  = aFp.read_INT2();
          INT2 aN  = aFp.read_INT2();

          mIZmin.data()[y][x] = zM;
          mIZmax.data()[y][x] = zM+aN;
          ElSetMax(aMaxZ ,(INT) aN);

          for (INT z=0 ; z<aN ; z++)
          {
              INT2 aVal =  aFp.read_INT2();
              ElSetMin(aVMin,aVal);
              ElSetMax(aVMax,aVal);
          }
          aNbZ += aN;
      }
   }

   cout << "NbZ = " << aNbZ <<  "  " << mStepZ << "\n";

   pSCA =     cInterfaceCoxAlgo::StdNewOne
              (
                  mSz,
                  trans(mIZmin.in(),mP0),
                  trans(mIZmax.in(),mP0),
                  2,
                  true
              );
cout << "AAAAAAAAAAAAa\n";

   
   aFp.seek_begin(aDeb);
   Im2D_INT2 zCor(mTx,mTy);
   Im2D_U_INT1 CorMax(mTx,mTy);


   for(INT y=0;y<mTy;++y)
   {
      for(INT x=0;x<mTx;++x)
      {
          INT2 z1  = aFp.read_INT2();
          INT2 z2  = z1+aFp.read_INT2();
 
          INT cMax = -100000;
          INT zMax = z1;

          bool OkP2 = (x>=mP0.x) && (x<mP0.x+mSz.x) && (y>=mP0.y) && (y<mP0.y+mSz.y);
          for (INT z=z1 ; z<z2 ; z++)
          {
              INT2 aVal =  aFp.read_INT2();
              if (aVal > cMax)
              {
                   cMax = aVal;
                   zMax = z;
              }
              aVal = round_ni((aVMax-aVal)/(aVMax/100.0));
              if (OkP2)
                  pSCA->SetCost(Pt3di(x-mP0.x,y-mP0.y,z),aVal);
          }
          zCor.data()[y][x] = zMax;
          CorMax.data()[y][x] = (INT)(255 * (1.0-cMax/900.0));
      }
   }

   cout << "VALS = [" << aVMin << " , " << aVMax << "]\n";

   ELISE_COPY(zCor.all_pts(),CorMax.in(),mW.ogray());
   ELISE_COPY(zCor.all_pts(),zCor.in(),mW2.ogray());

}
예제 #17
0
cInterfaceCoxRoyAlgo * cInterfaceCoxRoyAlgo::NewOne
                       (
                           int xsz,int ysz,
                           signed short ** aDataZmin,
                           signed short ** aDataZmax,
                           bool  Cx8, 
                           bool  OnUChar
                       )
{

   bool VerifCxn = false;
   if (VerifCxn)
   {
       int aNbV = Cx8 ? 8  : 4;
       Pt2di  * aTabV =  Cx8 ? TAB_8_NEIGH : TAB_4_NEIGH;
       int aMinInterv = 100000;

       for (int aX1=0 ; aX1<xsz ; aX1++)
       {
           for (int aY1=0 ; aY1<ysz ; aY1++)
           {
                for (int aKV = 0 ; aKV < aNbV ; aKV++)
                {
                     int aX2 = aX1 + aTabV[aKV].x;
                     int aY2 = aY1 + aTabV[aKV].y;
                     if ((aX2>=0) && (aX2<xsz) && (aY2>=0) && (aY2<ysz))
                     {
                        int aZMin1 = aDataZmin[aY1][aX1];
                        int aZMin2 = aDataZmin[aY2][aX2];
                        int aZMinInter = ElMax(aZMin1,aZMin2);

                        int aZMax1 = aDataZmax[aY1][aX1];
                        int aZMax2 = aDataZmax[aY2][aX2];
                        int aZMaxInter = ElMin(aZMax1,aZMax2);

                        int aSzInterv = aZMaxInter-aZMinInter;

                        ElSetMin(aMinInterv,aSzInterv);

                        if (aSzInterv<=0)
                        {
                             std::cout << aZMinInter << " " << aZMaxInter << "\n";
                             ELISE_ASSERT(false," Bad Conx in Cox Roy");
                        }
                     }
                }
           }
       }
       std::cout << "Verif CX done " << aMinInterv << "\n";
   }


   if (OnUChar)
   {
       if (Cx8)
          return new cV8_UC_CoxRoyAlgo(xsz,ysz,aDataZmin,aDataZmax);
       else
          return new cV4_UC_CoxRoyAlgo(xsz,ysz,aDataZmin,aDataZmax);
   } 
   else
   {
       if (Cx8)
          return new cV8_US_CoxRoyAlgo(xsz,ysz,aDataZmin,aDataZmax);
       else
          return new cV4_US_CoxRoyAlgo(xsz,ysz,aDataZmin,aDataZmax);
   } 
}