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


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

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


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

示例1: testDisplay

/**
 * testDisplay
 *
 */
bool testDisplay()
{
  typedef FreemanChain<int> FreemanChain;
  //typedef FreemanChain::Point Point;
  //typedef FreemanChain::Vector Vector;
  //typedef FreemanChain::ConstIterator Iterator;
  //typedef std::vector<unsigned int> numVector;

  Board2D aBoard;
  aBoard.setUnit(Board::UCentimeter);
  
  fstream fst;
  fst.open ((testPath + "samples/contourS.fc").c_str() , ios::in);
  FreemanChain fc(fst);  

  aBoard.setPenColor(Color::Red);
  
  //aBoard << DrawPavingPixel();
  
  aBoard << fc;
  
  std::string filenameImage = testPath + "samples/contourS.png"; // ! only PNG with Cairo for the moment !
  LibBoard::Image image( 0, 84, 185, 85, filenameImage, 20 ); 
  image.shiftDepth(500);
  LibBoard::Board & board = aBoard;
  board << image;
  
  aBoard.saveSVG( "testDisplayFC.svg", Board::BoundingBox, 5000 );
  aBoard.saveEPS( "testDisplayFC.eps", Board::BoundingBox, 5000 );
  aBoard.saveFIG( "testDisplayFC.fig", Board::BoundingBox, 5000 );
  
#ifdef WITH_CAIRO
  aBoard.saveCairo("testDisplayFC-cairo.pdf", Board2D::CairoPDF, Board::BoundingBox, 5000);
  aBoard.saveCairo("testDisplayFC-cairo.png", Board2D::CairoPNG, Board::BoundingBox, 5000);
  aBoard.saveCairo("testDisplayFC-cairo.ps",  Board2D::CairoPS,  Board::BoundingBox, 5000);
  aBoard.saveCairo("testDisplayFC-cairo.svg", Board2D::CairoSVG, Board::BoundingBox, 5000);
#endif
  
  return true;
}
开发者ID:arnaudetitia,项目名称:DGtal,代码行数:44,代码来源:testFreemanChain.cpp

示例2: main

int main()
{
  trace.beginBlock ( "Example dgtalboard-3-custom-classes" );

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

  Color red( 255, 0, 0 );
  Color dred( 192, 0, 0 );
  Color dgreen( 0, 192, 0 );
  Color blue( 0, 0, 255 );
  Color dblue( 0, 0, 192 );
  
  Board2D board;
  board << domain 
  << CustomStyle( p1.styleName(), new CustomColors( red, dred ) )
  << p1
  << CustomStyle( p2.styleName(), new CustomFillColor( dgreen ) )
  << p2
  << CustomStyle( p3.styleName(), 
      new CustomPen( blue, dblue, 6.0, 
               Board2D::Shape::SolidStyle,
               Board2D::Shape::RoundCap,
               Board2D::Shape::RoundJoin ) )
  << p3;
  board.saveSVG("dgtalboard-3-custom-classes.svg");
  board.saveEPS("dgtalboard-3-custom-classes.eps");

#ifdef WITH_CAIRO
  board.saveCairo("dgtalboard-3-custom-classes-cairo.pdf", Board2D::CairoPDF);
  board.saveCairo("dgtalboard-3-custom-classes-cairo.png", Board2D::CairoPNG);
  board.saveCairo("dgtalboard-3-custom-classes-cairo.ps", Board2D::CairoPS);
  board.saveCairo("dgtalboard-3-custom-classes-cairo.svg", Board2D::CairoSVG);
#endif
  
  trace.endBlock();
  return 0;
}
开发者ID:gdamiand,项目名称:DGtal,代码行数:40,代码来源:dgtalBoard2D-3-custom-classes.cpp

示例3: main

