int main() { trace.beginBlock ( "Example dgtalBoard2D-1-points" ); Point p1( -3, -2 ); Point p2( 7, 3 ); Point p3( 0, 0 ); Domain domain( p1, p2 ); Board2D board; board << domain << p1 << p2 << p3; board.saveSVG("dgtalBoard2D-1-points.svg"); board.saveEPS("dgtalBoard2D-1-points.eps"); board.saveTikZ("dgtalBoard2D-1-points.tikz"); #ifdef WITH_CAIRO board.saveCairo("dgtalBoard2D-1-points-cairo.pdf", Board2D::CairoPDF); board.saveCairo("dgtalBoard2D-1-points-cairo.png", Board2D::CairoPNG); board.saveCairo("dgtalBoard2D-1-points-cairo.ps", Board2D::CairoPS); board.saveCairo("dgtalBoard2D-1-points-cairo.svg", Board2D::CairoSVG); #endif trace.endBlock(); return 0; }
int main() { trace.beginBlock ( "Example dgtalBoard2D-4-colormaps" ); Point p1( -10, -7 ); Point p2( 10, 7 ); Domain domain( p1, p2 ); Point c1( -5, -1 ); Point c2( 5, 1 ); DigitalSet shape_set( domain ); Shapes<Domain>::addNorm1Ball( shape_set, c1, 5 ); Shapes<Domain>::addNorm1Ball( shape_set, c2, 5 ); shape_set.erase( c1 ); shape_set.erase( c2 ); // Creating colormap. GradientColorMap<int> cmap_grad( 0, 15 ); cmap_grad.addColor( Color( 50, 50, 255 ) ); cmap_grad.addColor( Color( 255, 0, 0 ) ); cmap_grad.addColor( Color( 255, 255, 10 ) ); // Creating board. Board2D board; board << SetMode( domain.className(), "Paving" ) << domain << SetMode( p1.className(), "Paving" ); // This is the name of the style for a Point in mode "Paving". string specificStyle = p1.className() + "/Paving"; for ( DigitalSet::ConstIterator it = shape_set.begin(); it != shape_set.end(); ++it ) { unsigned int d = (unsigned int) ceil( ( *it - c1 ).norm() ); // specific color depending on the distance to point c1. board << CustomStyle( specificStyle, new CustomColors( Color::Black, cmap_grad( d ) ) ) << *it; } board.saveSVG( "dgtalBoard2D-4-colormaps.svg"); board.saveEPS( "dgtalBoard2D-4-colormaps.eps"); board.saveTikZ( "dgtalBoard2D-4-colormaps.tikz"); #ifdef WITH_CAIRO board.saveCairo("dgtalBoard2D-4-colormaps-cairo.pdf", Board2D::CairoPDF); board.saveCairo("dgtalBoard2D-4-colormaps-cairo.png", Board2D::CairoPNG); board.saveCairo("dgtalBoard2D-4-colormaps-cairo.ps", Board2D::CairoPS); board.saveCairo("dgtalBoard2D-4-colormaps-cairo.svg", Board2D::CairoSVG); #endif trace.endBlock(); return 0; }
/** * @brief Function that illustrates the basic usage of * a naive DSS. */ void exampleNaiveDSS() { trace.beginBlock ( "Naive DSS" ); using namespace Z2i; //! [ArithmeticalDSSNaiveCtor] // Construct a naive DSS NaiveDSS8<Integer> segment( 5, 8, //slope Point(0,0), Point(8,5), //ending points Point(0,0), Point(8,5), //upper points Point(3,1), Point(3,1) //lower points ); //! [ArithmeticalDSSNaiveCtor] // Trace to the standard output trace.info() << segment << std::endl; //! [ArithmeticalDSSIteration] // Trace the position and remainder of each point for (NaiveDSS8<Integer>::ConstIterator it = segment.begin(), ite = segment.end(); it != ite; ++it ) { trace.info() << "(" << segment.position( *it ) << "," << segment.remainder( *it ) << ") "; } //! [ArithmeticalDSSIteration] trace.info() << std::endl; //! [NaiveDSS8DrawingUsage] Board2D board; // Draw the grid Domain domain( Point(0,0), Point(8,5) ); board << SetMode(domain.className(), "Grid") << domain; //Draw the points of the DSS board << SetMode("PointVector", "Both"); board << SetMode(segment.className(), "Points") << segment; // Draw the bounding box board << SetMode(segment.className(), "BoundingBox") << segment; //! [NaiveDSS8DrawingUsage] // Save board.saveSVG("NaiveDSS8.svg"); #ifdef WITH_CAIRO board.saveCairo("NaiveDSS8.png", Board2D::CairoPNG); #endif trace.endBlock(); }
void draw( const TImage aImg, const double& aMaxValue, std::string aBasename) { typedef typename TImage::Domain::ConstIterator ConstIteratorOnPoints; typedef typename TImage::Domain::Point Point; HueShadeColorMap<double, 2> colorMap(0,aMaxValue); Board2D b; b.setUnit ( LibBoard::Board::UCentimeter ); for (ConstIteratorOnPoints it = aImg.domain().begin(), itEnd = aImg.domain().end(); it != itEnd; ++it) { Point p = *it; b << CustomStyle( p.className(), new CustomFillColor( colorMap( aImg(p) ) ) ); b << p; } { std::stringstream s; s << aBasename << ".eps"; b.saveEPS(s.str().c_str()); } #ifdef WITH_CAIRO { std::stringstream s; s << aBasename << ".png"; b.saveCairo(s.str().c_str(), Board2D::CairoPNG); } #endif }
/** * Display * */ bool testDrawGridCurve(const string &filename) { GridCurve<KhalimskySpaceND<2> > c; //grid curve trace.info() << endl; trace.info() << "Displaying GridCurve " << endl; //reading grid curve fstream inputStream; inputStream.open (filename.c_str(), ios::in); c.initFromVectorStream(inputStream); inputStream.close(); //displaying it Board2D aBoard; aBoard.setUnit(Board2D::UCentimeter); aBoard << c; aBoard.saveEPS( "GridCurve.eps", Board2D::BoundingBox, 5000 ); #ifdef WITH_CAIRO aBoard.saveCairo("GridCurve-cairo.pdf", Board2D::CairoPDF, Board2D::BoundingBox, 5000); #endif return true; }
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; }
/** * Export a given Set into an image file. * * @param aSet input set. * @param outputName output file name. * @param outputFormat output file format. * */ static void save(const Set &aSet, const std::string outputName, const std::string outputFormat) { Image image = ImageFromSet<Image>::template create<Set>(aSet, 255, true); if (outputFormat == "pgm") PNMWriter<Image,Gray>::exportPGM(outputName+"."+outputFormat,image,0,255); else if (outputFormat == "raw") RawWriter<Image,Gray>::exportRaw8(outputName+"."+outputFormat,image,0,255); else if (outputFormat == "svg") { Board2D board; board << aSet; board.saveSVG((outputName+"."+outputFormat).c_str()); } else #ifdef WITH_CAIRO if (outputFormat == "pdf") { Board2D board; board << aSet; board.saveCairo((outputName+"."+outputFormat).c_str(), Board2D::CairoPDF); } else if (outputFormat == "png") { Board2D board; board << aSet; board.saveCairo((outputName+"."+outputFormat).c_str(), Board2D::CairoPNG); } else #endif { trace.error()<< "Output format: "<<outputFormat<< " not recognized."<<std::endl; exit(1); } }
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; }
/** * 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; }
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; }
/** * @brief Program that draws the maximal segments * of digital curve whose chain code may be given * as an argument. The chain code must be a sequence * of characters belonging to the set {0,1,2,3}. * @param argc number of arguments * @param argv array of arguments * @return 0 */ int main( int argc, char** argv ) { trace.beginBlock ( "Example convex-and-concave-parts" ); Board2D aBoard; //create a board //create a chain code string codes; if (argc >= 2) codes = argv[1]; else codes = "030030330303303030300001010101101011010000030330303303030300001010110101011010000033"; stringstream ss(stringstream::in | stringstream::out); ss << "0 0 " << codes << endl; FreemanChain<int> theContour( ss ); trace.info() << "Processing of " << ss.str() << endl; //draw the digital contour aBoard << SetMode( "PointVector", "Grid" ) << theContour; //draw the maximal segments segmentationIntoMaximalDSSs(theContour.begin(), theContour.end(), aBoard); //save the drawing aBoard.saveSVG("convex-and-concave-parts.svg"); #ifdef WITH_CAIRO aBoard.saveCairo("convex-and-concave-parts.png"); #endif trace.endBlock(); return 0; }
/** * Algorithms that computes the alpha-shape * of a point set */ void alphaShape() { //Digitization of a disk of radius 8 Ball2D<Z2i::Space> ball(Z2i::Point(0,0), 8); Z2i::Domain domain(ball.getLowerBound(), ball.getUpperBound()); Z2i::DigitalSet digitalSet(domain); Shapes<Z2i::Domain>::euclideanShaper(digitalSet, ball); //Contour of the digital set Z2i::KSpace kspace; kspace.init(domain.lowerBound()-Z2i::Point(1,1), domain.upperBound()+Z2i::Point(1,1), true); typedef DigitalSetBoundary<Z2i::KSpace, Z2i::DigitalSet> DigitalSurfaceContainer; typedef DigitalSurface<DigitalSurfaceContainer> CustomDigitalSurface; DigitalSurfaceContainer digitalSurfaceContainer( kspace, digitalSet ); CustomDigitalSurface digitalSurface( digitalSurfaceContainer ); //Grid curve Z2i::Curve gridCurve; typedef DepthFirstVisitor<DigitalSurface<DigitalSurfaceContainer> > CustomVisitor; CustomVisitor visitor( digitalSurface, *digitalSurface.begin() ); while ( ! visitor.finished() ) { gridCurve.pushBack( visitor.current().first ); visitor.expand(); } //Point set defined as the set of (not duplicated) inner points typedef Z2i::Curve::InnerPointsRange PointRange; PointRange pointsRange = gridCurve.getInnerPointsRange(); vector<Z2i::Point> border; unique_copy( pointsRange.begin(), pointsRange.end(), back_inserter( border ) ); //namespace for hull functions using namespace functions::Hull2D; { //alpha = 0 trace.info() << " alpha == 0 " << endl; vector<Z2i::Point> res; //! [Hull2D-RadiusPredicateInf] typedef AvnaimEtAl2x2DetSignComputer<DGtal::int64_t> DetComputer; typedef InGeneralizedDiskOfGivenRadius<Z2i::Point, DetComputer> Functor; Functor functor(true, 1, 0); //alpha = 0; 1/alpha -> +inf typedef PredicateFromOrientationFunctor2<Functor> Predicate; Predicate predicate( functor ); //! [Hull2D-RadiusPredicateInf] //! [Hull2D-ClosedGrahamScan] closedGrahamScanFromAnyPoint( border.begin(), border.end(), back_inserter( res ), predicate ); //! [Hull2D-ClosedGrahamScan] //display Board2D board; drawPolygon( res.begin(), res.end(), board ); board.saveSVG( "AlphaShape0.svg" ); #ifdef WITH_CAIRO board.saveCairo("AlphaShape0.png", Board2D::CairoPNG); #endif } { //alpha = 0 trace.info() << " alpha == 0 " << endl; vector<Z2i::Point> res; //comparator and functor typedef InHalfPlaneBySimple3x3Matrix<Z2i::Point, DGtal::int64_t> Functor; Functor functor; typedef PredicateFromOrientationFunctor2<Functor> Predicate; Predicate predicate( functor ); closedGrahamScanFromAnyPoint( border.begin(), border.end(), back_inserter( res ), predicate ); //display Board2D board; drawPolygon( res.begin(), res.end(), board ); board.saveSVG( "AlphaShape0bis.svg" ); #ifdef WITH_CAIRO board.saveCairo("AlphaShape0bis.png", Board2D::CairoPNG); #endif } //negative alpha shape { //alpha = -1 trace.info() << " alpha == -1 " << endl; vector<Z2i::Point> res; typedef AvnaimEtAl2x2DetSignComputer<DGtal::int64_t> DetComputer; typedef InGeneralizedDiskOfGivenRadius<Z2i::Point, DetComputer> Functor; //! [Hull2D-RadiusPredicateM1] Functor functor(false, 1, 1); //1/alpha = -sqrt(1/1) = -1 //! [Hull2D-RadiusPredicateM1] typedef PredicateFromOrientationFunctor2<Functor> Predicate; Predicate predicate( functor ); closedGrahamScanFromAnyPoint( border.begin(), border.end(), back_inserter( res ), predicate ); //display Board2D board; drawPolygon( res.begin(), res.end(), board ); board.saveSVG( "AlphaShapeM1.svg" ); #ifdef WITH_CAIRO board.saveCairo("AlphaShapeM1.png", Board2D::CairoPNG); #endif } { //alpha = -sqrt(5) trace.info() << " alpha == -sqrt(5) " << endl; vector<Z2i::Point> res; typedef AvnaimEtAl2x2DetSignComputer<DGtal::int64_t> DetComputer; typedef InGeneralizedDiskOfGivenRadius<Z2i::Point, DetComputer> Functor; //! [Hull2D-RadiusPredicateMsqrt5] Functor functor(false, 5, 1); //1/alpha = -sqrt(5) //! [Hull2D-RadiusPredicateMsqrt5] typedef PredicateFromOrientationFunctor2<Functor> Predicate; Predicate predicate( functor ); closedGrahamScanFromAnyPoint( border.begin(), border.end(), back_inserter( res ), predicate ); //display Board2D board; drawPolygon( res.begin(), res.end(), board ); board.saveSVG( "AlphaShapeMSqrt5.svg" ); #ifdef WITH_CAIRO board.saveCairo("AlphaShapeMSqrt5.png", Board2D::CairoPNG); #endif } { //alpha = -5 trace.info() << " alpha == -5 " << endl; vector<Z2i::Point> res; typedef AvnaimEtAl2x2DetSignComputer<DGtal::int64_t> DetComputer; typedef InGeneralizedDiskOfGivenRadius<Z2i::Point, DetComputer> Functor; //! [Hull2D-RadiusPredicateM5] Functor functor(false, 25, 1); //1/alpha = -sqrt(25/1) = -5 //! [Hull2D-RadiusPredicateM5] typedef PredicateFromOrientationFunctor2<Functor> Predicate; Predicate predicate( functor ); closedGrahamScanFromAnyPoint( border.begin(), border.end(), back_inserter( res ), predicate ); //display Board2D board; drawPolygon( res.begin(), res.end(), board ); board.saveSVG( "AlphaShapeM5.svg" ); #ifdef WITH_CAIRO board.saveCairo("AlphaShapeM5.png", Board2D::CairoPNG); #endif } //positive alpha shape { trace.info() << " alpha == 8 " << endl; vector<Z2i::Point> res; //! [Hull2D-RadiusPredicateP8] typedef AvnaimEtAl2x2DetSignComputer<DGtal::int64_t> DetComputer; typedef InGeneralizedDiskOfGivenRadius<Z2i::Point, DetComputer> Functor; Functor functor(true, 64, 1); //1/alpha = sqrt(64/1) = 8 typedef PredicateFromOrientationFunctor2<Functor, false, true> Predicate; Predicate predicate( functor ); //! [Hull2D-RadiusPredicateP8] closedGrahamScanFromAnyPoint( border.begin(), border.end(), back_inserter( res ), predicate ); //display Board2D board; drawPolygon( res.begin(), res.end(), board ); board.saveSVG( "AlphaShapeP8.svg" ); #ifdef WITH_CAIRO board.saveCairo("AlphaShapeP8.png", Board2D::CairoPNG); #endif } //positive alpha shape { trace.info() << " alpha == 9 " << endl; vector<Z2i::Point> res; typedef AvnaimEtAl2x2DetSignComputer<DGtal::int64_t> DetComputer; typedef InGeneralizedDiskOfGivenRadius<Z2i::Point, DetComputer> Functor; //! [Hull2D-RadiusPredicateP9] Functor functor(true, 81, 1); //1/alpha = sqrt(81/1) = 9 //! [Hull2D-RadiusPredicateP9] typedef PredicateFromOrientationFunctor2<Functor> Predicate; Predicate predicate( functor ); closedGrahamScanFromAnyPoint( border.begin(), border.end(), back_inserter( res ), predicate ); //display Board2D board; drawPolygon( res.begin(), res.end(), board ); board.saveSVG( "AlphaShapeP9.svg" ); #ifdef WITH_CAIRO board.saveCairo("AlphaShapeP9.png", Board2D::CairoPNG); #endif } }
int main( int argc, char** argv ) { // parse command line ---------------------------------------------- po::options_description general_opt("Allowed options are: "); general_opt.add_options() ("help,h", "display this message") ("FreemanChain,f", po::value<std::string>(), "FreemanChain file name") ("SDP", po::value<std::string>(), "Import a contour as a Sequence of Discrete Points (SDP format)") ("SFP", po::value<std::string>(), "Import a contour as a Sequence of Floating Points (SFP format)") ("drawContourPoint", po::value<double>(), "<size> display contour points as disk of radius <size>") ("lineWidth", po::value<double>()->default_value(1.0), "Define the linewidth of the contour (SDP format)") ("withProcessing", po::value<std::string>(), "Processing (used only with --FreemanChain):\n\t DSS segmentation {DSS}\n\t Maximal segments {MS}\n\t Faithful Polygon {FP}\n\t Minimum Length Polygon {MLP}") ("outputEPS", po::value<std::string>(), " <filename> specify eps format (default format output.eps)") ("outputSVG", po::value<std::string>(), " <filename> specify svg format.") ("outputFIG", po::value<std::string>(), " <filename> specify fig format.") #ifdef WITH_CAIRO ("outputPDF", po::value<std::string>(), "outputPDF <filename> specify pdf format. ") ("outputPNG", po::value<std::string>(), "outputPNG <filename> specify png format.") ("invertYaxis", " invertYaxis invert the Y axis for display contours (used only with --SDP)") #endif #ifdef WITH_MAGICK ("backgroundImage", po::value<std::string>(), "backgroundImage <filename> <alpha> : display image as background with transparency alpha (defaut 1) (transparency works only if cairo is available)") ("alphaBG", po::value<double>(), "alphaBG <value> 0-1.0 to display the background image in transparency (default 1.0)") #endif ("scale", po::value<double>(), "scale <value> 1: normal; >1 : larger ; <1 lower resolutions )"); po::variables_map vm; po::store(po::parse_command_line(argc, argv, general_opt), vm); po::notify(vm); if(vm.count("help")||argc<=1 || (not(vm.count("FreemanChain")) && not(vm.count("SDP")) && not(vm.count("SFP"))&& not(vm.count("backgroundImage")) ) ) { trace.info()<< "Display discrete contours. " <<std::endl << "Basic usage: "<<std::endl << "\t displayContours [options] --FreemanChain <fileName> --imageName image.png "<<std::endl << general_opt << "\n"; return 0; } double lineWidth= vm["lineWidth"].as<double>(); double scale=1.0; if(vm.count("scale")){ scale = vm["scale"].as<double>(); } Board2D aBoard; aBoard.setUnit (0.05*scale, LibBoard::Board::UCentimeter); #ifdef WITH_MAGICK double alpha=1.0; if(vm.count("alphaBG")){ alpha = vm["alphaBG"].as<double>(); } if(vm.count("backgroundImage")){ string imageName = vm["backgroundImage"].as<string>(); typedef ImageSelector<Z2i::Domain, unsigned char>::Type Image; DGtal::MagickReader<Image> reader; Image img = reader.importImage( imageName ); Z2i::Point ptInf = img.lowerBound(); Z2i::Point ptSup = img.upperBound(); unsigned int width = abs(ptSup.at(0)-ptInf.at(0)+1); unsigned int height = abs(ptSup.at(1)-ptInf.at(1)+1); aBoard.drawImage(imageName, 0-0.5,height-0.5, width, height, -1, alpha ); } #endif if(vm.count("FreemanChain")){ string fileName = vm["FreemanChain"].as<string>(); vector< FreemanChain<int> > vectFc = PointListReader< Z2i::Point>:: getFreemanChainsFromFile<int> (fileName); //aBoard << SetMode( vectFc.at(0).styleName(), "InterGrid" ); aBoard << CustomStyle( vectFc.at(0).styleName(), new CustomColors( Color::Red , Color::None ) ); for(unsigned int i=0; i<vectFc.size(); i++){ aBoard << vectFc.at(i) ; if(vm.count("withProcessing")){ std::string processingName = vm["withProcessing"].as<std::string>(); vector<Z2i::Point> vPts(vectFc.at(i).size()+1); copy ( vectFc.at(i).begin(), vectFc.at(i).end(), vPts.begin() ); bool isClosed; if ( vPts.at(0) == vPts.at(vPts.size()-1) ) { isClosed = true; vPts.pop_back(); } else isClosed = false; if (processingName == "DSS") { typedef ArithmeticalDSS<vector<Z2i::Point>::iterator,int,4> DSS4; typedef deprecated::GreedyDecomposition<DSS4> Decomposition4; //Segmentation DSS4 computer; Decomposition4 theDecomposition( vPts.begin(),vPts.end(),computer,isClosed ); //for each segment aBoard << SetMode( computer.styleName(), "BoundingBox" ); string styleName = computer.styleName() + "/BoundingBox"; for ( Decomposition4::SegmentIterator it = theDecomposition.begin(); it != theDecomposition.end(); ++it ) { DSS4 segment(*it); aBoard << CustomStyle( styleName, new CustomPenColor( DGtal::Color::Gray ) ); aBoard << segment; // draw each segment } } else if (processingName == "MS") { typedef ArithmeticalDSS<vector<Z2i::Point>::iterator,int,4> DSS4; typedef deprecated::MaximalSegments<DSS4> Decomposition4; //Segmentation DSS4 computer; Decomposition4 theDecomposition( vPts.begin(),vPts.end(),computer,isClosed ); //for each segment aBoard << SetMode( computer.styleName(), "BoundingBox" ); string styleName = computer.styleName() + "/BoundingBox"; for ( Decomposition4::SegmentIterator it = theDecomposition.begin(); it != theDecomposition.end(); ++it ) { DSS4 segment(*it); aBoard << CustomStyle( styleName, new CustomPenColor( DGtal::Color::Black ) ); aBoard << segment; // draw each segment } } else if (processingName == "FP") { typedef FP<vector<Z2i::Point>::iterator,int,4> FP; FP theFP( vPts.begin(),vPts.end(),isClosed ); aBoard << CustomStyle( theFP.styleName(), new CustomPenColor( DGtal::Color::Black ) ); aBoard << theFP; } else if (processingName == "MLP") { typedef FP<vector<Z2i::Point>::iterator,int,4> FP; FP theFP( vPts.begin(),vPts.end(),isClosed ); vector<FP::RealPoint> v( theFP.size() ); theFP.copyMLP( v.begin() ); //polyline to draw vector<LibBoard::Point> polyline; vector<FP::RealPoint>::const_iterator it = v.begin(); for ( ;it != v.end();++it) { FP::RealPoint p = (*it); polyline.push_back(LibBoard::Point(p[0],p[1])); } if (isClosed) { FP::RealPoint p = (*v.begin()); polyline.push_back(LibBoard::Point(p[0],p[1])); } aBoard.setPenColor(DGtal::Color::Black); aBoard.drawPolyline(polyline); } } } } if(vm.count("SDP") || vm.count("SFP")){ bool drawPoints= vm.count("drawContourPoint"); bool invertYaxis = vm.count("invertYaxis"); double pointSize=1.0; if(drawPoints){ pointSize = vm["drawContourPoint"].as<double>(); } vector<LibBoard::Point> contourPt; if(vm.count("SDP")){ string fileName = vm["SDP"].as<string>(); 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(vm.count("SFP")){ string fileName = vm["SFP"].as<string>(); 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); aBoard.drawPolyline(contourPt); } if (vm.count("outputSVG")){ string outputFileName= vm["outputSVG"].as<string>(); aBoard.saveSVG(outputFileName.c_str()); } else if (vm.count("outputFIG")){ string outputFileName= vm["outputFIG"].as<string>(); aBoard.saveFIG(outputFileName.c_str()); } else if (vm.count("outputEPS")){ string outputFileName= vm["outputEPS"].as<string>(); aBoard.saveEPS(outputFileName.c_str()); } #ifdef WITH_CAIRO else if (vm.count("outputEPS")){ string outputFileName= vm["outputEPS"].as<string>(); aBoard.saveCairo(outputFileName.c_str(),Board2D::CairoEPS ); } else if (vm.count("outputPDF")){ string outputFileName= vm["outputPDF"].as<string>(); aBoard.saveCairo(outputFileName.c_str(),Board2D::CairoPDF ); } else if (vm.count("outputPNG")){ string outputFileName= vm["outputPNG"].as<string>(); aBoard.saveCairo(outputFileName.c_str(),Board2D::CairoPNG ); } #endif else { //default output string outputFileName= "output.eps"; aBoard.saveEPS(outputFileName.c_str()); } }
/** * @brief Function showing how a DSS can be extended and retracted. */ void exampleUpdate() { trace.beginBlock ( "DSS update" ); using namespace Z2i; //Construction -------------------------------------------------- //! [ArithmeticalDSSUpdateInit] Point M(11, 7); NaiveDSS8<Integer> S( 5, 8, //slope Point(0,0), Point(10,6), //ending points Point(0,0), Point(8,5), //upper points Point(3,1), Point(3,1) //lower points ); //! [ArithmeticalDSSUpdateInit] //this segment should be valid: if (!S.isValid()) throw std::exception(); // Store a copy before any operation NaiveDSS8<Integer> copyOfS = S; trace.info() << S << std::endl; //Display ------------------------------------------------------ { Board2D board; // Draw the grid Domain domain( Point(0,0), M ); board << SetMode(domain.className(), "Grid") << domain; // Draw the points of the DSS and its bounding box board << SetMode("PointVector", "Both"); board << SetMode(S.className(), "Points") << S << SetMode(S.className(), "BoundingBox") << S; // Draw the orthonormal base board.drawArrow(0.0, 0.0, 1.0, 0.0); board.drawArrow(0.0, 0.0, 0.0, 1.0); // Draw M board << SetMode(M.className(), "Both") << CustomStyle( M.className(), new CustomColors( Color(255,0,0), Color(192, 0, 0)) ) << M; // Save board.saveSVG("NaiveDSS8ExtInit.svg"); #ifdef WITH_CAIRO board.saveCairo("NaiveDSS8ExtInit.png", Board2D::CairoPNG); #endif } // Extension ----------------------------------------------------- //! [ArithmeticalDSSUpdateExtension] bool resExtention = S.extendFront( M ); //! [ArithmeticalDSSUpdateExtension] //this segment should be extended: if (!resExtention) throw std::exception(); trace.info() << S << std::endl; //Display ------------------------------------------------------ { Board2D board; // Draw the grid Domain domain( Point(0,0), M ); board << SetMode(domain.className(), "Grid") << domain; // Draw the points of the DSS and its bounding box board << SetMode("PointVector", "Both"); board << SetMode(S.className(), "Points") << S << SetMode(S.className(), "BoundingBox") << S; // Draw the orthonormal base board.drawArrow(0.0, 0.0, 1.0, 0.0); board.drawArrow(0.0, 0.0, 0.0, 1.0); // Save board.saveSVG("NaiveDSS8ExtDone.svg"); #ifdef WITH_CAIRO board.saveCairo("NaiveDSS8ExtDone.png", Board2D::CairoPNG); #endif } // Retraction ---------------------------------------------------- //! [ArithmeticalDSSUpdateRetraction] bool resRetraction = S.retractFront(); //! [ArithmeticalDSSUpdateRetraction] //this segment should be retracted: if (!resRetraction) throw std::exception(); trace.info() << S << std::endl; // Comparaison ---------------------------------------------------- //! [ArithmeticalDSSUpdateConclu] //this segment and the previous copy should be equal: if ( !S.equalsTo(copyOfS) ) throw std::exception(); //! [ArithmeticalDSSUpdateConclu] trace.endBlock(); }
/** * @brief Function that illustrates the basic usage of * a standard DSS. */ void exampleStandardDSS() { trace.beginBlock ( "Standard DSS" ); using namespace Z2i; //! [ArithmeticalDSSStandardCtor] // Construct a standard DSS StandardDSS4<Integer> segment( 5, 8, //slope Point(0,0), Point(8,5), //ending points Point(0,0), Point(8,5), //upper points Point(4,1), Point(4,1) //lower points ); //! [ArithmeticalDSSStandardCtor] // Trace to the standard output trace.info() << segment << std::endl; // Display the DSS with a domain on a board Domain domain( Point(0,0), Point(8,5) ); Board2D board; //! [StandardDSS4DrawingUsage] // Draw the grid board << SetMode(domain.className(), "Grid") << domain; // Draw the points of the DSS board << SetMode("PointVector", "Grid") << SetMode(segment.className(), "Points") << segment; // Draw the bounding box board << SetMode(segment.className(), "BoundingBox") << segment; //! [StandardDSS4DrawingUsage] // Save board.saveSVG("StandardDSS4.svg"); #ifdef WITH_CAIRO board.saveCairo("StandardDSS4.png", Board2D::CairoPNG); #endif board.clear(); //! [ArithmeticalDSSDrawingUsage] // Draw the pixels board << SetMode(domain.className(), "Paving") << domain; //Draw the points of the DSS board << SetMode("PointVector", "Both"); board << SetMode(segment.className(), "Points") << segment; // Draw the bounding box board << SetMode(segment.className(), "BoundingBox") << segment; //! [ArithmeticalDSSDrawingUsage] board.saveSVG("StandardDSS4bis.svg"); #ifdef WITH_CAIRO board.saveCairo("StandardDSS4bis.png", Board2D::CairoPNG); #endif trace.endBlock(); }
/** * Algorithms that computes the convex hull * of a point set */ void convexHull() { //Digitization of a disk of radius 6 Ball2D<Z2i::Space> ball(Z2i::Point(0,0), 6); Z2i::Domain domain(ball.getLowerBound(), ball.getUpperBound()); Z2i::DigitalSet pointSet(domain); Shapes<Z2i::Domain>::euclideanShaper(pointSet, ball); //! [Hull2D-Namespace] using namespace functions::Hull2D; //! [Hull2D-Namespace] //! [Hull2D-Functor] typedef InHalfPlaneBySimple3x3Matrix<Z2i::Point, DGtal::int64_t> Functor; Functor functor; //! [Hull2D-Functor] { //convex hull in counter-clockwise order vector<Z2i::Point> res; //! [Hull2D-StrictPredicateCCW] typedef PredicateFromOrientationFunctor2<Functor, false, false> StrictPredicate; StrictPredicate predicate( functor ); //! [Hull2D-StrictPredicateCCW] //according to the last two template arguments, neither strictly negative values, nor zeros are accepted: //the predicate returns 'true' only for strictly positive values returned by the underlying functor. //! [Hull2D-AndrewAlgo] andrewConvexHullAlgorithm( pointSet.begin(), pointSet.end(), back_inserter( res ), predicate ); //! [Hull2D-AndrewAlgo] //![Hull2D-Caliper-computeBasic] double th = DGtal::functions::Hull2D::computeHullThickness(res.begin(), res.end(), DGtal::functions::Hull2D::HorizontalVerticalThickness); //![Hull2D-Caliper-computeBasic] //![Hull2D-Caliper-computeAnti] Z2i::Point antipodalP, antipodalQ, antipodalS; th = DGtal::functions::Hull2D::computeHullThickness(res.begin(), res.end(), DGtal::functions::Hull2D::HorizontalVerticalThickness, antipodalP, antipodalQ, antipodalS); //![Hull2D-Caliper-computeAnti] trace.info() <<" ConvexHull HV thickness: " << th << std::endl; //display Board2D board; drawPolygon( res.begin(), res.end(), board ); //![Hull2D-Caliper-display] board.setPenColor(DGtal::Color::Red); board.drawCircle( antipodalS[0], antipodalS[1], 0.2) ; board.setPenColor(DGtal::Color::Blue); board.drawCircle(antipodalP[0], antipodalP[1], 0.2); board.drawCircle(antipodalQ[0], antipodalQ[1], 0.2); board.drawLine(antipodalP[0], antipodalP[1], antipodalQ[0], antipodalQ[1]); //![Hull2D-Caliper-display] board.saveSVG( "ConvexHullCCW.svg" ); #ifdef WITH_CAIRO board.saveCairo("ConvexHullCCW.png", Board2D::CairoPNG); #endif } { //convex hull in counter-clockwise order with all the points lying on the edges vector<Z2i::Point> res; //! [Hull2D-LargePredicateCCW] typedef PredicateFromOrientationFunctor2<Functor, false, true> LargePredicate; LargePredicate predicate( functor ); //! [Hull2D-LargePredicateCCW] //according to the last template argument, zeros are accepted so that //the predicate returns 'true' for all the positive values returned by the underlying functor. //andrew algorithm andrewConvexHullAlgorithm( pointSet.begin(), pointSet.end(), back_inserter( res ), predicate ); //display Board2D board; drawPolygon( res.begin(), res.end(), board ); board.saveSVG( "ConvexHullCCWWithPointsOnEdges.svg" ); #ifdef WITH_CAIRO board.saveCairo("ConvexHullCCWWithPointsOnEdges.png", Board2D::CairoPNG); #endif } { //convex hull in clockwise order vector<Z2i::Point> res; //! [Hull2D-StrictPredicateCW] typedef PredicateFromOrientationFunctor2<Functor, true, false> StrictPredicate; StrictPredicate predicate( functor ); //! [Hull2D-StrictPredicateCW] //according to the last two argument template, //the predicate returns 'true' only for strictly negative values returned by the underlying functor. //andrew algorithm andrewConvexHullAlgorithm( pointSet.begin(), pointSet.end(), back_inserter( res ), predicate ); //display Board2D board; drawPolygon( res.begin(), res.end(), board ); board.saveSVG( "ConvexHullCW.svg" ); #ifdef WITH_CAIRO board.saveCairo("ConvexHullCW.png", Board2D::CairoPNG); #endif } { //convex hull in counter-clockwise order vector<Z2i::Point> res; //geometric predicate typedef PredicateFromOrientationFunctor2<Functor, false, false> StrictPredicate; StrictPredicate predicate( functor ); //! [Hull2D-GrahamAlgo] grahamConvexHullAlgorithm( pointSet.begin(), pointSet.end(), back_inserter( res ), predicate ); //! [Hull2D-GrahamAlgo] //display Board2D board; drawPolygon( res.begin(), res.end(), board ); board.saveSVG( "ConvexHullCCWbis.svg" ); #ifdef WITH_CAIRO board.saveCairo("ConvexHullCCWbis.png", Board2D::CairoPNG); #endif } { //convex hull of a simple polygonal line that is not weakly externally visible vector<Z2i::Point> polygonalLine; polygonalLine.push_back(Z2i::Point(0,0)); polygonalLine.push_back(Z2i::Point(0,4)); polygonalLine.push_back(Z2i::Point(1,4)); polygonalLine.push_back(Z2i::Point(1,1)); polygonalLine.push_back(Z2i::Point(3,1)); polygonalLine.push_back(Z2i::Point(2,2)); polygonalLine.push_back(Z2i::Point(3,4)); polygonalLine.push_back(Z2i::Point(4,4)); polygonalLine.push_back(Z2i::Point(4,0)); vector<Z2i::Point> resGraham, res; typedef PredicateFromOrientationFunctor2<Functor, false, false> StrictPredicate; StrictPredicate predicate( functor ); closedGrahamScanFromAnyPoint( polygonalLine.begin(), polygonalLine.end(), back_inserter( resGraham ), predicate ); //! [Hull2D-OnLineMelkmanAlgo] DGtal::MelkmanConvexHull<Z2i::Point, Functor> ch( functor ); for (std::vector<Z2i::Point>::const_iterator it = polygonalLine.begin(), itEnd = polygonalLine.end(); it != itEnd; ++it) ch.add( *it ); //! [Hull2D-OnLineMelkmanAlgo] //! [Hull2D-OffLineMelkmanAlgo] melkmanConvexHullAlgorithm( polygonalLine.begin(), polygonalLine.end(), back_inserter( res ), functor ); //! [Hull2D-OffLineMelkmanAlgo] //display Board2D board; drawPolygon( polygonalLine.begin(), polygonalLine.end(), board, true ); board.saveSVG( "SimplePolygonalLine.svg" ); #ifdef WITH_CAIRO board.saveCairo("SimplePolygonalLine.png", Board2D::CairoPNG); #endif board.clear(); drawPolygon( resGraham.begin(), resGraham.end(), board ); board.saveSVG( "SimplePolygonalLineGraham.svg" ); #ifdef WITH_CAIRO board.saveCairo("SimplePolygonalLineGraham.png", Board2D::CairoPNG); #endif board.clear(); drawPolygon( res.begin(), res.end(), board ); board.saveSVG( "SimplePolygonalLineMelkman.svg" ); #ifdef WITH_CAIRO board.saveCairo("SimplePolygonalLineMelkman.png", Board2D::CairoPNG); #endif board.clear(); drawPolygon( ch.begin(), ch.end(), board ); board.saveSVG( "SimplePolygonalLineMelkman2.svg" ); #ifdef WITH_CAIRO board.saveCairo("SimplePolygonalLineMelkman2.png", Board2D::CairoPNG); #endif } { //order of the points for andrew algorithm vector<Z2i::Point> res; std::copy( pointSet.begin(), pointSet.end(), back_inserter( res ) ); std::sort( res.begin(), res.end() ); //display Board2D board; drawPolygon( res.begin(), res.end(), board, false ); board.saveSVG( "AndrewWEVP.svg" ); #ifdef WITH_CAIRO board.saveCairo("AndrewWEVP.png", Board2D::CairoPNG); #endif } { //order of the points for graham algorithm vector<Z2i::Point> res; std::copy( pointSet.begin(), pointSet.end(), back_inserter( res ) ); //find an extremal point //NB: we choose the point of greatest x-coordinate //so that the sort step (by a polar comparator) //returns a weakly externally visible polygon std::vector<Z2i::Point>::iterator itMax = std::max_element( res.begin(), res.end() ); //sort around this point with a polar comparator functors::PolarPointComparatorBy2x2DetComputer<Z2i::Point> comparator; comparator.setPole( *itMax ); std::sort( res.begin(), res.end(), comparator ); //display Board2D board; drawPolygon( res.begin(), res.end(), board, false ); board.saveSVG( "GrahamWEVP.svg" ); #ifdef WITH_CAIRO board.saveCairo("GrahamWEVP.png", Board2D::CairoPNG); #endif } }
int main( int argc, char** argv ) { // Contour import args.addOption("-fc", "-fc <freemanChain.fc> : FreemanChain file name", "freeman.fc" ); args.addOption("-sdp", "-sdp <contour.sdp> : Import a contour as a Sequence of Discrete Points (SDP format)", "contour.sdp" ); args.addOption("-sfp", "-sdp <contour.sdp> : Import a contour as a Sequence of Floating Points (SFP format)", "contour.sdp" ); // Display options args.addOption("-drawContourPoint", "-drawContourPoint <size> (double): display contour points as disk of radius <size> (default 1.0) ", "1.0" ); args.addBooleanOption("-fillContour", "-fillContour fill the contours with default color"); args.addOption("-lineWidth", "-lineWidth <width> : define the linewidth <width> of the contour (default 1.0) (SDP format)", "1.0"); args.addOption("-outputEPS", "-outputEPS <filename> specify eps format (default format output.eps)", "output.eps"); args.addOption("-outputSVG", "-outputSVG <filename> specify svg format. (default name output.svg)", "output.svg"); args.addOption("-outputFIG", "-outputFIG <filename> specify svg format. (default name output.fig)", "output.fig"); #ifdef WITH_CAIRO args.addOption("-outputPDF", "-outputPDF <filename> specify svg format. (default name output.pdf)", "output.pdf"); args.addOption("-outputPNG", "-outputPNG <filename> specify png format. (default name output.png)", "output.png"); args.addBooleanOption("-invertYaxis", "-invertYaxis: invert the Y axis for display contours (used only with --SDP) "); #endif #ifdef WITH_MAGICK args.addOption("-backgroundImage", "-backgroundImage <filename> <alpha> : display image as background with transparency alpha (defaut 1) (transparency works only if cairo is available)", "imageBG.png", "1.0" ); #endif args.addOption("-backgroundImageXFIG", "-backgroundImageXFIG <filename> <width> <height> : display image as background in XFIG format", "imageBG.png", "256","256" ); args.addOption("-scale", "-scale <value> 1: normal; >1 : larger ; <1 lower resolutions ) (default 1.0) ", "1.0"); bool parseOK= args.readArguments( argc, argv ); if(!parseOK || args.check("-h") || (! args.check("-fc") && ! args.check("-sdp") && ! args.check("-sfp"))){ trace.info()<<args.usage("displayContours", "Display discrete contours. \n Basic usage: \n \t displayContours [options] -fc <fileName> \n", ""); return 1; } double lineWidth = args.getOption("-lineWidth")->getFloatValue(0); double scale = args.getOption("-scale")->getIntValue(0); bool filled = args.check("-fillContour"); Board2D aBoard; aBoard.setUnit (0.05*scale, LibBoard::Board::UCentimeter); #ifdef WITH_MAGICK double alpha=args.getOption("-alphaBG")->getFloatValue(0); if(args.check("-backgroundImage")){ string imageName = args.check("-backgroundImage")->getValue(0); typedef ImageSelector<Z2i::Domain, unsigned char>::Type Image; DGtal::MagickReader<Image> reader; Image img = reader.importImage( imageName ); Z2i::Point ptInf = img.domain().lowerBound(); Z2i::Point ptSup = img.domain().upperBound(); unsigned int width = abs(ptSup.at(0)-ptInf.at(0)+1); unsigned int height = abs(ptSup.at(1)-ptInf.at(1)+1); aBoard.drawImage(imageName, 0-0.5,height-0.5, width, height, -1, alpha ); } #endif 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()); } }
int main( int argc, char** argv ) { // parse command line ---------------------------------------------- po::options_description general_opt("Allowed options are: "); general_opt.add_options() ("help,h", "display this message") ("input,i", po::value<std::string>(), "input FreemanChain file name") ("SDP", po::value<std::string>(), "Import a contour as a Sequence of Discrete Points (SDP format)") ("SFP", po::value<std::string>(), "Import a contour as a Sequence of Floating Points (SFP format)") ("drawContourPoint", po::value<double>(), "<size> display contour points as disk of radius <size>") ("fillContour", "fill the contours with default color (gray)") ("lineWidth", po::value<double>()->default_value(1.0), "Define the linewidth of the contour (SDP format)") ("drawPointOfIndex", po::value<int>(), "<index> Draw the contour point of index <index> (default 0) ") ("pointSize", po::value<double>()->default_value(2.0), "<size> Set the display point size of the point displayed by drawPointofIndex option (default 2.0) ") ("noXFIGHeader", " to exclude xfig header in the resulting output stream (no effect with option -outputFile).") ("withProcessing", po::value<std::string>(), "Processing (used only when the input is a Freeman chain (--input)):\n\t DSS segmentation {DSS}\n\t Maximal segments {MS}\n\t Faithful Polygon {FP}\n\t Minimum Length Polygon {MLP}") ("outputFile,o", po::value<std::string>(), " <filename> save output file automatically according the file format extension.") ("outputStreamEPS", " specify eps for output stream format.") ("outputStreamSVG", " specify svg for output stream format.") ("outputStreamFIG", " specify fig for output stream format.") ("invertYaxis", " invertYaxis invert the Y axis for display contours (used only with --SDP)") ("backgroundImage", po::value<std::string>(), "backgroundImage <filename> : display image as background ") ("alphaBG", po::value<double>(), "alphaBG <value> 0-1.0 to display the background image in transparency (default 1.0), (transparency works only if cairo is available)") ("scale", po::value<double>(), "scale <value> 1: normal; >1 : larger ; <1 lower resolutions )"); bool parseOK=true; po::variables_map vm; try { po::store(po::parse_command_line(argc, argv, general_opt), vm); } catch(const std::exception& ex) { parseOK=false; trace.info()<< "Error checking program options: "<< ex.what()<< std::endl; } po::notify(vm); if(!parseOK||vm.count("help")||argc<=1 || (!(vm.count("input")) && !(vm.count("SDP")) && !(vm.count("SFP"))&& !(vm.count("backgroundImage")) ) ) { trace.info()<< "Display discrete contours. " <<std::endl << "Basic usage: "<<std::endl << "\t displayContours [options] --input <fileName> "<<std::endl << general_opt << "\n"; return 0; } double lineWidth= vm["lineWidth"].as<double>(); bool filled = vm.count("fillContour"); double scale=1.0; if(vm.count("scale")) { scale = vm["scale"].as<double>(); } Board2D aBoard; aBoard.setUnit (0.05*scale, LibBoard::Board::UCentimeter); double alpha=1.0; if(vm.count("alphaBG")) { alpha = vm["alphaBG"].as<double>(); } if(vm.count("backgroundImage")) { std::string imageName = vm["backgroundImage"].as<std::string>(); typedef ImageSelector<Z2i::Domain, unsigned char>::Type Image; Image img = DGtal::GenericReader<Image>::import( imageName ); Z2i::Point ptInf = img.domain().lowerBound(); Z2i::Point ptSup = img.domain().upperBound(); unsigned int width = abs(ptSup[0]-ptInf[0]+1); unsigned int height = abs(ptSup[1]-ptInf[1]+1); aBoard.drawImage(imageName, 0-0.5,height-0.5, width, height, -1, alpha ); } if(vm.count("input")) { std::string fileName = vm["input"].as<std::string>(); std::vector< FreemanChain<int> > vectFc = PointListReader< Z2i::Point>:: getFreemanChainsFromFile<int> (fileName); aBoard << CustomStyle( vectFc.at(0).className(), new CustomColors( Color::Red , filled? Color::Gray: Color::None ) ); aBoard.setLineWidth (lineWidth); for(unsigned int i=0; i<vectFc.size(); i++) { aBoard << vectFc.at(i) ; if(vm.count("drawPointOfIndex")) { int index = vm["drawPointOfIndex"].as<int>(); double size = vm["pointSize"].as<double>(); aBoard.setPenColor(Color::Blue); aBoard.fillCircle((double)(vectFc.at(i).getPoint(index)[0]), (double)(vectFc.at(i).getPoint(index)[1]), size); } if(vm.count("withProcessing")) { std::string processingName = vm["withProcessing"].as<std::string>(); std::vector<Z2i::Point> vPts(vectFc.at(i).size()+1); copy ( vectFc.at(i).begin(), vectFc.at(i).end(), vPts.begin() ); bool isClosed; if ( vPts.at(0) == vPts.at(vPts.size()-1) ) { isClosed = true; vPts.pop_back(); } else isClosed = false; if (processingName == "DSS") { typedef ArithmeticalDSSComputer<std::vector<Z2i::Point>::iterator,int,4> DSS4; typedef GreedySegmentation<DSS4> Decomposition4; DSS4 computer; Decomposition4 theDecomposition( vPts.begin(),vPts.end(),computer ); //for each segment std::string className; for ( Decomposition4::SegmentComputerIterator it = theDecomposition.begin(); it != theDecomposition.end(); ++it ) { DSS4::Primitive segment(it->primitive()); aBoard << SetMode( segment.className(), "BoundingBox" ); className = segment.className() + "/BoundingBox"; aBoard << CustomStyle( className, new CustomPenColor( DGtal::Color::Gray ) ); aBoard << segment; // draw each segment } } else if (processingName == "MS") { typedef ArithmeticalDSSComputer<std::vector<Z2i::Point>::iterator,int,4> DSS4; typedef SaturatedSegmentation<DSS4> Decomposition4; //Segmentation DSS4 computer; Decomposition4 theDecomposition( vPts.begin(),vPts.end(),computer ); //for each segment std::string className; for ( Decomposition4::SegmentComputerIterator it = theDecomposition.begin(); it != theDecomposition.end(); ++it ) { DSS4::Primitive segment(it->primitive()); aBoard << SetMode( segment.className(), "BoundingBox" ); className = segment.className() + "/BoundingBox"; aBoard << CustomStyle( className, new CustomPenColor( DGtal::Color::Gray ) ); aBoard << segment; // draw each segment } } else if (processingName == "FP") { typedef FP<std::vector<Z2i::Point>::iterator,int,4> FP; FP theFP( vPts.begin(),vPts.end() ); aBoard << CustomStyle( theFP.className(), new CustomPenColor( DGtal::Color::Black ) ); aBoard << theFP; } else if (processingName == "MLP") { typedef FP<std::vector<Z2i::Point>::iterator,int,4> FP; FP theFP( vPts.begin(),vPts.end() ); std::vector<FP::RealPoint> v( theFP.size() ); theFP.copyMLP( v.begin() ); //polyline to draw std::vector<LibBoard::Point> polyline; std::vector<FP::RealPoint>::const_iterator it = v.begin(); for ( ; it != v.end(); ++it) { FP::RealPoint p = (*it); polyline.push_back(LibBoard::Point(p[0],p[1])); } if (isClosed) { FP::RealPoint p = (*v.begin()); polyline.push_back(LibBoard::Point(p[0],p[1])); } aBoard.setPenColor(DGtal::Color::Black); aBoard.drawPolyline(polyline); } else if (processingName == "MDCA") { typedef KhalimskySpaceND<2,int> KSpace; typedef GridCurve<KSpace> Curve; Curve curve; //grid curve curve.initFromPointsVector( vPts ); typedef Curve::IncidentPointsRange Range; //range Range r = curve.getIncidentPointsRange(); //range typedef Range::ConstCirculator ConstCirculator; //iterator typedef StabbingCircleComputer<ConstCirculator> SegmentComputer; //segment computer //typedef GeometricalDCA<ConstIterator> SegmentComputer; //segment computer typedef SaturatedSegmentation<SegmentComputer> Segmentation; //Segmentation theSegmentation( r.begin(), r.end(), SegmentComputer() ); Segmentation theSegmentation( r.c(), r.c(), SegmentComputer() ); theSegmentation.setMode("Last"); // board << curve; Segmentation::SegmentComputerIterator it = theSegmentation.begin(); Segmentation::SegmentComputerIterator itEnd = theSegmentation.end(); Board2D otherBoard; otherBoard.setPenColor(DGtal::Color::Black); otherBoard << curve; for ( ; it != itEnd; ++it ) { aBoard << SetMode(SegmentComputer().className(), "") << (*it); otherBoard << SetMode(SegmentComputer().className(), "") << (*it); } otherBoard.saveSVG("mdca.svg", Board2D::BoundingBox, 5000 ); } } } } if(vm.count("SDP") || vm.count("SFP")) { bool drawPoints= vm.count("drawContourPoint"); bool invertYaxis = vm.count("invertYaxis"); double pointSize=1.0; if(drawPoints) { pointSize = vm["drawContourPoint"].as<double>(); } std::vector<LibBoard::Point> contourPt; if(vm.count("SDP")) { std::string fileName = vm["SDP"].as<std::string>(); std::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(vm.count("SFP")) { std::string fileName = vm["SFP"].as<std::string>(); std::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.setFillColor(Color::Gray); aBoard.setLineStyle (LibBoard::Shape::SolidStyle ); aBoard.setLineWidth (lineWidth); if(!filled) { aBoard.drawPolyline(contourPt); } else { aBoard.fillPolyline(contourPt); } if(vm.count("drawPointOfIndex")) { int index = vm["drawPointOfIndex"].as<int>(); double size = vm["pointSize"].as<double>(); aBoard.fillCircle((double)(contourPt.at(index).x), (double)(contourPt.at(index).y), size); } } if(vm.count("outputFile")) { std::string outputFileName= vm["outputFile"].as<std::string>(); std::string extension = outputFileName.substr(outputFileName.find_last_of(".") + 1); if(extension=="svg") { aBoard.saveSVG(outputFileName.c_str()); } #ifdef WITH_CAIRO else if (extension=="eps") { aBoard.saveCairo(outputFileName.c_str(),Board2D::CairoEPS ); } else if (extension=="pdf") { aBoard.saveCairo(outputFileName.c_str(),Board2D::CairoPDF ); } else if (extension=="png") { aBoard.saveCairo(outputFileName.c_str(),Board2D::CairoPNG ); } #endif else if(extension=="eps") { aBoard.saveEPS(outputFileName.c_str()); } else if(extension=="fig") { aBoard.saveFIG(outputFileName.c_str(),LibBoard::Board::BoundingBox, 10.0, !vm.count("noXFIGHeader") ); } } if (vm.count("outputStreamSVG")) { aBoard.saveSVG(std::cout); } else if (vm.count("outputStreamFIG")) { aBoard.saveFIG(std::cout, LibBoard::Board::BoundingBox, 10.0, !vm.count("noXFIGHeader")); } else if (vm.count("outputStreamEPS")) { aBoard.saveEPS(std::cout); } }
bool testImageAdapter() { unsigned int nbok = 0; unsigned int nb = 0; trace.beginBlock ("Testing ImageAdapter"); typedef ImageContainerBySTLVector< Z2i::Domain, unsigned char> VImage; typedef GrayscaleColorMap<unsigned char> Gray; string filename = testPath + "samples/church-small.pgm"; VImage image = PGMReader<VImage>::importPGM(filename); trace.info() << "Imported image: " << image << endl; Board2D aBoard; Display2DFactory::drawImage<Gray>(aBoard, image, (unsigned char)0, (unsigned char)255); aBoard.saveSVG("church.svg"); #ifdef WITH_CAIRO aBoard.saveCairo("church.png", Board2D::CairoPNG); #endif typedef ImageAdapter<VImage, Z2i::Domain, DefaultFunctor, VImage::Value, DefaultFunctor, DefaultFunctor> MyImageAdapter; BOOST_CONCEPT_ASSERT(( CImage< MyImageAdapter > )); nbok += true ? 1 : 0; nb++; // 1) bell_tower //! [ImageAdapterWithSubdomain] Z2i::Point p1( 43, 107 ); Z2i::Point p2( 73, 177 ); Z2i::Domain domain_bell_tower( p1, p2 ); DefaultFunctor idbtD, idbtV, idbtVm1; MyImageAdapter bell_tower(image, domain_bell_tower, idbtD, idbtV, idbtVm1); //! [ImageAdapterWithSubdomain] trace.info() << "ImageAdapter: " << bell_tower << " " << bell_tower.domain() << std::endl; nbok += bell_tower.isValid() ? 1 : 0; nb++; aBoard.clear(); Display2DFactory::drawImage<Gray>(aBoard, bell_tower, (unsigned char)0, (unsigned char)255); aBoard.saveSVG("bell_tower.svg"); #ifdef WITH_CAIRO aBoard.saveCairo("bell_tower.png", Board2D::CairoPNG); #endif // 2) cars Z2i::Point p3( 0, 49 ); Z2i::Point p4( 58, 72 ); Z2i::Domain domain_cars( p3, p4 ); DefaultFunctor idcD; DefaultFunctor idcV; DefaultFunctor idcVm1; MyImageAdapter cars(image, domain_cars, idcD, idcV, idcVm1); trace.info() << "ImageAdapter: " << cars << " " << cars.domain() << std::endl; nbok += cars.isValid() ? 1 : 0; nb++; aBoard.clear(); Display2DFactory::drawImage<Gray>(aBoard, cars, (unsigned char)0, (unsigned char)255); aBoard.saveSVG("cars.svg"); #ifdef WITH_CAIRO aBoard.saveCairo("cars.png", Board2D::CairoPNG); #endif // 3) fill 255 for 'bell_tower' image MyImageAdapter::Domain::ConstIterator bt_it = bell_tower.domain().begin(); MyImageAdapter::Domain::ConstIterator bt_itEnd = bell_tower.domain().end(); for (; bt_it != bt_itEnd; ++bt_it) { bell_tower.setValue(*bt_it, 255); } aBoard.clear(); Display2DFactory::drawImage<Gray>(aBoard, bell_tower, (unsigned char)0, (unsigned char)255); aBoard.saveSVG("bell_tower_after_filling.svg"); #ifdef WITH_CAIRO aBoard.saveCairo("bell_tower_after_filling.png", Board2D::CairoPNG); #endif // 4) fill 55 for 'cars' image MyImageAdapter::Domain::ConstIterator c_it = cars.domain().begin(); MyImageAdapter::Domain::ConstIterator c_itEnd = cars.domain().end(); for (; c_it != c_itEnd; ++c_it) { cars.setValue(*c_it, 55); } aBoard.clear(); Display2DFactory::drawImage<Gray>(aBoard, cars, (unsigned char)0, (unsigned char)255); aBoard.saveSVG("cars_after_filling.svg"); #ifdef WITH_CAIRO aBoard.saveCairo("cars_after_filling.png", Board2D::CairoPNG); #endif // 5) fill 0 (only for one pixel on two) for 'floor_lamp' image //! [ImageAdapterWithSpecificDomain] Z2i::Point p5( 56, 33 ); Z2i::Point p6( 68, 79 ); Z2i::Domain domain_floor_lamp( p5, p6 ); // --- DigitalSetDomain Z2i::DigitalSet mySet( domain_floor_lamp ); unsigned int i = 0; for ( Z2i::Domain::ConstIterator it = domain_floor_lamp.begin() ; it != domain_floor_lamp.end(); ++it, ++i ) { if (i%2) mySet.insertNew( *it ); } DigitalSetDomain<Z2i::DigitalSet> my_specific_domain_floor_lamp(mySet); // --- DigitalSetDomain typedef ImageAdapter<VImage, DigitalSetDomain<Z2i::DigitalSet>, DefaultFunctor, VImage::Value, DefaultFunctor, DefaultFunctor> MyImageAdapter2; // BOOST_CONCEPT_ASSERT(( CImage< MyImageAdapter2 > )); // pb here DefaultFunctor idflD, idflV, idflVm1; MyImageAdapter2 floor_lamp(image, my_specific_domain_floor_lamp, idflD, idflV, idflVm1); //! [ImageAdapterWithSpecificDomain] trace.info() << "ImageAdapter: " << floor_lamp << " " << floor_lamp.domain() << std::endl; nbok += floor_lamp.isValid() ? 1 : 0; nb++; aBoard.clear(); Display2DFactory::drawImage<Gray>(aBoard, floor_lamp, (unsigned char)0, (unsigned char)255); aBoard.saveSVG("floor_lamp.svg"); #ifdef WITH_CAIRO aBoard.saveCairo("floor_lamp.png", Board2D::CairoPNG); #endif MyImageAdapter2::Domain::ConstIterator f_it = floor_lamp.domain().begin(); MyImageAdapter2::Domain::ConstIterator f_itEnd = floor_lamp.domain().end(); for (; f_it != f_itEnd; ++f_it) { floor_lamp.setValue(*f_it, 0); } aBoard.clear(); Display2DFactory::drawImage<Gray>(aBoard, floor_lamp, (unsigned char)0, (unsigned char)255); aBoard.saveSVG("floor_lamp_after_filling.svg"); #ifdef WITH_CAIRO aBoard.saveCairo("floor_lamp_after_filling.png", Board2D::CairoPNG); #endif aBoard.clear(); Display2DFactory::drawImage<Gray>(aBoard, image, (unsigned char)0, (unsigned char)255); aBoard.saveSVG("church_after_filling.svg"); #ifdef WITH_CAIRO aBoard.saveCairo("church_after_filling.png", Board2D::CairoPNG); #endif trace.info() << "(" << nbok << "/" << nb << ") " << "true == true" << endl; trace.endBlock(); return nbok == nb; }
int main( int argc, char** argv ) { trace.beginBlock ( "Example FrechetShortcut" ); trace.info() << "Args:"; for ( int i = 0; i < argc; ++i ) trace.info() << " " << argv[ i ]; trace.info() << endl; std::string filename; double error; if(argc == 1) { trace.info() << "Use default file and error value\n"; filename = examplesPath + "samples/plant-frechet.dat"; error = 3; } else if(argc != 3) { trace.info() << "Please enter a filename and error value.\n"; return 0; } else { filename = argv[1]; error = atof(argv[2]); } ifstream instream; // input stream instream.open (filename.c_str(), ifstream::in); Curve c; //grid curve c.initFromVectorStream(instream); Board2D board; // Display the pixels as arrows range to show the way the curve is scanned board << c.getArrowsRange(); trace.beginBlock("Simple example"); //! [FrechetShortcutUsage] Curve::PointsRange r = c.getPointsRange(); typedef FrechetShortcut<Curve::PointsRange::ConstIterator,int> Shortcut; // Computation of one shortcut Shortcut s(error); s.init( r.begin() ); while ( ( s.end() != r.end() ) &&( s.extendFront() ) ) {} // Computation of a greedy segmentation typedef GreedySegmentation<Shortcut> Segmentation; Segmentation theSegmentation( r.begin(), r.end(), Shortcut(error) ); // the segmentation is computed here Segmentation::SegmentComputerIterator it = theSegmentation.begin(); Segmentation::SegmentComputerIterator itEnd = theSegmentation.end(); for ( ; it != itEnd; ++it) { s=Shortcut(*it); trace.info() << s << std::endl; board << s; } board.saveEPS("FrechetShortcutExample.eps", Board2D::BoundingBox, 5000 ); //! [FrechetShortcutUsage] #ifdef WITH_CAIRO board.saveCairo("FrechetShortcutExample.png"); #endif trace.endBlock(); return 0; }
int main( ) { trace.beginBlock ( "Example dgtalboard-2-sets" ); Point p1( -10, -7 ); Point p2( 10, 7 ); Domain domain( p1, p2 ); DigitalSet shape_set( domain ); Shapes<Domain>::addNorm1Ball( shape_set, Point( -5, -1 ), 5 ); Shapes<Domain>::addNorm1Ball( shape_set, Point( 5, 1 ), 5 ); shape_set.erase( Point( -5, -1 ) ); shape_set.erase( Point( 5, 1 ) ); Board2D board; board << domain << shape_set; // display domain and set board.saveSVG( "dgtalboard-2-sets-1.svg"); board.saveEPS( "dgtalboard-2-sets-1.eps"); #ifdef WITH_CAIRO board.saveCairo("dgtalboard-2-sets-1-cairo.pdf", Board2D::CairoPDF); board.saveCairo("dgtalboard-2-sets-1-cairo.png", Board2D::CairoPNG); board.saveCairo("dgtalboard-2-sets-1-cairo.ps", Board2D::CairoPS); board.saveCairo("dgtalboard-2-sets-1-cairo.svg", Board2D::CairoSVG); #endif board.clear(); // Object with couple (4,8) of adjacency. Object4_8 shape( dt4_8, shape_set ); board << domain // display domain << SetMode( shape.styleName(), "DrawAdjacencies" ) << shape; // and object with mode "DrawAdjacencies" board.saveSVG( "dgtalboard-2-sets-2.svg"); board.saveEPS( "dgtalboard-2-sets-2.eps"); #ifdef WITH_CAIRO board.saveCairo("dgtalboard-2-sets-2-cairo.pdf", Board2D::CairoPDF); board.saveCairo("dgtalboard-2-sets-2-cairo.png", Board2D::CairoPNG); board.saveCairo("dgtalboard-2-sets-2-cairo.ps", Board2D::CairoPS); board.saveCairo("dgtalboard-2-sets-2-cairo.svg", Board2D::CairoSVG); #endif board.clear(); // Object with couple (8,4) of adjacency. Object8_4 shape2( dt8_4, shape_set ); board << domain // display domain << SetMode( shape2.styleName(), "DrawAdjacencies" ) << shape2; // and object with mode "DrawAdjacencies" board.saveSVG( "dgtalboard-2-sets-3.svg"); board.saveEPS( "dgtalboard-2-sets-3.eps"); #ifdef WITH_CAIRO board.saveCairo("dgtalboard-2-sets-3-cairo.pdf", Board2D::CairoPDF); board.saveCairo("dgtalboard-2-sets-3-cairo.png", Board2D::CairoPNG); board.saveCairo("dgtalboard-2-sets-3-cairo.ps", Board2D::CairoPS); board.saveCairo("dgtalboard-2-sets-3-cairo.svg", Board2D::CairoSVG); #endif trace.endBlock(); return 0; }