当前位置: 首页>>代码示例>>C++>>正文


C++ Board2D::clear方法代码示例

本文整理汇总了C++中Board2D::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Board2D::clear方法的具体用法?C++ Board2D::clear怎么用?C++ Board2D::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Board2D的用法示例。


在下文中一共展示了Board2D::clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testImplicitShape

/**
 * Example of a test. To be completed.
 *
 */
bool testImplicitShape()
{
  unsigned int nbok = 0;
  unsigned int nb = 0;
  
  trace.beginBlock ( "Testing implicit shaper ..." );
  Z2i::Point a(0,0);
  Z2i::Point b(64,64);
  Z2i::Point c(32,32);
  
  Board2D board;
  
  Z2i::Domain domain(a,b);
  Z2i::DigitalSet set(domain);
  
  Shapes<Z2i::Domain>::shaper( set,
			       ImplicitBall<Z2i::Space>( c, 10));
  board << set;
  board.saveSVG("implicitball.svg");

  set.clear();
  board.clear();
  Shapes<Z2i::Domain>::shaper( set,
			       ImplicitHyperCube<Z2i::Space>( c, 10));
  board << set;
  board.saveSVG("implicitcube.svg");
  

  set.clear();
  board.clear();
  Shapes<Z2i::Domain>::shaper( set,
			       ImplicitNorm1Ball<Z2i::Space>( c, 10));
  board << set;
  board.saveSVG("implicitlosange.svg");
  
  set.clear();
  board.clear();
  Shapes<Z2i::Domain>::shaper( set,
			       ImplicitRoundedHyperCube<Z2i::Space>( c, 10, 1));
  board << set;
  board.saveSVG("implicitrounded-1.svg");
  

  set.clear();
  board.clear();
  Shapes<Z2i::Domain>::shaper( set,
			       ImplicitRoundedHyperCube<Z2i::Space>( c, 10, 2.5));
  board << set;
  board.saveSVG("implicitrounded-2.5.svg");
  

  nbok += true ? 1 : 0; 
  nb++;
  trace.info() << "(" << nbok << "/" << nb << ") "
	       << "true == true" << std::endl;
  trace.endBlock();
  
  return nbok == nb;
}
开发者ID:malaterre,项目名称:DGtal,代码行数:63,代码来源:testImplicitShape.cpp

示例2: testDigitalSetBoardSnippet

bool testDigitalSetBoardSnippet()
{
  typedef SpaceND<2> Z2;
  typedef HyperRectDomain<Z2> Domain;
  typedef Z2::Point Point;
  Point p1(  -10, -10  );
  Point p2(  10, 10  );
  Domain domain( p1, p2 );
  typedef DigitalSetSelector < Domain, BIG_DS + HIGH_ITER_DS + HIGH_BEL_DS >::Type SpecificSet;

  BOOST_CONCEPT_ASSERT(( concepts::CDigitalSet< SpecificSet > ));

  SpecificSet mySet( domain );

  Point c(  0, 0  );
  mySet.insert( c );
  Point d(  5, 2  );
  mySet.insert( d );
  Point e(  1, -3  );
  mySet.insert( e );

  Board2D board;
  board.setUnit(LibBoard::Board::UCentimeter);
  board << mySet;
  board.saveSVG("myset-export.svg");

  board.clear();

  board.setUnit(LibBoard::Board::UCentimeter);
  board << SetMode( domain.className(), "Grid" ) << domain << mySet;
  board.saveSVG("simpleSet-grid.svg");

  board.clear();

  board.setUnit(LibBoard::Board::UCentimeter);
  board << SetMode( domain.className(), "Paving" ) << domain;
  board << mySet;
  board.saveSVG("simpleSet-paving.svg");


  board.clear();

  board.setUnit(LibBoard::Board::UCentimeter);
  board << CustomStyle( mySet.className(), new MyDomainStyleCustomRed );
  board << mySet;
  board.saveSVG("simpleSet-color.svg");

  return true;
}
开发者ID:BorisMansencal,项目名称:DGtal,代码行数:49,代码来源:testDigitalSet.cpp

示例3: testDigitalSetBoardSnippet

bool testDigitalSetBoardSnippet()
{
  typedef SpaceND<2> Z2;
  typedef HyperRectDomain<Z2> Domain;
  typedef Z2::Point Point;
  Point p1(  -10, -10  );
  Point p2(  10, 10  );
  Domain domain( p1, p2 );
  typedef DigitalSetSelector < Domain, BIG_DS + HIGH_ITER_DS + HIGH_BEL_DS >::Type SpecificSet;
  SpecificSet mySet( domain );

  Point c(  0, 0  );
  mySet.insert( c );
  Point d(  5, 2  );
  mySet.insert( d );
  Point e(  1, -3  );
  mySet.insert( e );

  Board2D board;
  board.setUnit(Board::UCentimeter);
  board << mySet;
  board.saveSVG("myset-export.svg");

  board.clear();

  board.setUnit(Board::UCentimeter);
  board << DrawDomainGrid() << domain << mySet;
  board.saveSVG("simpleSet-grid.svg");

  board.clear();

  board.setUnit(Board::UCentimeter);
  board << DrawDomainPaving() << domain;
  board << mySet;
  board.saveSVG("simpleSet-paving.svg");


  board.clear();

  board.setUnit(Board::UCentimeter);
  board << CustomStyle( mySet.styleName(), new MyDomainStyleCustomRed );
  board << mySet;
  board.saveSVG("simpleSet-color.svg");

  return true;
}
开发者ID:gdamiand,项目名称:DGtal,代码行数:46,代码来源:testDigitalSet.cpp