int main(int /*argc*/, char** /*argv*/)
{
  


////////////////////////////////////////
  Board2D board;
  board.setUnit(Board2D::UCentimeter);
  board.drawArc(0.0, 1.0, 5.0, 0, M_PI/2.0, false); 
  board.drawArc(0.0, 1.0, 4.0, 0, M_PI/2.0, true); 
  board.drawArc(0.0, 1.0, 3.0, -0.5, M_PI/2.0-0.5, false); 
  board.drawArc(0.0, 1.0, 2.0, 0.5, M_PI/2.0+0.5, false); 
  board.saveEPS( "essai.eps" );
  board.saveSVG( "essai.svg" );  
  board.saveTikZ( "essai.tikz" );
#ifdef WITH_CAIRO
    board.saveCairo("essai.pdf", Board2D::CairoPDF);
#endif
////////////////////////////////////////

  return 0;
}
开发者ID:BorisMansencal,项目名称:DGtal,代码行数:22,代码来源:testArcDrawing.cpp

示例4: saveGranulo

/**
* Save the granometric function values stored in an image into an EPS file
*
* @param granuloImage The image containing the granulometric function values
*
* @param maxGranulo The maximum value of the granulometric function
*
* @param fileName A string containing the filename where we store the image
*/
void saveGranulo(myLittleImage& granuloImage, unsigned int maxGranulo, string fileName)
{
	Board2D board;
	HueTwice colorMap(1,maxGranulo+1);
	Point O(0,0);
	string specificStyle =  O.className() + "/Paving";
	Color white(255,255,255);
    board << SetMode(granuloImage.domain().className(), "Paving")
      	  << granuloImage.domain()
          << SetMode(O.className(), "Paving");

   	for (myLittleImage::Domain::ConstIterator it = granuloImage.domain().begin(); it != granuloImage.domain().end(); ++it)
    {
    	if (granuloImage(*it) > 0)
		{
			Color c = colorMap(granuloImage(*it));
       		board << CustomStyle(specificStyle, new CustomColors(c,c)) << *it;
		}
		else
			board << CustomStyle(specificStyle, new  CustomColors(white,white)) << *it;
    }
    board.saveEPS(fileName.c_str());
}
开发者ID:WilliamAufort,项目名称:ImageIndexing,代码行数:32,代码来源:granulometry.cpp

示例5: aComputer

int 
main(int argc, char ** argv){
  typedef Z2i::Point Point;
  std::vector<Point> contour = PointListReader<Point>::getPointsFromFile("../Samples/contourS.sdp");
  Board2D aBoard;
  for (auto&& p :contour) {
    aBoard << p;
  }
  aBoard.setPenColor(DGtal::Color::Red);
  aBoard.setFillColor(DGtal::Color::Red);
  aBoard.drawCircle(contour[30][0], contour[30][1],1); 
  unsigned int startIndex = 30;
  typedef  AlphaThickSegmentComputer< Z2i::Point > AlphaThickSegmentComputer2D;
  AlphaThickSegmentComputer2D aComputer(5);
  aComputer.init(contour.begin()+30);
  while(aComputer.extendFront()){
  }

  aBoard  << CustomStyle( aComputer.className(), new CustomColors( DGtal::Color::Blue, DGtal::Color::None ) );  
  aBoard << aComputer;
  aBoard.saveEPS("resultTuto2.eps");
  
  return 0;
}
开发者ID:kerautret,项目名称:MT_DGtalTutoIWCIA,代码行数:24,代码来源:tuto2_compAlphaThickSegment.cpp

示例6: testCircleFrom3Points

