Пример #1
0
float SimilByCorrel
      (
         int aSzW,
         const cTD_Im & aIm1,const Pt2di & aP1,
         const cTD_Im & aIm2,const Pt2di & aP2
      )
{
    if (! 	VignetteInImage(aSzW,aIm1,aP1)) return Beaucoup;
    if (! 	VignetteInImage(aSzW,aIm2,aP2)) return Beaucoup;

	RMat_Inertie aMat;
    
    Pt2di aDP;
    for (aDP.x= -aSzW ; aDP.x<= aSzW ; aDP.x++)
    {
        for (aDP.y= -aSzW ; aDP.y<= aSzW ; aDP.y++)
        {
			float aV1 = aIm1.GetVal(aP1+aDP);
			float aV2 = aIm2.GetVal(aP2+aDP);
			aMat.add_pt_en_place(aV1,aV2,1.0);
		}
	}

	return 1-aMat.correlation();
}
Пример #2
0
		  float SimilByCorrel
		  (
		    const Pt2di & aP1,
			const cTD_OneScale & aIm2,const Pt2di & aP2
		  ) const
		  {
			  RMat_Inertie aMat;
			  FillInertie(aMat,aP1,aIm2,aP2);
			  
			  return 1- aMat.correlation();
		  }
Пример #3
0
void TestNtt(const std::string &aName)
{
    Tiff_Im aTF = Tiff_Im::StdConvGen(aName,1,true);

    Pt2di aSz = aTF.sz();
    Im2D_REAL4 aI0(aSz.x,aSz.y);
    ELISE_COPY( aTF.all_pts(),aTF.in(),aI0.out());

    int aWSz=2;

    TIm2D<REAL4,REAL8> aTIm(aI0);

     double aSomGlob=0.0;
     double aNbGlob=0.0;

     for (int aKdx=-aWSz ; aKdx<=aWSz ; aKdx+=aWSz)
     {
         printf("## ");
         for (int aKdy=-aWSz ; aKdy<=aWSz ; aKdy+=aWSz)
         {
             int aDx = aKdx;
             int aDy = aKdy;
             Pt2di aDep(aDx,aDy);
             Pt2di aP;
             RMat_Inertie aMat;
             for (aP.x = aWSz ; aP.x<aSz.x-aWSz ; aP.x++)
             {
                 for (aP.y=aWSz ; aP.y<aSz.y-aWSz ; aP.y++)
                 {
                      aMat.add_pt_en_place(aTIm.get(aP),aTIm.get(aP+aDep));
                 }
             }
             double aC = aMat.correlation();
             aC = 1-aC;
             if (dist8(aDep) == aWSz)
             {
                aSomGlob += aC;
                aNbGlob ++;
             }
             printf(" %4d",round_ni(10000*(aC)));
         }
         printf("\n");
     }
     aSomGlob /= aNbGlob;
     std::cout  <<  " G:" << aSomGlob << "\n";
     printf("\n\n");
  
}
Пример #4
0
		float SimilByCatCorrel
			  (
				const Pt2di & aP1,
				const cTD_PyrMultiScale & aPyr2,
				const Pt2di & aP2
				) const 
		{
			if ((!InPyram(aP1)) || (!aPyr2.InPyram(aP2)))
				return 2 ;
			
			RMat_Inertie aMat;
			for (int aK=0 ; aK<mNbIm ; aK++)
			{
				const cTD_OneScale&  aSC1 = mVecIms[aK];
				const cTD_OneScale&  aSC2 = aPyr2.mVecIms[aK];

				aSC1.FillInertie(aMat,aP1,aSC2,aP2);
			}
			
			return 1-aMat.correlation();
		}
double cMC_PairIm::Correl(Pt2dr aPTER,int aSzW,double * aVPx)
{
    RMat_Inertie aMat;

    Pt2di aDP;
    for (aDP.x=-aSzW ; aDP.x<=aSzW; aDP.x++)
    {
        for (aDP.y=-aSzW ; aDP.y<=aSzW; aDP.y++)
        {
	    Pt2dr aQTer = aPTER +  (Pt2dr(aDP) * double(mDZ*mResolZ1));

	    Pt2dr aPI1 = mPDV1.Geom().Objet2ImageInit_Euclid(aQTer,aVPx) / double(mDZ);
	    Pt2dr aPI2 = mPDV2.Geom().Objet2ImageInit_Euclid(aQTer,aVPx) / double(mDZ);
	    if (mTI1.Rinside_bilin(aPI1) && (mTI2.Rinside_bilin(aPI2)))
	    {
	       aMat.add_pt_en_place(mTI1.getr(aPI1),mTI2.getr(aPI2));
	    }
	    else
	       return -1;
        }
    }

    return aMat.correlation();
}
Пример #6
0
bool  cOneTestLSQ::OneLSQItere()
{
   if (!OK(Pt2dr(0,0))) return false;

   ClearStat();
   int aCpt=0;

   RMat_Inertie aMat;
   double aDif = 0;

   for(int aKx=-mNbW; aKx<=mNbW; aKx++)
   {
       for(int aKy=-mNbW; aKy<=mNbW; aKy++)
       {
          Pt2dr aP2 = mIm2->PVois(aKx,aKy);

          Pt3dr aGV2 =  mIm2->GetValDer(aP2);


           double aV1 = mValsIm1[aCpt];
          // double aV1 = mIm1.GetVal(mIm1.PVois(aKx,aKy));
          double aV2 = aGV2.z;
          double aGx = aGV2.x;
          double aGy = aGV2.y;

          aDif += ElSquare(aV1-aV2);
          aMat.add_pt_en_place(aV1,aV2);

          // Pour verifier la justesse des moindres carres
          if (0)
          {
              aV2 = 50 + 2 * aV1  - 0.5* aGx -0.25 * aGy;
          }

          mCov[IndK0][IndK0] += 1;
          mCov[IndK0][IndK1] += aV1;
          mCov[IndK0][IndKx] -= aGx;
          mCov[IndK0][IndKy] -= aGy;

          mCov[IndK1][IndK1] += aV1*aV1;
          mCov[IndK1][IndKx] -= aV1*aGx;
          mCov[IndK1][IndKy] -= aV1*aGy;

          mCov[IndKx][IndKx] += aGx*aGx;
          mCov[IndKx][IndKy] += aGx*aGy;

          mCov[IndKy][IndKy] += aGy*aGy;

          mSomI2[IndK0] += aV2;
          mSomI2[IndK1] += aV1 * aV2;
          mSomI2[IndKx] -= aV2 * aGx;
          mSomI2[IndKy] -= aV2 * aGy;

          aCpt++;
       }
   }

   for(int aK1=0; aK1<NbInc; aK1++)
   {
       mMatI2(0,aK1) = mSomI2[aK1];
       for(int aK2=0; aK2<=aK1; aK2++)
       {
           mMatCov(aK1,aK2) =  mMatCov(aK2,aK1) = mCov[aK2][aK1];
       }
   }


   jacobi_diag(mMatCov,mValP,mVecP);

   double aVPMin = 1e10;
   for(int aK1=0; aK1<NbInc; aK1++)
      aVPMin = std::min(aVPMin,mValP(aK1,aK1));

   if (aVPMin<1e-8) return false;


   mSolLSQ = gaussj(mMatCov) * mMatI2;
   mCorel0LSQ = aMat.correlation();


   mDepLSQ = Pt2dr(mSolLSQ(0,2), mSolLSQ(0,3));



   mDeps.push_back(mDepLSQ);

   return true;
}