示例4: main

int main( int argc, char** argv )
{
  trace.beginBlock ( "Example exampleBezierCurve" );
  trace.info() << "Args:";
  for ( int i = 0; i < argc; ++i )
    trace.info() << " " << argv[ i ];
  trace.info() << endl;

  //control points
  typedef PointVector<2,int> Point;
  Point P(0,0), Q(4,4), R(8,0); 

  //display
  Board2D board; 

  //with fill
  board << SetMode(P.className(), "Grid") << P << Q << R; 
  board.drawQuadraticBezierCurve(P[0], P[1], Q[0], Q[1], R[0], R[1]); 

  board.saveSVG("BezierCurve.svg", Board2D::BoundingBox, 5000 ); 
  board.saveEPS("BezierCurve.eps", Board2D::BoundingBox, 5000 ); 
  board.saveTikZ("BezierCurve.tikz", Board2D::BoundingBox, 5000 ); 
  board.saveFIG("BezierCurve.fig", Board2D::BoundingBox, 5000 ); 
#ifdef WITH_CAIRO
  board.saveCairo("BezierCurve.pdf", Board2D::CairoPDF); 
#endif

  board.clear(); 
  //without fill
  board << SetMode(P.className(), "Grid") << P << Q << R; 
  board.setFillColor(Color::None); 
  board.drawQuadraticBezierCurve(P[0], P[1], Q[0], Q[1], R[0], R[1]); 

  board.saveSVG("BezierCurve2.svg", Board2D::BoundingBox, 5000 ); 
  board.saveEPS("BezierCurve2.eps", Board2D::BoundingBox, 5000 ); 
  board.saveTikZ("BezierCurve2.tikz", Board2D::BoundingBox, 5000 ); 
  board.saveFIG("BezierCurve2.fig", Board2D::BoundingBox, 5000 ); 
#ifdef WITH_CAIRO
  board.saveCairo("BezierCurve2.pdf", Board2D::CairoPDF); 
#endif

  trace.endBlock();
  return 0;
}
开发者ID:BorisMansencal,项目名称:DGtal,代码行数:44,代码来源:exampleBezierCurve.cpp

示例5: main

int main()
{
  trace.beginBlock ( "Board example" );

  Point p1( -3, -2 );
  Point p2( 7, 3 );
  Point p3( 0, 0 );
  Domain domain( p1, p2 );
  

  Board2D board;
  
  //We display the underlying domain
  board << domain ;

  //We display points
  board << p1 << p2 << p3;


  //Output
  board.saveSVG("test.svg");
  board.saveEPS("test.eps");
  board.saveTikZ("test.tikz");
  
  //Clear
  board.clear();
  
  //Upade position + color
  p2[0] = 5; //x-coordinate
  board << domain << p1 << p3;
  
  Color red( 255, 0, 0 );
  
  //All points will be in red
  board  << CustomStyle( p2.className(), new CustomColors( red, red ) )
	 << p2;
  
  //Export again
  board.saveEPS("test2.eps");


  trace.endBlock();
  return 0;
}
开发者ID:Reventl0v,项目名称:lectureDG,代码行数:44,代码来源:simpleboard.cpp

示例6: moduleImages_example