bool testCircleFrom3Points()
{

  trace.beginBlock("Simple test for CircleFrom3Points"); 
  
  typedef PointVector<2,Coordinate> Point; 
  CircleFrom3Points<Point> c; 
  Point o(0,0); 

  {
    c.init( Point(0,1), Point(150,18), Point(250,-48) ); 
    trace.info() << c << endl;
    trace.info() << o << " is at distance " << c.signedDistance(o) << endl;
    if (c.signedDistance(o) != -4026300) return false; 
  }
  {
    c.init( Point(0,1), Point(150,18), Point(100,48) ); 
    trace.info() << c << endl;
    trace.info() << o << " is at distance " << c.signedDistance(o) << endl;
    if (c.signedDistance(o) != 442200) return false; 
  }
  {
    c.init( Point(8,4), Point(9,3), Point(10,0) ); 
    trace.info() << c << endl;
    trace.info() << o << " is at distance " << c.signedDistance(o) << endl;
    if (c.signedDistance(o) != 0) return false;
    double cx, cy, r; 
    c.getParameters(cx, cy, r); 
    if ( (cx != 5.0)||(cy != 0.0) )
    {
      trace.emphase() << "error in returned center" << endl;
      trace.info() << "(" << cx << "," << cy << ") " << endl;
      trace.info() << "instead of (5,0)" << endl;
      return false; 
    } 
  }
  {
    c.init( Point(0,0), Point(150,20), Point(15,2) ); 
    trace.info() << c << endl;
    trace.info() << o << " is at distance " << c.signedDistance(o) << endl;
    if (c.signedDistance(o) != 0) return false; 
  }

  Board2D board; 
  board << SetMode(o.className(), "Grid") << o; 
  {
    c.init( Point(8,4), Point(9,3), Point(10,0) ); 
    trace.info() << "arc drawing" << endl;
    
    board << SetMode( c.className(), "Arc" );
    Display2DFactory::draw(board, c, Point(5,10), Point(8,4));
    
    board << SetMode( c.className(), "Sector" );
    Display2DFactory::draw(board, c, Point(9,3), Point(10,0) );
    
    board << SetMode( c.className(), "Annulus" );
    Display2DFactory::draw(board, c, Point(5,-10), Point(2,-4) );
    
    board.saveEPS("arcDisplay.eps");
  }


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

示例7: testSurfelAdjacency


//.........这里部分代码省略.........
    for ( Dimension j = 0; j < K.dimension; ++j )
      if ( i != j )
  trace.info() << "(" << i << "," << j << ")=" 
         << ( SAdj.getAdjacency( i, j ) ? "i2e" : "e2i" );
  trace.info() << endl;
  trace.endBlock();

  int spel[ 4 ] = { 1, 1, 1, 1 }; // pixel
  Point kp( spel );
  SCell sspel = K.sCell( kp, K.POS );
  trace.beginBlock ( "Testing surfel directness ..." );
  for ( Dimension k = 0; k < K.dimension; ++k )
    {
      SCell surfel = K.sIncident( sspel, k, true );
      SCell innerspel = K.sDirectIncident( surfel, K.sOrthDir( surfel ) );
      trace.info() << "spel=" << sspel << " surfel=" << surfel
       << " innerspel=" << innerspel << endl;
      nbok += sspel == innerspel ? 1 : 0; 
      nb++;
      trace.info() << "(" << nbok << "/" << nb << ") "
       << "spel == innerspel" << std::endl;
      surfel = K.sIncident( sspel, k, false );
      innerspel = K.sDirectIncident( surfel, K.sOrthDir( surfel ) );
      trace.info() << "spel=" << sspel << " surfel=" << surfel
       << " innerspel=" << innerspel << endl;
      nbok += sspel == innerspel ? 1 : 0; 
      nb++;
      trace.info() << "(" << nbok << "/" << nb << ") "
       << "spel == innerspel" << std::endl;
    }
  trace.endBlock();

  SurfelNeighborhood<KSpace> SN;
  trace.beginBlock ( "Testing surfel neighborhood ..." );
  SCell surfel = K.sIncident( sspel, 0, false );
  SN.init( &K, &SAdj, surfel );
  trace.info() << "surfel      =" << surfel << endl;
  trace.info() << "follower1(+)=" << SN.follower1( 1, true ) << endl;
  trace.info() << "follower2(+)=" << SN.follower2( 1, true ) << endl;
  trace.info() << "follower3(+)=" << SN.follower3( 1, true ) << endl;
  trace.info() << "follower1(-)=" << SN.follower1( 1, false ) << endl;
  trace.info() << "follower2(-)=" << SN.follower2( 1, false ) << endl;
  trace.info() << "follower3(-)=" << SN.follower3( 1, false ) << endl;
  trace.endBlock();

  trace.beginBlock ( "Testing surface tracking ..." );
  typedef SpaceND< KSpace::dimension, Integer > Space;
  typedef HyperRectDomain<Space> Domain;
  typedef typename DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet;
  Domain domain( low, high );
  DigitalSet shape_set( domain );
  SetPredicate<DigitalSet> shape_set_predicate( shape_set );
  int center[ 4 ] = { 1, 0, 0, 0 }; // pixel
  Point pcenter( center );
  Shapes<Domain>::addNorm1Ball( shape_set, pcenter, 1 );
  trace.info() << "surfel      = " << surfel << endl;
  SCell other1, other2;
  SN.getAdjacentOnDigitalSet( other1, shape_set, 1, K.sDirect( surfel, 1 ) );
  SN.getAdjacentOnDigitalSet( other2, shape_set, 1, !K.sDirect( surfel, 1 ) );
  trace.info() << "directNext  = " << other1 << endl;
  trace.info() << "indirectNext= " << other2 << endl;
  std::set<SCell> bdry;

  // surfel = Surfaces<KSpace>::findABel( K, shape_set );

  Surfaces<KSpace>::trackBoundary( bdry,
           K, SAdj, shape_set_predicate, surfel );
  trace.info() << "tracking finished, size=" << bdry.size() 
         << ", should be " << 2*K.dimension*(2*K.dimension-1) << endl;
  nbok += bdry.size() == ( 2*K.dimension*(2*K.dimension-1) ) ? 1 : 0; 
  nb++;
  trace.info() << "(" << nbok << "/" << nb << ") "
         << "bdry.size() == ( 2*K.dimension*(2*K.dimension-1) )"
         << std::endl;
  std::set<SCell> bdry_direct;
  Surfaces<KSpace>::trackClosedBoundary( bdry_direct,
           K, SAdj, shape_set_predicate, surfel );
  trace.info() << "fast direct tracking finished, size=" << bdry_direct.size() 
         << ", should be " << 2*K.dimension*(2*K.dimension-1) << endl;
  nbok += bdry_direct.size() == ( 2*K.dimension*(2*K.dimension-1) ) ? 1 : 0; 
  nb++;
  trace.info() << "(" << nbok << "/" << nb << ") "
         << "bdry_direct.size() == ( 2*K.dimension*(2*K.dimension-1) )"
         << std::endl;
  
  trace.endBlock();
  if ( K.dimension == 2 )
    {
      Board2D board;
      board.setUnit( LibBoard::Board::UCentimeter );
      board << SetMode( domain.className(), "Paving" )
      << domain;
      for ( typename std::set<SCell>::const_iterator it = bdry_direct.begin(),
        it_end = bdry_direct.end(); it != it_end; ++it )
  board << *it;
      board.saveEPS( "cells-2.eps" );
      board.saveSVG( "cells-2.svg" );
    }
  return nbok == nb;
}
开发者ID:kerautret,项目名称:DGtal-forIPOL,代码行数:101,代码来源:testCellularGridSpaceND.cpp

