DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
greedyAlphaThickDecomposition.cpp
Go to the documentation of this file.
1
16
29
38
39
40
42
#include <iostream>
43
#include "ConfigExamples.h"
44
#include "DGtal/helpers/StdDefs.h"
45
#include "DGtal/base/Common.h"
46
#include "DGtal/geometry/curves/AlphaThickSegmentComputer.h"
47
#include "DGtal/io/boards/Board2D.h"
48
#include "DGtal/geometry/curves/GreedySegmentation.h"
49
#include <DGtal/io/readers/GenericReader.h>
51
52
using namespace
std
;
53
using namespace
DGtal
;
54
56
57
int
main
()
58
{
59
trace
.
beginBlock
(
"Example of greedy alpha thick segment decompotion"
);
60
61
typedef
std::vector<Z2i::RealPoint>::const_iterator
ConstIterator
;
62
typedef
AlphaThickSegmentComputer<Z2i::RealPoint, ConstIterator >
AlphaThickSegmentComputer2D;
63
64
Board2D
aBoard;
65
std::string file = examplesPath +
"samples/contourSnoisy.sdp"
;
66
std::vector<Z2i::RealPoint> aContour =
PointListReader<Z2i::RealPoint>::getPointsFromFile
(file);
67
68
typedef
GreedySegmentation<AlphaThickSegmentComputer2D>
DecompositionAT;
69
70
// displaying contour
71
aBoard <<
SetMode
(aContour[0].className(),
"Grid"
);
72
std::vector<LibBoard::Point> poly;
73
for
(
unsigned
int
i = 0; i< aContour.size(); i++) poly.push_back(
LibBoard::Point
(aContour[i][0], aContour[i][1]));
74
aBoard.
setPenColor
(
DGtal::Color::Gray
);
75
aBoard.
fillPolyline
(poly);
76
77
// Computing greedy Alpha Thick decomposition.
79
aBoard <<
SetMode
(
"AlphaThickSegment"
,
"BoundingBox"
);
81
83
DecompositionAT theDecomposition(aContour.begin(), aContour.end(), AlphaThickSegmentComputer2D(4));
85
87
for
( DecompositionAT::SegmentComputerIterator
88
it = theDecomposition.begin(),
89
itEnd = theDecomposition.end();
90
it != itEnd; ++it )
91
{
92
aBoard <<
CustomStyle
( (*it).className(),
93
new
CustomPenColor
(
Color::Blue
) );
94
aBoard<< *it;
95
}
97
98
aBoard.
saveEPS
(
"greedyAlphaThickDecomposition.eps"
);
99
100
trace
.
endBlock
();
101
return
0;
102
}
103
// //
DGtal::AlphaThickSegmentComputer
Aim: This class is devoted to the recognition of alpha thick segments as described in fauretangential...
Definition
AlphaThickSegmentComputer.h:128
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition
Board2D.h:71
DGtal::Color::Blue
static const Color Blue
Definition
Color.h:428
DGtal::Color::Gray
static const Color Gray
Definition
Color.h:423
DGtal::GreedySegmentation
Aim: Computes the greedy segmentation of a range given by a pair of ConstIterators....
Definition
GreedySegmentation.h:150
DGtal::ConstIterator
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::endBlock
double endBlock()
LibBoard::Board::setPenColor
Board & setPenColor(const DGtal::Color &color)
Definition
Board.cpp:297
LibBoard::Board::fillPolyline
void fillPolyline(const std::vector< Point > &points, int depthValue=-1)
Definition
Board.cpp:550
LibBoard::Board::saveEPS
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition
Board.cpp:804
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::trace
Trace trace
std
STL namespace.
DGtal::CustomPenColor
Custom style class redefining the pen color. You may use Board2D::Color::None for transparent color.
Definition
Board2D.h:313
DGtal::CustomStyle::CustomStyle
CustomStyle(std::string classname, DrawableWithBoard2D *style)
Definition
Board2D.h:224
DGtal::PointListReader::getPointsFromFile
static std::vector< TPoint > getPointsFromFile(const std::string &filename, std::vector< unsigned int > aVectPosition=std::vector< unsigned int >())
DGtal::SetMode::SetMode
SetMode(std::string classname, std::string mode)
Definition
Board2D.h:254
LibBoard::Point
Struct representing a 2D point.
Definition
Point.h:27
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
examples
geometry
curves
greedyAlphaThickDecomposition.cpp
Generated on
for DGtal by
1.18.0