void afisare(double lungime, int nivel)
  {
    CVector v(0.0, -1.0);
    CPunct p(-0.3, 0.25);

	init(lungime,p,v);
    Im1(lungime, nivel, p, v);
  }
  void Im1(double lungime, int nivel, CPunct &p, CVector v)
  {
    CPunct p1;
    if (nivel == 0) 
    {
    }
    else
    {

      v.rotatie(-45);
	  v.deseneaza(p,lungime);
	  p1 = v.getDest(p, lungime);
      Im1(lungime/3, nivel - 1, p1, v);

      v.rotatie(90);
      v.deseneaza(p,lungime);
	  p=v.getDest(p,lungime);

	  v.rotatie(10);
	  v.deseneaza(p,lungime);
	  p1 = v.getDest(p, lungime);
	  Im1(lungime/3, nivel - 1, p1, v);

	  v.rotatie(-55);
	  v.deseneaza(p,lungime);
	  p=v.getDest(p,lungime);

	  v.rotatie(30);
	  v.deseneaza(p,lungime/2);
	  p1 = v.getDest(p, lungime/2);
	  Im1(lungime/3, nivel - 1, p1, v);

	  v.rotatie(-120);
	  v.deseneaza(p,lungime/2);
	  p1 = v.getDest(p, lungime/2);
	  Im1(lungime/3, nivel - 1, p1, v);
	}
  }