示例8: testDistancePropagation

bool testDistancePropagation()
{
  typedef Z2i::Space Space;
  typedef Z2i::Point Point;
  typedef Z2i::Domain Domain;
  typedef Z2i::DigitalSet DigitalSet;
  typedef Z2i::Object4_8 Object;
  
  BOOST_CONCEPT_ASSERT(( CUndirectedSimpleGraph<Z2i::Object4_8> ));

  trace.beginBlock( "Distance propagation in 2D object" );
  Point p1( -41, -36 );
  Point p2( 18, 18 );
  Domain domain( p1, p2 );
  Point c1( -2, -1 );
  Point c2( -14, 5 );
  Point c3( -30, -15 );
  Point c4( -10, -20 );
  Point c5( 12, -1 );
  DigitalSet shape_set( domain );
  
  Shapes<Domain>::addNorm2Ball( shape_set, c1, 9 );
  Shapes<Domain>::addNorm1Ball( shape_set, c2, 9 );
  Shapes<Domain>::addNorm1Ball( shape_set, c3, 10 );
  Shapes<Domain>::addNorm2Ball( shape_set, c4, 12 );
  Shapes<Domain>::addNorm1Ball( shape_set, c5, 4 );

  Object obj(Z2i::dt4_8, shape_set);
  
  
  GradientColorMap<int> cmap_grad( 0, 25);
  cmap_grad.addColor( Color( 0, 0, 255 ) );
  cmap_grad.addColor( Color( 0, 255, 0 ) );
  cmap_grad.addColor( Color( 255, 0, 0 ) );
  
  Board2D board;
  board << SetMode( domain.className(), "Paving" )
        << domain
        << SetMode( p1.className(), "Paving" );
  
  Image image = ImageFromSet<Image>::create(shape_set, 1);
  
  // Type definitions
  typedef CanonicEmbedder<Space> VertexEmbedder;
  typedef VertexEmbedder::Value RealPoint;
  typedef RealPoint::Coordinate Scalar;
  typedef ExactPredicateLpSeparableMetric<Space,2> Distance;
  typedef std::binder1st< Distance > DistanceToPoint; 
  typedef DGtal::functors::Composer<VertexEmbedder, DistanceToPoint, Scalar> VertexFunctor;
  typedef DistanceBreadthFirstVisitor< Object, VertexFunctor, std::set<Point> > Visitor;

  BOOST_CONCEPT_ASSERT(( CGraphVisitor<Visitor> ));


  VertexEmbedder embedder;
  Distance distance;
  DistanceToPoint distanceToPoint = std::bind1st( distance, embedder( c1 ) );
  VertexFunctor vfunctor( embedder, distanceToPoint );
  Visitor visitor( obj, vfunctor, c1 );
  
  while( ! visitor.finished() )
    {
      Scalar v = visitor.current().second;
      image.setValue( visitor.current().first, v ); 
      visitor.expand();
    }
  
  string specificStyle = p1.className() + "/Paving";
  
  for ( DigitalSet::ConstIterator it = shape_set.begin();
        it != shape_set.end();
        ++it )
    {
      if( image(*it) == 0)
        board << CustomStyle( specificStyle,
                              new CustomColors( Color::Black,
                                                Color::Red ) );
      else if( image(*it) > 0 )
        board << CustomStyle( specificStyle,
                              new CustomColors( Color::Black,
                                                cmap_grad( image(*it) ) ) );
      else
        board << CustomStyle( specificStyle,
                              new CustomColors( Color::Black,
                                                cmap_grad( 0 ) ) );
      board << *it;
    }

  trace.info() << "- Output file testDistancePropagation.eps" << std::endl;
  board.saveEPS("testDistancePropagation.eps");
  trace.endBlock();

  trace.beginBlock( "Distance visitor as a range." );
  typedef GraphVisitorRange<Visitor> VisitorRange;
  VisitorRange range( new Visitor( obj, vfunctor, c1 ) );
  Scalar d = -1.0;
  unsigned int nb = 0;
  unsigned int nbok = 0;
  unsigned int nbperfect = 0;
  for ( VisitorRange::NodeConstIterator it = range.beginNode(), itEnd = range.endNode();
//.........这里部分代码省略.........
开发者ID:Victor-Ostromoukhov,项目名称:DGtal,代码行数:101,代码来源:testDistancePropagation.cpp

示例9: main

int main()
{

    //! [freemanChainFromImage-imageImport]
    typedef DGtal::ImageContainerBySTLVector< DGtal::Z2i::Domain, unsigned char> Image;
    std::string filename =  examplesPath + "samples/circleR10modif.pgm";
    Image image = DGtal::PGMReader<Image>::importPGM(filename);
    //! [freemanChainFromImage-imageImport]

    //![freemanChainFromImage-ksspace]
    Z2i::KSpace ks;
    ks.init( image.domain().lowerBound(), image.domain().upperBound(), true );
    //![freemanChainFromImage-ksspace]

    //! [freemanChainFromImage-setAppend]
    Z2i::DigitalSet set2d (image.domain());
    SetFromImage<Z2i::DigitalSet>::append<Image>(set2d, image, 1, 255);
    //! [freemanChainFromImage-setAppend]


    //! [freemanChainFromImage-displaySet]
    Board2D aBoard;
    aBoard << set2d;
    aBoard << image.domain();
    //! [freemanChainFromImage-displaySet]

    //! [freemanChainFromImage-adj]
    SurfelAdjacency<2> sAdj( true );
    //! [freemanChainFromImage-adj]

    //! [freemanChainFromImage-extraction]
    std::vector< std::vector< Z2i::Point >  >  vectContoursBdryPointels;
    Surfaces<Z2i::KSpace>::extractAllPointContours4C( vectContoursBdryPointels,
            ks, set2d, sAdj );
    //! [freemanChainFromImage-extraction]


    GradientColorMap<int> cmap_grad( 0, (const int)vectContoursBdryPointels.size() );
    cmap_grad.addColor( Color( 50, 50, 255 ) );
    cmap_grad.addColor( Color( 255, 0, 0 ) );
    cmap_grad.addColor( Color( 255, 255, 10 ) );
    cmap_grad.addColor( Color( 25, 255, 255 ) );
    cmap_grad.addColor( Color( 255, 25, 255 ) );
    cmap_grad.addColor( Color( 25, 25, 25 ) );

    //! [freemanChainFromImage-fcConstruction]
    for(unsigned int i=0; i<vectContoursBdryPointels.size(); i++) {
        //  Constructing and displaying FreemanChains from contours.
        FreemanChain<Z2i::Integer> fc (vectContoursBdryPointels.at(i));
        //! [freemanChainFromImage-fcConstruction]
        //! [freemanChainFromImage-fcdysplay]
        aBoard << SetMode( fc.className(), "InterGrid" );
        aBoard<< CustomStyle( fc.className(),
                              new CustomColors(  cmap_grad(i),  Color::None ) );
        aBoard << fc;
        //! [freemanChainFromImage-fcdysplay]
    }

    aBoard.saveEPS("freemanChainFromImage.eps");
    return 0;
}
开发者ID:phcerdan,项目名称:DGtal,代码行数:61,代码来源:freemanChainFromImage.cpp

示例10: main

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

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

  GradientColorMap<float> 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;
      float v = sqrt( d2( p ) );
      v = std::min( (float)m, std::max( v, 0.0f ) ); 
      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("delta2.eps");
  return 0;
}
开发者ID:dcoeurjo,项目名称:VCM,代码行数:62,代码来源:delta-distance.cpp

示例11: main

int main()
{
  Domain domain(Point(0,0), Point(2,2));
  
  //Testing auto in domain iteration
  trace.beginBlock("Domain iterator with auto");
  for(auto it = domain.begin(), itend=domain.end(); it != itend; ++it)
    trace.info()<< *it << " ";
  trace.info()<<std::endl;
  trace.endBlock();
  
  //For loop on a range
  trace.beginBlock("range-based for on the domain");
  for(auto point : domain)
    trace.info() <<point << " ";
  trace.info() <<std::endl;
  trace.endBlock();
  
  //For loop on an image range
  trace.beginBlock("image (const) iterator on values");
  ImageContainerBySTLVector<Domain, int> image(domain);
  for(auto value: image.range())
    trace.info() <<value << " ";
  trace.info() <<std::endl;
  trace.endBlock();
  
  //For loop on an image domain range
  trace.beginBlock("(const) iterator on image domain");
  for(auto value: image.domain())
    trace.info() <<value << " ";
  trace.info() <<std::endl;
  trace.endBlock();
  
  //R-W for loop on an image range
  trace.beginBlock("image  iterator on values");
  int cpt=0;
  for(auto& value: image.range())
  {
    value = cpt;
    cpt++;
    trace.info() <<value << " ";
  }
  trace.info() <<std::endl;
  trace.endBlock();
  
  //Testing lambda expressions
  trace.beginBlock("Lambda exps");
  std::for_each(image.range().begin(), image.range().end(), [](int a){ trace.info() <<a<<" "; });
  trace.info()<<std::endl;
  std::transform(image.range().begin(), image.range().end(), image.range().begin(), [](int a){return 2*a+1;});
  std::for_each(image.range().begin(), image.range().end(), [](int a){ trace.info() <<a<<" "; });
  trace.info() <<std::endl;
  trace.endBlock();
  
  //Lambda expression based ultimate homotopic thining
  trace.beginBlock("STL+Lambda homotopic thinning");
  Domain domain2( Point(-32,-32), Point(32,32));
  DigitalSet set(domain2);
  //constructing a torus
  std::for_each(domain2.begin(), domain2.end(), [&set](Point p){ if ((p.norm() < 10 ) && p.norm() > 5) set.insertNew(p); });
  trace.info() << set << std::endl;
  Board2D board;
  board << set;
  board.saveEPS("original.eps");

  Object4_8 object(dt4_8 , set);
  std::vector<Point> Q;
  auto stable = false;
  auto step = 0;
  DigitalSet & S = object.pointSet();
  while(!stable)
  {
    trace.info() << "step = "<<step;
    stable = true;
    std::for_each(S.begin(), S.end(),
                  [&Q,&object](Point p){ if (object.isSimple(p)) Q.push_back(p); });
    std::for_each(Q.begin(), Q.end(),
                  [&object,&stable,&S](Point p){ if (object.isSimple(p))  {stable = false; S.erase(p);} });
    Q.clear();
    trace.info() << "|S| = "<< S.size() << std::endl;
    step++;
  }
  trace.endBlock();
  board << CustomStyle( object.pointSet().className(), new CustomColors(Color::Black, Color::Red))
        << object.pointSet();
  board.saveEPS("skeleton.eps");
  return 0;
}
开发者ID:dcoeurjo,项目名称:MyDGtalTools,代码行数:88,代码来源:dgtal-cpp11.cpp

示例12: 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

示例13: main


//.........这里部分代码省略.........
  if(args.check("-backgroundImageXFIG")){
    string imageName = args.getOption("-backgroundImageXFIG")->getValue(0);
    unsigned int width = args.getOption("-backgroundImageXFIG")->getIntValue(1);
    unsigned int height = args.getOption("-backgroundImageXFIG")->getIntValue(2);
    aBoard.drawImage(imageName, 0,height-1, width, height, -1, 1.0 );
    }
 
  if(args.check("-fc")){
    string fileName = args.getOption("-fc")->getValue(0);
    vector< FreemanChain<int> > vectFc =  PointListReader< Z2i::Point>:: getFreemanChainsFromFile<int> (fileName); 
    //aBoard <<  SetMode( vectFc.at(0).className(), "InterGrid" );
    aBoard << CustomStyle( vectFc.at(0).className(), 
			   new CustomColors( Color::Red  ,  (filled ? (Color::Black) : (Color::None))  ) );    
    for(unsigned int i=0; i<vectFc.size(); i++){
      aBoard <<  vectFc.at(i) ;
    }
  } 
 

  if( args.check("-sdp") || args.check("-sfp")){
    bool drawPoints= args.check("-drawContourPoint");
    bool invertYaxis = args.check("-invertYaxis");
    
    double pointSize = args.getOption("-drawContourPoint")->getFloatValue(0);
    
    vector<LibBoard::Point> contourPt;
    if(args.check("-sdp")){
      string fileName = args.getOption("-sdp")->getValue(0);
      vector< Z2i::Point >  contour = 
	PointListReader< Z2i::Point >::getPointsFromFile(fileName); 
      for(unsigned int j=0; j<contour.size(); j++){
	LibBoard::Point pt((double)(contour.at(j)[0]),
			   (invertYaxis? (double)(-contour.at(j)[1]+contour.at(0)[1]):(double)(contour.at(j)[1])));
	contourPt.push_back(pt);
	if(drawPoints){
	  aBoard.fillCircle(pt.x, pt.y, pointSize);
	}
      }
    }
    
    if(args.check("-sfp")){
      string fileName = args.getOption("-sfp")->getValue(0);
      vector< PointVector<2,double>  >  contour = 
	PointListReader<  PointVector<2,double>  >::getPointsFromFile(fileName); 
      for(unsigned int j=0; j<contour.size(); j++){
	LibBoard::Point pt((double)(contour.at(j)[0]),
			   (invertYaxis? (double)(-contour.at(j)[1]+contour.at(0)[1]):(double)(contour.at(j)[1])));
	contourPt.push_back(pt);
	if(drawPoints){
	  aBoard.fillCircle(pt.x, pt.y, pointSize);
	}
      }
    }
    aBoard.setPenColor(Color::Red);
    aBoard.setLineStyle (LibBoard::Shape::SolidStyle );
    aBoard.setLineWidth (lineWidth);
    if(!filled){
      aBoard.drawPolyline(contourPt);
    }else{
      aBoard.fillPolyline(contourPt);
    }
    
  
  }

 
  
  if (args.check("-outputSVG")){
    string outputFileName= args.getOption("-outputSVG")->getValue(0);
    aBoard.saveSVG(outputFileName.c_str());
  } else   
    if (args.check("-outputFIG")){
      string outputFileName= args.getOption("-outputFIG")->getValue(0);
      aBoard.saveFIG(outputFileName.c_str());
    } else
      if (args.check("-outputEPS")){
	string outputFileName= args.getOption("-outputEPS")->getValue(0);
	aBoard.saveEPS(outputFileName.c_str());
      }  
#ifdef WITH_CAIRO
      else
	if (args.check("-outputEPS")){
	  string outputFileName= args.getOption("-outputSVG")->getValue(0);
	  aBoard.saveCairo(outputFileName.c_str(),Board2D::CairoEPS );
	} else 
	  if (args.check("-outputPDF")){
	    string outputFileName= args.getOption("-outputPDF")->getValue(0);
	    aBoard.saveCairo(outputFileName.c_str(),Board2D::CairoPDF );
	  } else 
	    if (args.check("-outputPNG")){
	      string outputFileName= args.getOption("-outputPNG")getValue(0);
	      aBoard.saveCairo(outputFileName.c_str(),Board2D::CairoPNG );
	    }
#endif
	    else { //default output
	      string outputFileName= "output.eps";
	      aBoard.saveEPS(outputFileName.c_str());
	    }
  
}
开发者ID:kerautret,项目名称:DGtal-forIPOL,代码行数:101,代码来源:displayContours.cpp

