DGtal  1.3.beta
geometry/curves/greedyAlphaThickDecomposition.cpp

This example shows the greedy decomposition of an noisy contour from the alpha-thick segment primitive with alpha = 4.

See also
Alpha-thick Segment Recognition
Greedy decomposition with alpha-thick segments with alpha = 4
#include <iostream>
#include "ConfigExamples.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/base/Common.h"
#include "DGtal/geometry/curves/AlphaThickSegmentComputer.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/geometry/curves/GreedySegmentation.h"
#include <DGtal/io/readers/GenericReader.h>
using namespace std;
using namespace DGtal;
int main()
{
trace.beginBlock ( "Example of greedy alpha thick segment decompotion" );
typedef std::vector<Z2i::RealPoint>::const_iterator ConstIterator;
typedef AlphaThickSegmentComputer<Z2i::RealPoint, ConstIterator > AlphaThickSegmentComputer2D;
Board2D aBoard;
std::string file = examplesPath + "samples/contourSnoisy.sdp";
std::vector<Z2i::RealPoint> aContour = PointListReader<Z2i::RealPoint>::getPointsFromFile (file);
// displaying contour
aBoard << SetMode(aContour[0].className(), "Grid");
std::vector<LibBoard::Point> poly;
for (unsigned int i = 0; i< aContour.size(); i++) poly.push_back(LibBoard::Point(aContour[i][0], aContour[i][1]));
aBoard.fillPolyline(poly);
// Computing greedy Alpha Thick decomposition.
aBoard << SetMode("AlphaThickSegment", "BoundingBox");
DecompositionAT theDecomposition(aContour.begin(), aContour.end(), AlphaThickSegmentComputer2D(4));
for ( DecompositionAT::SegmentComputerIterator
it = theDecomposition.begin(),
itEnd = theDecomposition.end();
it != itEnd; ++it )
{
aBoard << CustomStyle( (*it).className(),
new CustomPenColor( Color::Blue ) );
aBoard<< *it;
}
aBoard.saveEPS("greedyAlphaThickDecomposition.eps");
return 0;
}
// //
ConstIterator
MyDigitalSurface::ConstIterator ConstIterator
Definition: greedy-plane-segmentation-ex2.cpp:93
LibBoard::Board::setPenColor
Board & setPenColor(const DGtal::Color &color)
Definition: Board.cpp:298
DGtal::Trace::endBlock
double endBlock()
LibBoard::Board::fillPolyline
void fillPolyline(const std::vector< Point > &points, int depthValue=-1)
Definition: Board.cpp:551
DGtal::trace
Trace trace
Definition: Common.h:154
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::PointListReader
Aim: Implements method to read a set of points represented in each line of a file.
Definition: PointListReader.h:84
DGtal::Color::Gray
static const Color Gray
Definition: Color.h:390
DGtal::AlphaThickSegmentComputer
Aim: This class is devoted to the recognition of alpha thick segments as described in ....
Definition: AlphaThickSegmentComputer.h:127
DGtal::CustomStyle
Definition: Board2D.h:217
DGtal::GreedySegmentation
Aim: Computes the greedy segmentation of a range given by a pair of ConstIterators....
Definition: GreedySegmentation.h:149
LibBoard::Point
Struct representing a 2D point.
Definition: Point.h:27
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
main
int main(int argc, char **argv)
Definition: testArithmeticDSS-benchmark.cpp:147
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:70
LibBoard::Board::saveEPS
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
DGtal::SetMode
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition: Board2D.h:247
DGtal::CustomPenColor
Custom style class redefining the pen color. You may use Board2D::Color::None for transparent color.
Definition: Board2D.h:312