Esempio n. 1
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);
   }

}
Esempio n. 2
0
void ElImplemDequantifier::Test()
{
    INT Z=2;

    Pt2di aSZ = mSzReel - Pt2di(2,2);

    Video_Win aW = Video_Win::WStd(aSZ,Z);
    aW.set_title("Image Quant");
    Video_Win aW2 = Video_Win::WStd(aSZ,Z);
    Video_Win aW3 = Video_Win::WStd(aSZ,Z);
    Video_Win aW4 = Video_Win::WStd(aSZ,Z);
    aW2.set_title("Deq");
    aW3.set_title("Deq+Cuv");
    aW4.set_title("FRELLE");


    Fonc_Num aFR = sin(FX/20.0) * sin(FY/20.0) * 3 +  FX/70.0;

// aFR = 5 * (1- (Square(FX-aSZ.x/2)+Square(FY-aSZ.y/2))/square_euclid(aSZ/2));

    Fonc_Num aFonc = round_ni (aFR);
                    

     Fonc_Num aBase = 0;// aFonc;


    REAL Ampl = 90.0;
    ELISE_COPY(aW.all_pts(),(aFonc -aBase)*Ampl,aW.ocirc());

    DoDequantif(aSZ,aFonc,true);



    ELISE_COPY ( aW2.all_pts(), (ImDeqReelle()-aBase)*Ampl, aW2.ocirc());
    
    SetTraitSpecialCuv(true);
    DoDequantif(aSZ,aFonc,true);
    ELISE_COPY ( aW3.all_pts(), (ImDeqReelle()-aBase)*Ampl, aW3.ocirc());
    ELISE_COPY ( aW4.all_pts(), (aFR-aBase)*Ampl, aW4.ocirc());

/*
    Video_Win aW4 = Video_Win::WStd(aSZ,Z);
    ELISE_COPY 
    ( 
          aW3.all_pts(), 
          Moy(Moy( aF.in(0),3),3) *Ampl,
          aW3.ocirc()
    );
    ELISE_COPY 
    ( 
          aW3.all_pts(), 
          Moy(Moy( ImDeqReelle(),3),3) *Ampl,
          aW4.ocirc()
    );

*/


    while(1) getchar();
}
void cImOfTriplet::InitW(const Pt2dr & aSzMax)
{
      mW  = new Video_Win (Video_Win::LoadTiffWSzMax(mIm->Name(),aSzMax,mZoomW));
      mW->set_title(mIm->Name().c_str());
}
Esempio n. 4
0
Im2D_INT2  TestCoxRoy
           (
                INT         aSzV,
                Im2D_U_INT1 imG1,
                Im2D_U_INT1 imG2,
                Pt2di       aP0,
                Pt2di       aP1,
                INT         aParMin,
                INT         aParMax
           )
{
   ElTimer  aRoyTimer;
   TheP0 = aP0;
   Pt2di aSz = aP1 -aP0;
   Im2D_INT2  aRes (aSz.x,aSz.y);

   TheCorr = new EliseCorrel2D
                 (
                     imG1.in(0),
                     imG2.in(0),
                     imG1.sz(),
                     aSzV,
                     false,
                     -1,
		     true,
		     true
                 );

   Im2D_INT2 aIZMin(aSz.x,aSz.y,(INT2)(aParMin));
   Im2D_INT2 aIZMax(aSz.x,aSz.y,(INT2)(aParMax));

   cInterfaceCoxRoyAlgo * TheCRA = cInterfaceCoxRoyAlgo::NewOne
                (
                      aSz.x,
                      aSz.y,
                      aIZMin.data(),
                      aIZMax.data(),
                      false,
                      false
                );
    InitCostCoxRoy(*TheCRA);





   INT MpdFlow=0;
   if (false)
   {
      cInterfaceCoxAlgo * pSCA =     cInterfaceCoxAlgo::StdNewOne
		                     (
			                 aSz,
			                 0,
			                 aParMax-aParMin,
			                 2,
			                 false
			              );
      for (INT anX=aP0.x ; anX<aP1.x ; anX++)
          for (INT anY=aP0.y ; anY<aP1.y ; anY++)
              for (INT aZ=0 ; aZ<(aParMax-aParMin) ; aZ++)
	      {
		  Pt2di aP(anX,anY);
                  REAL aC = TheCorr->Correl(aP,aP+Pt2di(aZ+aParMin,0));
		  pSCA->SetCost(Pt3di(anX-aP0.x,anY-aP0.y,aZ),MakeCapa(1-aC));
	      }
      MpdFlow =  pSCA->PccMaxFlow();
      Im2D_INT2 aSol = pSCA->Sol(0);   
      Video_Win aW =  Video_Win::WStd(aSol.sz(),1.0);
      aW.set_title("MPD");
      INT aV0,aV1;
      ELISE_COPY(aSol.all_pts(),aSol.in(),VMin(aV0)|VMax(aV1));
      ELISE_COPY(aSol.all_pts(),(aSol.in()-aV0)*(255.0/(aV1-aV0)),aW.ogray());
      delete pSCA;
   }
   cout << "MPD Flow " << MpdFlow << "\n";





    aRoyTimer.reinit();
    INT aFl1 = TheCRA->TopMaxFlowStd(aRes.data());
    cout << "Roy Time = " << aRoyTimer.uval() << "\n";


    ELISE_COPY(aRes.all_pts(),aRes.in(),aRes.out());


    {
        INT aV0,aV1;
        ELISE_COPY(aRes.all_pts(),aRes.in(),VMin(aV0)|VMax(aV1));
        cout << "Cox Roy Interv = " << aV0  << " --- " << aV1 << "\n";
    }

    delete TheCRA;

    INT ecartPlani = 2;
    INT ecartAlti = 5;

    ELISE_COPY
    (
          aIZMin.all_pts(),
          rect_min(aRes.in(aParMax),ecartPlani) -ecartAlti,
          aIZMin.out()
    );
    ELISE_COPY
    (
          aIZMax.all_pts(),
          rect_max(aRes.in(aParMin),ecartPlani) +ecartAlti,
          aIZMax.out()
    );


   Im2D_INT2  aRes2 (aSz.x,aSz.y);
   TheCRA = cInterfaceCoxRoyAlgo::NewOne
                (
                      aSz.x,
                      aSz.y,
                      aIZMin.data(),
                      aIZMax.data(),
                      false,
                      false
                );
    InitCostCoxRoy(*TheCRA);

    aRoyTimer.reinit();
    INT aFl2 = TheCRA->TopMaxFlowStd(aRes2.data());
    cout << "Roy Time 2 = " << aRoyTimer.uval() << "\n";

    INT aNbDif;
    ELISE_COPY
    (
         aRes.all_pts(), 
         aRes.in()!=aRes2.in(),
         sigma(aNbDif)
    );
    BENCH_ASSERT(aNbDif==0);

    cout << "FLOWS : " << aFl1 << " " << aFl2 << "\n";
    cout << "Nb Dif = " << aNbDif << "\n";




    delete TheCorr;
    return aRes;
}
Esempio n. 5
0
void cASAMG::TestImCoher() 
{
    ElTimer aChrono;
    const   std::vector<cASAMG *> & aVN = mCloseNeigh;

    int aNbIm = aVN.size();
    Im2D_REAL4 aImDif(mSz.x,mSz.y,1000);
    TIm2D<REAL4,REAL8> aTDif(aImDif);
    Pt2di aP;

    for (aP.x=0 ; aP.x<mSz.x ; aP.x++)
    {
        for (aP.y=0 ; aP.y<mSz.y ; aP.y++)
        {
             if (mTMasqN.get(aP))
             {
                 Pt3dr aPE = mStdN->PtOfIndex(aP);
                 double aSom=0;
                 for (int aK=0 ; aK<aNbIm ; aK++)
                 {
                     aSom += aVN[aK]->QualityProjOnMe(aPE);
                 }
                 aTDif.oset(aP,aSom);
             }
        }
    }

    for (int aNbRec = 3 ; aNbRec>=0 ; aNbRec --)
    {
        double aSeuil = aNbRec-0.25;
        Fonc_Num aFInside = aImDif.in(-1) > aSeuil;
        if (aNbRec>0)
        {
            eQualCloud aQual = eQC_Coh1;
            if (aNbRec==2) aQual = eQC_Coh2;
            if (aNbRec==3) aQual = eQC_Coh3;
            // Pour ceux qui ont ete valide (aNbRec> 0.75) et non bord ou autre chose ont leur met la bonne valeur
            ELISE_COPY
            (
                 select(mImQuality.all_pts(),aFInside && (mImQuality.in()==eQC_NonAff)),
                 aQual,
                 mImQuality.out()
            );

            ELISE_COPY
            (
                 select
                 (
                      mImQuality.all_pts(),
                         aFInside 
                      && (mImQuality.in()==eQC_GradFaibleC1) 
                      && (erod_32(mMasqN.in_proj(),2*mPrm.DilateBord().Val()))
                 ),
                 eQC_GradFaibleC2,
                 mImQuality.out()
            );
        }
        else
        {
            aFInside =  aImDif.in(-1) <= (aSeuil+1);
            Im2D_Bits<1>   aImLQ(mSz.x,mSz.y);
            ELISE_COPY(aImLQ.all_pts(),aFInside,aImLQ.out());

            ELISE_COPY
            (
                 select(mImQuality.all_pts(), aImLQ.in() && (mImQuality.in()==eQC_NonAff)),
                 eQC_ZeroCohImMul,
                 mImQuality.out()
            );
            ELISE_COPY
            (
                 select
                 (
                     mImQuality.all_pts(),
                     aImLQ.in()&&( mImQuality.in()>=eQC_GradFort) && ( mImQuality.in()<=eQC_Bord)
                 ),
                 eQC_ZeroCohBrd,
                 mImQuality.out()
            );
/*
*/
        }
    }
    ELISE_COPY(mImQuality.border(1),eQC_Out,mImQuality.out());
    InitGlobHisto();

    for (int aK=0 ; aK<mHisto.tx() ; aK++)
    {
        if (mDH[aK])
        {
           mMaxNivH = aK;
        }
    }

   
    Video_Win * aW =  mAppli->Param().VisuImageCoh().Val() ? TheWinIm() : 0 ;
    if (aW)
    {
        aW->set_title(mIma->mNameIm.c_str());
        std::cout << "For " << mIma->mNameIm << " time " << aChrono.uval() << " NbIm " << aNbIm << "\n";
        Fonc_Num fGray = Min(255,aImDif.in() * (255.0/aNbIm));

        for (int aK=0 ; aK<mHisto.tx() ; aK++)
            std::cout << "H[" << aK << "]= " << mHisto.data()[aK] << "\n";
        InspectQual(true);
        
    }
}