示例14: 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

示例15: testBreadthFirstPropagation

void testBreadthFirstPropagation()
{
  typedef Z2i::Point Point;
  typedef Z2i::Domain Domain;
  typedef Z2i::DigitalSet DigitalSet;
  typedef Z2i::Object4_8 Object;
  
  BOOST_CONCEPT_ASSERT(( CUndirectedSimpleGraph<Z2i::Object4_8> ));
  
  Point p1( -41, -36 );
  Point p2( 18, 18 );
  Domain domain( p1, p2 );
  Point c1( -2, -1 );
  Point c2( -14, 5 );
  Point c3( -30, -15 );
  Point c4( -10, -20 );
  Point c5( 12, -1 );
  DigitalSet shape_set( domain );
  
  Shapes<Domain>::addNorm2Ball( shape_set, c1, 9 );
  Shapes<Domain>::addNorm1Ball( shape_set, c2, 9 );
  Shapes<Domain>::addNorm1Ball( shape_set, c3, 10 );
  Shapes<Domain>::addNorm2Ball( shape_set, c4, 12 );
  Shapes<Domain>::addNorm1Ball( shape_set, c5, 4 );

  Object obj(Z2i::dt4_8, shape_set);
  
  
  GradientColorMap<int> cmap_grad( 0, 52);
  cmap_grad.addColor( Color( 0, 0, 255 ) );
  cmap_grad.addColor( Color( 0, 255, 0 ) );
  cmap_grad.addColor( Color( 255, 0, 0 ) );
  
  Board2D board;
  board << SetMode( domain.className(), "Paving" )
  << domain
  << SetMode( p1.className(), "Paving" );
  
  Image image = ImageFromSet<Image>::create(shape_set, 1);
  
  typedef BreadthFirstVisitor<Object, set<Point> > Visitor;
  BOOST_CONCEPT_ASSERT(( CGraphVisitor< Visitor > ));
  Visitor bfv (obj, c1);
  
  
  while( !bfv.finished() )
  {
    image.setValue(bfv.current().first, bfv.current().second);
    bfv.expand();
  }
  
  string specificStyle = p1.className() + "/Paving";
  
  for ( DigitalSet::ConstIterator it = shape_set.begin();
  it != shape_set.end();
  ++it )
  {
    if( image(*it) == 0)
    {
      board << CustomStyle( specificStyle,
        new CustomColors( Color::Black,
        Color::Red ) )
      << *it;
    }
    else
    {
      if( image(*it) > 0 )
      {
	board << CustomStyle( specificStyle,
	  new CustomColors( Color::Black,
	  cmap_grad( image(*it) ) ) )
	<< *it;
      }
      else
      {
	board << CustomStyle( specificStyle,
	  new CustomColors( Color::Black,
	  cmap_grad( 0 ) ) )
	<< *it;
      }
    }
  }
  
  board.saveEPS("testBreadthFirstPropagation.eps");
}
开发者ID:dcoeurjo,项目名称:DGtal,代码行数:85,代码来源:testBreadthFirstPropagation.cpp


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