This example outputs a greedy segmentation of a closed and 4-connected digital curve into DSSs.
#include <cmath>
#include <iostream>
#include <sstream>
#include "DGtal/base/Common.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/io/Color.h"
#include "DGtal/io/colormaps/GradientColorMap.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/geometry/curves/ArithmeticalDSSComputer.h"
#include "DGtal/geometry/curves/FreemanChain.h"
#include "DGtal/geometry/curves/GreedySegmentation.h"
using namespace Z2i;
{
trace.
beginBlock (
"Example dgtalboard-5-greedy-dss" );
std::stringstream ss(stringstream::in | stringstream::out);
ss << "31 16 11121212121212212121212212122122222322323233323333333323333323303330330030300000100010010010001000101010101111" << endl;
Contour4 theContour( ss );
Decomposition4 theDecomposition( theContour.begin(),theContour.end(),DSS4() );
<<
SetMode(
"PointVector",
"Grid" );
string styleName = "";
for ( Decomposition4::SegmentComputerIterator
it = theDecomposition.begin(),
itEnd = theDecomposition.end();
it != itEnd; ++it )
{
aBoard <<
SetMode(
"ArithmeticalDSS",
"Points" )
<< it->primitive();
aBoard <<
SetMode(
"ArithmeticalDSS",
"BoundingBox" )
<< it->primitive();
}
aBoard.
saveSVG(
"greedy-dss-decomposition.svg");
aBoard.
saveEPS(
"greedy-dss-decomposition.eps");
#ifdef WITH_CAIRO
aBoard.
saveCairo(
"greedy-dss-decomposition.png");
#endif
return 0;
}
Aim: This class is a wrapper around ArithmeticalDSS that is devoted to the dynamic recognition of dig...
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Aim: Computes the greedy segmentation of a range given by a pair of ConstIterators....
void beginBlock(const std::string &keyword="")
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
void saveCairo(const char *filename, CairoType type=CairoPNG, PageSize size=Board::BoundingBox, double margin=10.0) const
DGtal is the top-level namespace which contains all DGtal functions and types.
Custom style class redefining the pen color. You may use Board2D::Color::None for transparent color.
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
HyperRectDomain< Space > Domain