Ejemplo n.º 3
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);
   }

}
bool GetOpticalFlow(const cv::Mat& Intensity_Ref,const cv::Mat& Intensity_Cur,DImage& vx,DImage& vy,DImage& warpI2)
{
    // Remember to convert the mat img into the corresping type!!!
    assert(Intensity_Ref.type() == CV_8UC1 && Intensity_Cur.type() == CV_8UC1); // we only support three types of image information for now
    assert(Intensity_Ref.size().width == vx.width() && Intensity_Ref.size().height == vx.height());
    assert(Intensity_Cur.size().width == vy.width() && Intensity_Cur.size().height == vy.height());
    DImage Im1(Intensity_Ref.size().width,Intensity_Ref.size().height,1);
    DImage Im2(Intensity_Cur.size().width,Intensity_Cur.size().height,1);
    ImageIO::loadcvMat(Intensity_Ref,Im1.pData);
    ImageIO::loadcvMat(Intensity_Cur,Im2.pData);
    //cout << Im1.pData[0] << endl;
    //cout << Im1.pData[640*480-1] << endl;
    /*
    ofstream o_file1,o_file2;
    o_file1.open("Im1_data.txt");
    o_file2.open("Im2_data.txt");
    int length = Im1.width()*Im1.height();
    for(int i = 0;i<length;i++)
    {
        o_file1 << Im1.pData[i];
        o_file2 << Im2.pData[i];
        if((i+1)%Im1.width()==0)
        {
            o_file1 << "\n";
            o_file2 << "\n";
        }
        else
        {
            o_file1 << " ";
            o_file2 << " ";
        }
    }
    o_file1.close();
    o_file2.close();
    */
    assert(Im1.matchDimension(Im2));
    // get the parameters
    double alpha= 0.012;
    double ratio=0.75;
    int minWidth= 20;
    int nOuterFPIterations = 7;
    int nInnerFPIterations = 1;
    int nSORIterations= 30;

    OpticalFlow::Coarse2FineFlow(vx,vy,warpI2,Im1,Im2,alpha,ratio,minWidth,nOuterFPIterations,nInnerFPIterations,nSORIterations);
}
Ejemplo n.º 5
0
void bench_Box2di::Suppr(Pt2di sz)
{
    Im2D_U_INT1 Im1(sz.x,sz.y,0);
    Im2D_U_INT1 Im2(sz.x,sz.y,0);

    Box2di Add = BoxRand(sz);
    Box2di Suppr = BoxRand(sz);
    
    Set(Im1,Add,1);
    Set(Im1,Suppr,0);
    
    ModelBoxSubstr Model;
    Model.MakeIt(Add,Suppr);

    for (INT k=0 ; k<Model.NbBox() ; k++)
        ELISE_COPY(rectangle(Model.Box(k)),1+Im2.in(),Im2.out());

    verif_equal(Im1,Im2);

}
Ejemplo n.º 6
0
void bench_im_rle(Pt2di sz,INT NbLabel,Pt2di SzBox,INT NbLissage)
{
    typedef EliseRle::tIm  tIm;
    bool  ModeV8 = NRrandom3() > 0.5;
    Im2D<tIm,INT> Im1(sz.x,sz.y);
    Im2D<tIm,INT> Im2(sz.x,sz.y);
    Im2D<tIm,INT> Im3(sz.x,sz.y);
    Im2D<tIm,INT> ImOri(sz.x,sz.y);

    Im2D<tIm,INT> ImBox1(sz.x,sz.y,0);
    Im2D<tIm,INT> ImBox2(sz.x,sz.y,0);

    Fonc_Num f = Iconv(frandr()*20*NbLabel)%NbLabel;
    for (INT k=0 ; k<NbLissage ; k++)
        f = label_maj(f,NbLabel,Pt2di(5,5));


    ELISE_COPY(Im1.all_pts() , f-2, Im1.out()|Im2.out()|Im3.out()|ImOri.out() );
    ELISE_COPY(Im1.border(1) , 0  , Im1.out()|Im2.out()|Im3.out()|ImOri.out() );


    tIm ** data1 = Im1.data();
    tIm ** data2 = Im2.data();


    Neighbourhood V8 = Neighbourhood::v8();     
    Neighbourhood V4 = Neighbourhood::v4();     

    U_INT1 ColBig = NbLabel * 2 +1;
    EliseRle::tContainer  Rles;

    INT cptSmall1 =0; 
    INT cptSmall2 =0; 
    INT cptBig1 =0; 
    INT cptBig2 =0; 
    ELISE_COPY(select(Im1.all_pts(),Im1.in()<0),0,Im1.out());

    BenchConc aBc(NbLabel,false);
    BenchConc * aBcPtr = &aBc;

    if (NRrandom3() >0.5)
        aBcPtr = new BenchConc(NbLabel,true);

    ELISE_COPY
    (
         Im3.all_pts(),
         BoxedConc(Im3.in(0),SzBox,ModeV8,aBcPtr,(INT)(9+SzBox.y*2.9*NRrandom3())),
         Im3.out()
    );


    for (INT y=0; y<sz.y ; y++)
    {
       for (INT x=0; x<sz.x ; x++)
       {
           tIm v1 = data1[y][x];
           Neighbourhood V = ModeV8 ? V8 : V4;
           Liste_Pts_INT2 l2(2);
           if ((v1 >0) && (v1<=NbLabel))
           {
               Pt2di p0,p1;
               ELISE_COPY
               (
                   conc
                   (
                      Pt2di(x,y),
                      Im1.neigh_test_and_set (V,v1,ColBig,ColBig+1)
                   ),
                   Virgule(FX,FY),
                   (l2|p0.VMin()|p1.VMax())
              );
              p1 += Pt2di(1,1);

              if ((p1.x-p0.x<=SzBox.x) && (p1.y-p0.y<=SzBox.y))
              {
                 cptSmall1++;
                 ELISE_COPY(l2.all_pts(),v1+NbLabel,Im1.out());
              }
              else
              {
                 cptBig1++;
              }
              ELISE_COPY(rectangle(p0,p1),(ImBox1.in()+v1)%256,ImBox1.out());
           }

           tIm v2 = data2[y][x];
           if ((v2 >0) && (v2<=NbLabel))
           {
                Box2di Box =  EliseRle::ConcIfInBox
                              (
                                   Pt2di(x,y),
                                   Rles,
                                   data2,
                                   v2,ColBig,
                                   ModeV8,
                                   SzBox
                              );
                if (! Rles.empty())
                {
                   cptSmall2++;
                   EliseRle::SetIm(Rles,data2, v2+NbLabel);
                }
                else
                {
                   cptBig2++;
                }
                ELISE_COPY
                (
                    rectangle(Box._p0,Box._p1),
                    (ImBox2.in()+v2)%256,
                    ImBox2.out()
                );
           }
       }
    }
    ELISE_COPY(select(Im1.all_pts(),ImOri.in()<0),ImOri.in(),Im1.out());

    BENCH_ASSERT(cptSmall2 == cptSmall1);
    BENCH_ASSERT(cptBig2 == cptBig1);
    INT Dif1;
    ELISE_COPY
    (
       Im1.all_pts(),
       Abs(Im1.in()-Im2.in()),
       VMax(Dif1)
    );
    BENCH_ASSERT(Dif1==0);
    ELISE_COPY
    (
       Im1.all_pts(),
       Abs(ImBox1.in()-ImBox2.in()),
       VMax(Dif1)
    );
    BENCH_ASSERT(Dif1==0);


    ELISE_COPY
    (
       Im1.all_pts(),
       Abs(Im1.in()-Im3.in()),
       VMax(Dif1)
    );
    
    BENCH_ASSERT(Dif1==0);
}
Ejemplo n.º 7
0
void bench_op_buf_cat
    (
           Pt2di szIm
    )
{

    Pt2di p0 = Pt2di(Pt2dr(szIm.x*(NRrandom3()/2.1 -0.1),szIm.y *(NRrandom3()/2.1-0.1)));
    Pt2di p1 = Pt2di(Pt2dr(szIm.x*(1.1 -NRrandom3()/2.1),szIm.y *(1.1-NRrandom3()/2.1)));
    INT fact = 50;

    Im2D_REAL8 Im1(szIm.x,szIm.y);
    Im2D_REAL8 Im2(szIm.x,szIm.y);
    ELISE_COPY
    (
         Im1.all_pts(),
         Virgule(unif_noise_4(3) * fact, unif_noise_4(3) * fact),
         Virgule(Im1.out(),Im2.out())
   );


   Box2di aBox(bench_op_buf_cat_PRand_centre(20),bench_op_buf_cat_PRand_centre(20));

    aBox._p0.SetInf(Pt2di(0,0));
    aBox._p1.SetSup(Pt2di(0,0));



    bench_op_buf_cat<INT> ((INT *)0, FX,FY,Virgule(FX,FY), p0,p1);

    Fonc_Num RFonc = Im1.in(0);
    Fonc_Num IFonc = Iconv(Im1.in(0));

    bench_op_buf_cat<INT> 
    ( 
         (INT *) 0,
         rect_som(IFonc,aBox),
         IFonc,
         rect_som(IFonc,aBox,true),
         p0,p1
    );

    bench_op_buf_cat<REAL> 
    ( 
         (REAL *) 0,
         rect_som(RFonc,aBox),
         RFonc,
         rect_som(RFonc,aBox,true),
         p0,p1
    );

    bench_op_buf_cat<REAL> 
    ( 
         (REAL *) 0,
         rect_min(RFonc,aBox),
         RFonc,
         rect_min(RFonc,aBox,true),
         p0,p1
    );

    {
       Fonc_Num f2 = Virgule(IFonc,1-IFonc,FX*1-IFonc);
       bench_op_buf_cat<INT> 
       ( 
            (INT *) 0,
            rect_max(f2,aBox),
            f2,
            rect_max(f2,aBox,true),
            p0,p1
       );
    }

    {
        Fonc_Num RhoTeta = Virgule(Im1.in(0),Im2.in(0));
        REAL Ouv  = NRrandom3();
        bool Oriented = (NRrandom3() > 0.5);
        REAL RhoCalc = 0.1 + 2.0*NRrandom3();
        bench_op_buf_cat<REAL>
        (
             (REAL *) 0,
             RMaxLocDir(RhoTeta,Ouv,Oriented,RhoCalc,false),
             RhoTeta,
             RMaxLocDir(RhoTeta,Ouv,Oriented,RhoCalc,true),
             p0,p1
        );                 
    }

    bench_op_buf_cat<INT> 
    ( 
         (INT *) 0,
         rect_median(IFonc,aBox,256),
         IFonc,
         rect_median(IFonc,aBox,256,true),
         p0,p1
    );

    {
        Fonc_Num  f2 = Virgule(IFonc,mod(IFonc*FX*FY,256));
        bench_op_buf_cat<INT> 
        ( 
             (INT *) 0,
             rect_median(f2,aBox,256),
             f2,
             rect_median(f2,aBox,256,true),
             p0,p1
        );
    }




}