void moduleImages_example()
{
    using namespace Z2i;

    Board2D aBoard;

//! [def]
    using Value = double; // value type  of the image
    using HueShadeDouble = HueShadeColorMap<Value>;   // a simple HueShadeColorMap varying on 'double' values
//! [def]

    trace.beginBlock("image");

//! [raw_image_creation]
    const Domain domain(Point(1,1), Point(16,16));
    Value* data = new Value[ domain.size() ];
    ArrayImageAdapter< Value*, Domain > image( data, domain );
//! [raw_image_creation]

//! [image_filling]
    Value i = 0;
    for ( auto & value : image )
        value = i++;
//! [image_filling]

    aBoard.clear();
    Display2DFactory::drawImage<HueShadeDouble>(aBoard, image, 0, domain.size()-1);
    aBoard.saveSVG("ArrayImageAdapter_image.svg");

    trace.endBlock();

    trace.beginBlock("subImage");

//! [ConstArrayImageAdapterForSubImage_creation]
    Domain subDomain(Point(1,1), Point(8,8));
    ArrayImageAdapter< Value const*, Domain > constSubImage( data, domain, subDomain );
//! [ConstArrayImageAdapterForSubImage_creation]

    aBoard.clear();
    Display2DFactory::drawImage<HueShadeDouble>(aBoard, constSubImage, 0, domain.size()-1);
    aBoard.saveSVG("ArrayImageAdapter_subImage.svg");

    trace.endBlock();

    trace.beginBlock("modifying subImage through domain iterator");
    {
//! [ArrayImageAdapterForSubImage_creation]
        ArrayImageAdapter< Value*, Domain > subImage( data, domain, subDomain );
//! [ArrayImageAdapterForSubImage_creation]
    }

//! [ArrayImageAdapterForSubImage_alternateCreation]
    auto subImage = makeArrayImageAdapterFromIterator( data, domain, subDomain );
//! [ArrayImageAdapterForSubImage_alternateCreation]


//! [ArrayImageAdapterForSubImage_modifByDomain]
    for ( auto point : subImage.domain() )
    {
        Value coord = (point - Point(4,4)).norm();
        subImage.setValue( point, 25*(cos(coord)+1) );
    }
//! [ArrayImageAdapterForSubImage_modifByDomain]

    aBoard.clear();
    Display2DFactory::drawImage<HueShadeDouble>(aBoard, image, 0, domain.size()-1);
    aBoard.saveSVG("ArrayImageAdapter_subImage_modifByDomain.svg");

    trace.endBlock();

    trace.beginBlock("modifying subImage through image iterator");
//! [ArrayImageAdapterForSubImage_modifByImage]
    for ( auto it = subImage.begin(), it_end = subImage.end(); it != it_end; ++it )
    {
        Value coord = (it.getPoint() - Point(4,4)).norm();
        *it = 25*(sin(coord)+1);
    }
//! [ArrayImageAdapterForSubImage_modifByImage]

    aBoard.clear();
    Display2DFactory::drawImage<HueShadeDouble>(aBoard, image, 0, domain.size()-1);
    aBoard.saveSVG("ArrayImageAdapter_subImage_modifByImage.svg");

    trace.endBlock();

    trace.beginBlock("subImage from an ImageContainerBySTLVector");
//! [ImageSTL_creation]
    ImageContainerBySTLVector<Domain, Value> anIterableImage(domain);
    for (auto& value : anIterableImage)
        value = 0;
//! [ImageSTL_creation]

//! [ArrayImageAdapterFromImageSTL]
    {
        ArrayImageAdapter< ImageContainerBySTLVector<Domain,Value>::Iterator, Domain > subImageSTL( anIterableImage.begin(), domain, subDomain );
    }
//! [ArrayImageAdapterFromImageSTL]

//! [ArrayImageAdapterFromImageSTL_alternate]
    auto subImageSTL = makeArrayImageAdapterFromImage( anIterableImage, subDomain );
//.........这里部分代码省略.........
开发者ID:caomw,项目名称:DGtal,代码行数:101,代码来源:exampleArrayImageAdapter.cpp

示例7: main

int main()
{
  trace.beginBlock ( "Example kernelDomain" );
  
  //We create several space models.
  typedef DGtal::SpaceND<3, DGtal::int32_t> MySpace32;
  typedef DGtal::SpaceND<1, DGtal::int64_t> MySpace8;

#ifdef WITH_BIGINTEGER
  typedef DGtal::SpaceND<3, DGtal::BigInteger> MySpaceBIGINTEGER;
#endif

  typedef DGtal::Z2i::Space MySpace; 
  
  //Point lying in the Z2i::Space
  typedef MySpace::Point MyPoint;
  
  MyPoint p(13,-5);
  
  trace.info() << "Point p="<<p<<endl;
  
  //We create a domain
  typedef HyperRectDomain<MySpace> MyDomain;
  MyPoint a(-3,-4);
  MyPoint b(10,4);
  MyDomain domain(a,b);
  
  //We trace  domain information
  trace.info() <<"Domain domain="<<domain<<endl;

  //We generate a board
  Board2D board;
  board << domain;
  board.saveSVG("kernel-domain.svg");

  MyPoint c(5,1);

  if ( domain.isInside(c) )
    trace.info() << "C is inside the domain"<<endl;
  else
    trace.info() << "C is outside the domain"<<endl;
    
  board << c;
  board.saveSVG("kernel-domain-point.svg");
  

  //PointVector example
  MyPoint q;
  MyPoint::Coordinate coord = 24;
  for(MySpace::Dimension d = 0 ; d < MySpace::dimension; d++)
    q[d] = coord;
  trace.info()<<"Q="<<q<<endl;

  MyPoint r;
  for(MyPoint::Iterator it=r.begin(), itend=r.end() ; 
      it != itend;
      ++it)
    (*it) = coord;
  trace.info()<<"R="<<r<<endl;


  //We scan the domain
  for( MyDomain::ConstIterator it = domain.begin(), itend = domain.end();
       it != itend;   
       ++it)
    trace.info() << "Processing point"<< (*it) << endl;
   

  board.clear();
  board << domain;
  //We draw an arrow between two consecutive points during the iteration.
  MyDomain::ConstIterator itPrec = domain.begin();
  MyDomain::ConstIterator it = itPrec;
  MyDomain::Vector shift;
  ++it;

  board << (*itPrec); //We display the first point as a pixel.
  for( MyDomain::ConstIterator itend = domain.end();
       it != itend;   
       ++it, ++itPrec)
    {
      shift =   (*it) -(*itPrec);
      Display2DFactory::draw(board, shift, (*itPrec));
    }
  board.saveSVG("kernel-domain-it-arrow.svg");

  trace.endBlock();
  return 0;
}
开发者ID:Jeremy-Gaillard,项目名称:DGtal,代码行数:89,代码来源:kernelDomain.cpp

示例8: main

int main( int argc, char** argv )
{
  using namespace DGtal;
  using namespace DGtal::Z2i;
  
  typedef ImageContainerBySTLVector<Domain,unsigned char> GrayLevelImage2D;
  typedef ImageContainerBySTLVector<Domain,double>         DoubleImage2D;
  typedef DistanceToMeasure<DoubleImage2D>                 Distance;
  if ( argc <= 3 ) return 1;
  GrayLevelImage2D img  = GenericReader<GrayLevelImage2D>::import( argv[ 1 ] );
  double           mass = atof( argv[ 2 ] );
  double           rmax = atof( argv[ 3 ] );
  double           R    = atof( argv[ 4 ] );
  double           r    = atof( argv[ 5 ] );
  double           T1    = atof( argv[ 6 ] );
  double           T2    = atof( argv[ 7 ] );
  DoubleImage2D     fimg( img.domain() );
  DoubleImage2D::Iterator outIt = fimg.begin();
  for ( GrayLevelImage2D::ConstIterator it = img.begin(), itE = img.end();
        it != itE; ++it )
    {
      double v = ((double)*it) / 255.0;
      *outIt++ = v;
    }
  trace.beginBlock( "Computing delta-distance." );
  Distance     delta( mass, fimg, rmax );
  const DoubleImage2D& d2 = delta.myDistance2;
  trace.endBlock();

  double m = 0.0f;
  for ( typename Domain::ConstIterator it = d2.domain().begin(),
          itE = d2.domain().end(); it != itE; ++it )
    {
      Point p = *it;
      double v = sqrt( d2( p ) );
      m = std::max( v, m );
    }

  GradientColorMap<double> cmap_grad( 0, m );
  cmap_grad.addColor( Color( 255, 255, 255 ) );
  cmap_grad.addColor( Color( 255, 255, 0 ) );
  cmap_grad.addColor( Color( 255, 0, 0 ) );
  cmap_grad.addColor( Color( 0, 255, 0 ) );
  cmap_grad.addColor( Color( 0,   0, 255 ) );
  cmap_grad.addColor( Color( 0,   0, 0 ) );
  Board2D board;
  board << SetMode( d2.domain().className(), "Paving" );
  
  for ( typename Domain::ConstIterator it = d2.domain().begin(),
          itE = d2.domain().end(); it != itE; ++it )
    {
      Point p = *it;
      double v = sqrt( d2( p ) );
      v = std::min( (double) m, std::max( v, 0.0 ) ); 
      board << CustomStyle( p.className(),
                            new CustomColors( Color::Black, cmap_grad( v ) ) )
            << p;
      RealVector grad = delta.projection( p );
      board.drawLine( p[ 0 ], p[ 1 ], p[ 0 ] + grad[ 0 ], p[ 1 ] + grad[ 1 ], 0 );
    }
  std::cout << endl;
  board.saveEPS("dvcm-delta2.eps");
  board.clear();
  
  trace.beginBlock( "Computing delta-VCM." );
  typedef DeltaVCM< Distance > DVCM;
  typedef DVCM::Matrix                     Matrix;
  DVCM dvcm( delta, R, r );
  trace.endBlock();

  {
    GrayLevelImage2D pm_img( dvcm.myProjectedMeasure.domain() );
    DoubleImage2D::ConstIterator it    = dvcm.myProjectedMeasure.begin();
    DoubleImage2D::ConstIterator itE   = dvcm.myProjectedMeasure.end();
    GrayLevelImage2D::Iterator  outIt = pm_img.begin();
    for ( ; it != itE; ++it )
      {
        double v = std::max( 0.0, std::min( (*it) * 255.0, 255.0 ) );
        *outIt++ = v;
      }
    
    GenericWriter< GrayLevelImage2D >::exportFile( "dvcm-projmeasure.pgm", pm_img );
  }

  typedef EigenDecomposition<2,double> LinearAlgebraTool;
  typedef functors::HatPointFunction<Point,double> KernelFunction;
  KernelFunction chi( 1.0, r );

  // Flat zones are metallic blue, slightly curved zones are white,
  // more curved zones are yellow till red.
  double size = 1.0;
  GradientColorMap<double> colormap( 0.0, T2 );
  colormap.addColor( Color( 128, 128, 255 ) );
  colormap.addColor( Color( 255, 255, 255 ) );
  colormap.addColor( Color( 255, 255, 0 ) );
  colormap.addColor( Color( 255, 0, 0 ) );
  Matrix vcm_r, evec, null;
  RealVector eval;
  for ( Domain::ConstIterator it = dvcm.domain().begin(), itE = dvcm.domain().end();
        it != itE; ++it )
//.........这里部分代码省略.........
开发者ID:JacquesOlivierLachaud,项目名称:VCM,代码行数:101,代码来源:delta-vcm.cpp

示例9: main

int main()
{
  trace.beginBlock ( "Example distancetransform2D" );

  //! [DTDef]
  Z2i::Point a ( 0, 0 );
  Z2i::Point b ( 127, 127);
  
  //Input image with unsigned char values
  typedef ImageSelector<Z2i::Domain, unsigned int>::Type Image;
  Image image ( Z2i::Domain(a, b ));

  //We fill the image with the 128 value
  for ( Image::Iterator it = image.begin(), itend = image.end();it != itend; ++it)
    (*it)=128;
  //We generate 16 seeds with 0 values.
  randomSeeds(image,16,0);
  //! [DTDef]

  //Input shape output
  typedef GrayscaleColorMap<Image::Value> Gray;
  Board2D board;
  board.setUnit ( LibBoard::Board::UCentimeter );
  Display2DFactory::drawImage<Gray>(board, image, (unsigned int)0, (unsigned int)129);
  board.saveSVG("inputShape.svg");

  //! [DTPredicate]
  //Point Predicate from random seed image
  typedef functors::SimpleThresholdForegroundPredicate<Image> PointPredicate;
  PointPredicate predicate(image,0);
  //! [DTPredicate]  

  //! [DTCompute]
  typedef  DistanceTransformation<Z2i::Space, PointPredicate, Z2i::L2Metric> DTL2;
  typedef  DistanceTransformation<Z2i::Space, PointPredicate, Z2i::L1Metric> DTL1;
 
 
  DTL2 dtL2(image.domain(), predicate, Z2i::l2Metric);
  DTL1 dtL1(image.domain(), predicate, Z2i::l1Metric);
  //! [DTCompute]


  DTL2::Value maxv2=0;
  //We compute the maximum DT value on the L2 map
  for ( DTL2::ConstRange::ConstIterator it = dtL2.constRange().begin(), itend = dtL2.constRange().end();it != itend; ++it)
    if ( (*it) > maxv2)  maxv2 = (*it);
 
  DTL1::Value maxv1=0;
  //We compute the maximum DT value on the L1 map
  for ( DTL1::ConstRange::ConstIterator it = dtL1.constRange().begin(), itend = dtL1.constRange().end();it != itend; ++it)
    if ( (*it) > maxv1)  maxv1 = (*it);
  
  //! [DTColormaps]
  //Colormap used for the SVG output
  typedef HueShadeColorMap<DTL2::Value, 2> HueTwice;
  //! [DTColormaps]


  
  
  trace.warning() << dtL2 << " maxValue= "<<maxv2<< endl;
  board.clear();
  Display2DFactory::drawImage<HueTwice>(board, dtL2, 0.0, maxv2 + 1);
  board.saveSVG ( "example-DT-L2.svg" );

  trace.warning() << dtL1 << " maxValue= "<<maxv1<< endl;
  board.clear();
  Display2DFactory::drawImage<HueTwice>(board, dtL1, 0.0, maxv1 + 1);
  board.saveSVG ( "example-DT-L1.svg" );

  //Explicit export with ticked colormap
  //We compute the maximum DT value on the L2 map
  board.clear();
  TickedColorMap<double, GradientColorMap<double> > ticked(0.0,maxv2, Color::White);
  ticked.addRegularTicks(5, 0.5);
  ticked.finalize();
  ticked.colormap()->addColor( Color::Red );
  ticked.colormap()->addColor( Color::Black );
  for ( DTL2::Domain::ConstIterator it = dtL2.domain().begin(), itend = dtL2.domain().end();it != itend; ++it)
  {
    board<< CustomStyle((*it).className(),new CustomColors(ticked(dtL2(*it)),ticked(dtL2(*it))));
    board << *it;
  }
  board.saveSVG("example-DT-L2-ticked.svg");
  
  trace.endBlock();
  return 0;
}
开发者ID:Victor-Ostromoukhov,项目名称:DGtal,代码行数:88,代码来源:distancetransform2D.cpp

示例10: testCellDrawOnBoard

bool testCellDrawOnBoard()
{
  typedef typename KSpace::Integer Integer;
  typedef typename KSpace::Cell Cell;
  typedef typename KSpace::SCell SCell;
  typedef typename KSpace::Point Point;
  typedef typename KSpace::DirIterator DirIterator;
  typedef typename KSpace::Cells Cells;
  typedef typename KSpace::SCells SCells;
  typedef SpaceND<2, Integer> Z2;
  typedef HyperRectDomain<Z2> Domain;
  unsigned int nbok = 0;
  unsigned int nb = 0;
  trace.beginBlock ( "Testing cell draw on digital board ..." );
  KSpace K;
  int xlow[ 4 ] = { -3, -3 };
  int xhigh[ 4 ] = { 5, 3 };
  Point low( xlow );
  Point high( xhigh ); 
  bool space_ok = K.init( low, high, true );
  Domain domain( low, high );
  Board2D board;
  board.setUnit( LibBoard::Board::UCentimeter );
  board << SetMode( domain.className(), "Paving" )
  << domain;
  int spel[ 2 ] = { 1, 1 }; // pixel 0,0
  Point kp( spel );
  Cell uspel = K.uCell( kp );
  board << uspel 
  << low << high
  << K.uIncident( uspel, 0, false )
  << K.uIncident( uspel, 1, false );
  int spel2[ 2 ] = { 5, 1 }; // pixel 2,0
  Point kp2( spel2 );
  SCell sspel2 = K.sCell( kp2, K.POS );
  board << CustomStyle( sspel2.className(), 
      new CustomPen( Color( 200, 0, 0 ), 
               Color( 255, 100, 100 ),
               2.0, 
               Board2D::Shape::SolidStyle ) )
  << sspel2 
      << K.sIncident( sspel2, 0, K.sDirect( sspel2, 0 ) )
  << K.sIncident( sspel2, 1, K.sDirect( sspel2, 0 ) );
  board.saveEPS( "cells-1.eps" );
  board.saveSVG( "cells-1.svg" );
  trace.endBlock();
  board.clear();
  board << domain;
  SCell slinel0 = K.sIncident( sspel2, 0, K.sDirect( sspel2, 0 ) );
  SCell spointel01 = K.sIncident( slinel0, 1, K.sDirect( slinel0, 1 ) );
  board << CustomStyle( sspel2.className(), 
      new CustomColors( Color( 200, 0, 0 ), 
            Color( 255, 100, 100 ) ) )
  << sspel2
  << CustomStyle( slinel0.className(), 
      new CustomColors( Color( 0, 200, 0 ), 
            Color( 100, 255, 100 ) ) )
  << slinel0
  << CustomStyle( spointel01.className(), 
      new CustomColors( Color( 0, 0, 200 ), 
            Color( 100, 100, 255 ) ) )
  << spointel01;
  board.saveEPS( "cells-3.eps" );
  board.saveSVG( "cells-3.svg" );
  
  return ((space_ok) && (nbok == nb));
}
开发者ID:kerautret,项目名称:DGtal-forIPOL,代码行数:67,代码来源:testCellularGridSpaceND.cpp

示例11: main

int main()
{
  trace.beginBlock ( "Example distancetransform2D" );

  Z2i::Point a ( 0, 0 );
  Z2i::Point b ( 127, 127);
  
  //Input image with unsigned char values
  typedef ImageSelector<Z2i::Domain, unsigned int>::Type Image;
  Image image ( a, b );

  //We fill the image with the 128 value
  for ( Image::Iterator it = image.begin(), itend = image.end();it != itend; ++it)
    (*it)=128;
  //We generate 16 seeds with 0 values.
  randomSeeds(image,50,0);

  //Colormap used for the SVG output
  typedef HueShadeColorMap<long int, 2> HueTwice;
  typedef GrayscaleColorMap<unsigned char> Gray;
  
  //Input shape output
  Board2D board;
  board.setUnit ( LibBoard::Board::UCentimeter );
  image.selfDraw<Gray> ( board , 0, 129);
  board.saveSVG("inputShape.svg");

  typedef  DistanceTransformation<Image, 2> DTL2;
  typedef  DistanceTransformation<Image, 0> DTLInf;
  typedef  DistanceTransformation<Image, 1> DTL1;
 
  DTL2 dtL2;
  DTLInf dtLinf;
  DTL1 dtL1;
  
  DTL2::OutputImage resultL2 = dtL2.compute ( image );
  DTLInf::OutputImage resultLinf = dtLinf.compute ( image );
  DTL1::OutputImage resultL1 = dtL1.compute ( image );
  
  unsigned int maxv=0;
  //We compute the maximum DT value on the Linf map
  for ( DTLInf::OutputImage::ConstIterator it = resultLinf.begin(), itend = resultLinf.end();it != itend; ++it)
    if ( (*it) > maxv)  maxv = (*it);
  unsigned int maxv2=0;
  //We compute the maximum DT value on the L2 map
  for ( DTL2::OutputImage::ConstIterator it = resultL2.begin(), itend = resultL2.end();it != itend; ++it)
    if ( (*it) > maxv2)  maxv2 = (*it);
  unsigned int maxv1=0;
  //We compute the maximum DT value on the L1 map
  for ( DTL1::OutputImage::ConstIterator it = resultL1.begin(), itend = resultL1.end();it != itend; ++it)
    if ( (*it) > maxv1)  maxv1 = (*it);
  
  
  trace.warning() << resultL2 << " maxValue= "<<maxv2<< endl;
  board.clear();
  resultL2.selfDraw<HueTwice> ( board , 0, maxv2 + 1 );
  board.saveSVG ( "example-DT-L2.svg" );

  trace.warning() << resultL1 << " maxValue= "<<maxv1<< endl;
  board.clear();
  resultL1.selfDraw<HueTwice> ( board , 0, maxv1 + 1 );
  board.saveSVG ( "example-DT-L1.svg" );

  trace.warning() << resultLinf << " maxValue= "<<maxv<< endl;
  board.clear();
  resultLinf.selfDraw<HueTwice> ( board , 0, maxv + 1 );
  board.saveSVG ( "example-DT-Linf.svg" );

  trace.endBlock();
  return 0;
}
开发者ID:gdamiand,项目名称:DGtal,代码行数:71,代码来源:distancetransform2D.cpp

示例12: testDistanceTransformationNeg

/**
 * Example of a test. To be completed.
 *
 */
bool testDistanceTransformationNeg()
{
  unsigned int nbok = 0;
  unsigned int nb = 0;

  trace.beginBlock ( "Testing the whole DT computation" );

  typedef SpaceND<2> TSpace;
  typedef TSpace::Point Point;
  typedef HyperRectDomain<TSpace> Domain;
  typedef HueShadeColorMap<unsigned char, 2> HueTwice;
  typedef GrayscaleColorMap<unsigned char> Gray;
  Point a ( -10, -10 );
  Point b ( 10, 10 );
  typedef ImageSelector<Domain, unsigned int>::Type Image;
  Image image ( a, b );

  for(int y=-10; y<=10;y++) 
    for(int x=-10; x<=10;x++)
      {
  if ((abs(x)<7) && (abs(y)<5))
    image.setValue(Point(x,y),1);
  else
    image.setValue(Point(x,y),0);
      }
  
  DistanceTransformation<Image, 2> dt;
  typedef DistanceTransformation<Image, 2>::OutputImage ImageLong;

  dt.checkTypesValidity ( image );

  Board2D board;
  board.setUnit ( LibBoard::Board::UCentimeter );
  image.selfDraw<Gray> ( board, 0, 1 );
  board.saveSVG ( "image-preDT-neg.svg" );


  for(int y=-10; y<=10;y++) 
    {
      for(int x=-10; x<=10;x++)
  {
    std::cout<<image(Point(x,y))<<"  ";
  }
      std::cout<<std::endl;
    }
  

  ImageLong result = dt.compute ( image );
  
  DGtal::int64_t maxv=0;
  for(ImageLong::Iterator it = result.begin(), itend = result.end();
      it != itend ; ++it)
    if (result(it) > maxv)
      maxv = result(it);

  for(int y=-10; y<=10;y++) 
    {
      for(int x=-10; x<=10;x++)
  {
    std::cout<<result(Point(x,y))<<"  ";
  }
      std::cout<<std::endl;
    }
  


  trace.warning() << result << endl;

  board.clear();
  result.selfDraw<Gray> ( board, 0, maxv );
  board.saveSVG ( "image-postDT-neg.svg" );


  trace.info() << result << endl;

  trace.endBlock();

  return nbok == nb;
}
开发者ID:gdamiand,项目名称:DGtal,代码行数:83,代码来源:testDistanceTransformation.cpp

示例13: testSimplePoints2D


//.........这里部分代码省略.........
  Shapes<Domain>::addNorm1Ball( shape_set, Point( -10, -8 ), 7 );
  Shapes<Domain>::addNorm1Ball( shape_set, Point( 10, 8 ), 7 );
  Shapes<Domain>::addNorm1Ball( shape_set, Point( 3, 0 ), 6 );
  Shapes<Domain>::addNorm1Ball( shape_set, Point( 0, -3 ), 7 );
  Shapes<Domain>::addNorm1Ball( shape_set, Point( -10, 0 ), 6 );
  Shapes<Domain>::addNorm1Ball( shape_set, Point( -8, 8 ), 6 );
  Shapes<Domain>::addNorm1Ball( shape_set, Point( 0, 9 ), 6 );
  Shapes<Domain>::addNorm1Ball( shape_set, Point( 15, -2 ), 6 );
  Shapes<Domain>::addNorm1Ball( shape_set, Point( 12, -10 ), 4 );
  shape_set.erase( Point( 5, 0 ) );
  shape_set.erase( Point( -1, -2 ) );
  Object4_8 shape( dt4_8, shape_set );
  Object8_4 shape2( dt8_4, shape_set );

  GradientColorMap<int> cmap_grad( 0, 6 );
  cmap_grad.addColor( Color( 128, 128, 255 ) );
  cmap_grad.addColor( Color( 255, 255, 128 ) );
  //cmap_grad.addColor( Color( 220, 130, 25 ) );
  Board2D board;
  board.setUnit(Board::UCentimeter);
  board << SetMode( domain.styleName(), "Paving" ) // DrawDomainPaving()
  << domain;
  Board2D board2;
  board2.setUnit(Board::UCentimeter);
  board2 << SetMode( domain.styleName(), "Grid" ) // DrawDomainGrid()
   << domain;

  // Greedy thinning.
  DGtal::uint64_t nb_simple;
  trace.beginBlock ( "Greedy homotopic thinning ..." );
  int layer = 0;
  do 
    {
      DigitalSet & S = shape.pointSet();
      std::queue<DigitalSet::Iterator> Q;
      for ( DigitalSet::Iterator it = S.begin(); it != S.end(); ++it )
  if ( shape.isSimple( *it ) )
    Q.push( it );
      nb_simple = 0;
      while ( ! Q.empty() )
  {
    DigitalSet::Iterator it = Q.front();
    Q.pop();
    if ( shape.isSimple( *it ) )
      {
        board << CustomStyle( it->styleName(), 
                   new MyDrawStyleCustomFillColor
                   ( cmap_grad( layer ) ) )
        << *it;
        S.erase( *it );
        ++nb_simple;
      }
  }
      ++layer;
    }
  while ( nb_simple != 0 );
  trace.endBlock();

  // Greedy thinning.
  trace.beginBlock ( "Greedy homotopic thinning ..." );
  layer = 0;
  do 
    {
      DigitalSet & S = shape2.pointSet();
      std::queue<DigitalSet::Iterator> Q;
      for ( DigitalSet::Iterator it = S.begin(); it != S.end(); ++it )
  if ( shape2.isSimple( *it ) )
    Q.push( it );
      nb_simple = 0;
      while ( ! Q.empty() )
  {
    DigitalSet::Iterator it = Q.front();
    Q.pop();
    if ( shape2.isSimple( *it ) )
      {
        board2 << CustomStyle( it->styleName(), 
                   new MyDrawStyleCustomFillColor
             ( cmap_grad( layer ) ) )
         << *it;
        S.erase( *it );
        ++nb_simple;
      }
  }
      ++layer;
    }
  while ( nb_simple != 0 );
  trace.endBlock();
  
  board  << CustomStyle( shape.styleName(), new MyDrawStyleCustomRed )
  << shape;
  board.saveSVG( "shape-thinning-4-8.svg");
  board.clear();

  board2 << CustomStyle( shape2.styleName(), new MyDrawStyleCustomRed )
   << shape2;
  board2.saveSVG( "shape-thinning-8-4.svg");
  board2.clear();
  
  return nbok == nb;
}
开发者ID:gdamiand,项目名称:DGtal,代码行数:101,代码来源:testObject.cpp

示例14: main

int main( int /*argc*/, char** /*argv*/ )
{
  trace.beginBlock ( "Example voronoimap2D" );

  //! [Voro2D-Metric]
  typedef ExactPredicateLpSeparableMetric<Z2i::Space, 2> L2Metric;
  L2Metric l2;
  //! [Voro2D-Metric]

  //! [Voro2D-SmallImage]
  Z2i::Point lower(0,0);
  Z2i::Point upper(16,16);
  Z2i::Domain domain(lower,upper);

  Z2i::DigitalSet set(domain);
  set.insertNew(Z2i::Point(2,3));
  set.insertNew(Z2i::Point(7,15));
  set.insertNew(Z2i::Point(12,5));
  Board2D board;

  board<< domain << set;
  board.saveSVG("voronoimap-inputset.svg");
  //! [Voro2D-SmallImage]

  //! [Voro2D-Predicate]
  typedef NotPointPredicate<Z2i::DigitalSet> NotPredicate;
  NotPredicate notSetPred(set);
  //! [Voro2D-Predicate]

  //! [Voro2D-Voro]
  typedef VoronoiMap<Z2i::Space, NotPredicate, L2Metric > Voronoi2D;
  Voronoi2D voronoimap(domain,notSetPred,l2);
  //! [Voro2D-Voro]

  //! [Voro2D-trace]
  board.clear();
  board << domain;
  for(Voronoi2D::Domain::ConstIterator it = voronoimap.domain().begin(),
      itend = voronoimap.domain().end(); it != itend; ++it)
  {
    Voronoi2D::Value site = voronoimap( *it );   //closest site to (*it)
    if (site != (*it))
      Display2DFactory::draw( board,   site - (*it), (*it)); //Draw an arrow
  }
  board.saveSVG("voronoimap-voro.svg");
  //! [Voro2D-trace]

  //! [Voro2D-traceCell]
  board.clear();
  for(Voronoi2D::Domain::ConstIterator it = voronoimap.domain().begin(),
      itend = voronoimap.domain().end(); it != itend; ++it)
  {
    Voronoi2D::Value site = voronoimap( *it );   //closest site to (*it)
    unsigned char c = (site[1]*13 + site[0] * 7) % 256; //basic hashfunction
    board << CustomStyle( (*it).className(), new CustomColors(Color(c,c,c),Color(c,c,c)))
      << (*it);
  }
  board.saveSVG("voronoimap-cells.svg");
  //! [Voro2D-traceCell]


  //! [Voro2D-l8Metric]
  typedef ExactPredicateLpSeparableMetric<Z2i::Space, 8> L8Metric;
  L8Metric l8;
  typedef VoronoiMap<Z2i::Space, NotPredicate, L8Metric > Voronoi2D_l8;
  Voronoi2D_l8 voronoimap_l8(domain,notSetPred,l8);
  board.clear();
  board << domain;
  for(Voronoi2D_l8::Domain::ConstIterator it = voronoimap_l8.domain().begin(),
      itend = voronoimap_l8.domain().end(); it != itend; ++it)
  {
    Voronoi2D::Value site = voronoimap_l8( *it );   //closest site to (*it)
    unsigned char c = (site[1]*13 + site[0] * 7) % 256; //basic hashfunction
    board << CustomStyle( (*it).className(), new CustomColors(Color(c,c,c),Color(c,c,c)))
          << (*it);
  }
  board.saveSVG("voronoimap-vorol8.svg");
  //! [Voro2D-l8Metric]

  //! [Voro2D-DT]
  typedef DistanceTransformation<Z2i::Space, NotPredicate, L2Metric > DT;
  DT dt(domain,notSetPred,l2);
  board.clear();
  board << domain;

  //Fast max computation on the range value
  DT::Value maxDT=0.0;
  for(DT::ConstRange::ConstIterator it = dt.constRange().begin(), itend = dt.constRange().end();
      it != itend ; ++it)
    if ((*it)>maxDT) maxDT = (*it);

  //Colormap
  HueShadeColorMap<DT::Value,1> hueMap(0.0,maxDT);

  //Drawing
  for(DT::Domain::ConstIterator it = dt.domain().begin(),
      itend = dt.domain().end(); it != itend; ++it)
  {
    DT::Value dist = dt( *it );   //distance to closest site to (*it)
    board << CustomStyle( (*it).className(), new CustomColors( hueMap(dist), hueMap(dist)))
//.........这里部分代码省略.........
开发者ID:BorisMansencal,项目名称:DGtal,代码行数:101,代码来源:voronoimap2D.cpp

示例15: testDistanceTransformation

/**
 * Example of a test. To be completed.
 *
 */
bool testDistanceTransformation()
{
  unsigned int nbok = 0;
  unsigned int nb = 0;

  trace.beginBlock ( "Testing the whole DT computation" );

  typedef SpaceND<2> TSpace;
  typedef TSpace::Point Point;
  typedef HyperRectDomain<TSpace> Domain;
  typedef HueShadeColorMap<unsigned char, 2> HueTwice;
  typedef GrayscaleColorMap<unsigned char> Gray;
  Point a ( 2, 2 );
  Point b ( 15, 15 );
  typedef ImageSelector<Domain, unsigned int>::Type Image;
  Image image ( a, b );

  for ( unsigned k = 0; k < 49; k++ )
  {
    a[0] = ( k / 7 ) + 5;
    a[1] = ( k % 7 ) + 5;
    image.setValue ( a, 128 );
  }



  DistanceTransformation<Image, 2> dt;
  typedef DistanceTransformation<Image, 2>::OutputImage ImageLong;

  dt.checkTypesValidity ( image );

  Board2D board;
  board.setUnit ( LibBoard::Board::UCentimeter );
  image.selfDraw<Gray> ( board, 0, 255 );
  board.saveSVG ( "image-preDT.svg" );
  //We just iterate on the Domain points and print out the point coordinates.
  std::copy ( image.begin(),
        image.end(),
        std::ostream_iterator<unsigned int> ( std::cout, " " ) );
  
  
  
  ImageLong result = dt.compute ( image );
  
  trace.warning() << result << endl;
  //We just iterate on the Domain points and print out the point coordinates.
  ImageLong::ConstIterator it = result.begin();
  for (unsigned int y = 2; y < 16; y++)
  {
    for (unsigned int x = 2; x < 16; x++)
    {
      std::cout << result(it) << " ";
      ++it;
    }
    std::cout << std::endl;
  }



  board.clear();
  result.selfDraw<Gray> ( board, 0, 16 );
  board.saveSVG ( "image-postDT.svg" );


  trace.info() << result << endl;

  trace.endBlock();

  return nbok == nb;
}
开发者ID:gdamiand,项目名称:DGtal,代码行数:74,代码来源:testDistanceTransformation.cpp


注:本文中的Board2D::clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。