DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
exampleAlphaThickSegmentTgtCover.cpp
Go to the documentation of this file.
1
16
29
30
31
40
41
42
44
#include <iostream>
45
#include "ConfigExamples.h"
46
#include "DGtal/helpers/StdDefs.h"
47
#include "DGtal/base/Common.h"
49
#include "DGtal/geometry/curves/AlphaThickSegmentComputer.h"
50
#include "DGtal/geometry/curves/SaturatedSegmentation.h"
51
#include "DGtal/base/Circulator.h"
54
#include "DGtal/geometry/curves/SegmentComputerUtils.h"
56
57
58
#include "DGtal/io/boards/Board2D.h"
59
61
62
using namespace
std
;
63
using namespace
DGtal
;
64
66
67
int
main
()
68
{
69
trace
.
beginBlock
(
"Example of AlphaThickSegment tangential cover obtained from SaturatedSegmentation"
);
70
72
typedef
std::vector<Z2i::RealPoint>::const_iterator RAConstIterator;
73
typedef
Circulator<RAConstIterator>
ConstCirculator;
74
typedef
AlphaThickSegmentComputer<Z2i::RealPoint, ConstCirculator>
AlphaThickSegmentComputer2D;
75
typedef
SaturatedSegmentation<AlphaThickSegmentComputer2D>
AlphaSegmentation;
77
78
79
Board2D
aBoard, aBoard2;
80
std::string file = examplesPath +
"samples/contourSnoisy.sdp"
;
81
std::vector<Z2i::RealPoint> aContour =
PointListReader<Z2i::RealPoint>::getPointsFromFile
(file);
82
83
// displaying contour
84
aBoard <<
SetMode
(aContour[0].className(),
"Grid"
);
85
aBoard2 <<
SetMode
(aContour[0].className(),
"Grid"
);
86
std::vector<LibBoard::Point> poly;
87
for
(
unsigned
int
i = 0; i< aContour.size(); i++) poly.push_back(
LibBoard::Point
(aContour[i][0], aContour[i][1]));
88
aBoard.
setPenColor
(
DGtal::Color
(200, 200, 200));
89
aBoard.
fillPolyline
(poly);
90
aBoard2.
setPenColor
(
DGtal::Color
(200, 200, 200));
91
aBoard2.
fillPolyline
(poly);
92
94
Circulator<RAConstIterator>
circulator (aContour.begin(), aContour.begin(), aContour.end());
96
98
AlphaThickSegmentComputer2D computer(4,
functions::Hull2D::EuclideanThickness
);
99
AlphaSegmentation segmentator(circulator, circulator, computer);
101
103
AlphaSegmentation::SegmentComputerIterator i = segmentator.begin();
104
AlphaSegmentation::SegmentComputerIterator end = segmentator.end();
105
106
for
( ; i != end; ++i) {
107
AlphaThickSegmentComputer2D current(*i);
108
aBoard <<
SetMode
(current.className(),
"BoundingBox"
);
109
aBoard << current;
110
}
112
aBoard.
saveEPS
(
"exampleAlphaThickSegmentTgtCover.eps"
);
113
trace
.
endBlock
();
114
115
trace
.
beginBlock
(
"Example of AlphaThickSegment tangential cover obtained for a single point"
);
116
117
// Displaying Tangential cover associated to a single point:
118
120
unsigned
int
index
= 80;
121
firstMaximalSegment
(computer, circulator+
index
, circulator, circulator);
122
AlphaThickSegmentComputer2D first (computer);
123
lastMaximalSegment
(computer, circulator+
index
, circulator, circulator);
124
AlphaThickSegmentComputer2D last (computer);
126
127
aBoard2.
setPenColor
(
DGtal::Color::Blue
);
128
aBoard2.
fillCircle
((*(circulator+
index
))[0], (*(circulator+
index
))[1], 1.0);
130
while
(first.end() != last.end()){
131
aBoard2 <<
SetMode
(first.className(),
"BoundingBox"
);
132
aBoard2 << first;
133
nextMaximalSegment
(first, circulator);
134
}
135
aBoard2 << last;
137
138
stringstream name;
139
name <<
"exampleAlphaThickSegmentTgtCoverPoint"
<<
index
<<
".eps"
;
140
aBoard2.
saveEPS
(name.str().c_str());
141
trace
.
endBlock
();
142
143
144
145
146
return
0;
147
}
148
// //
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::Circulator
Aim: Provides an adapter for classical iterators that can iterate through the underlying data structu...
Definition
Circulator.h:86
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition
Color.h:77
DGtal::Color::Blue
static const Color Blue
Definition
Color.h:428
DGtal::SaturatedSegmentation
Aim: Computes the saturated segmentation, that is the whole set of maximal segments within a range gi...
Definition
SaturatedSegmentation.h:154
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::fillCircle
void fillCircle(double x, double y, double radius, int depthValue=-1)
Definition
Board.cpp:470
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::functions::Hull2D::EuclideanThickness
@ EuclideanThickness
Definition
Hull2DHelpers.h:78
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::lastMaximalSegment
void lastMaximalSegment(SC &s, const typename SC::ConstIterator &i, const typename SC::ConstIterator &begin, const typename SC::ConstIterator &end, DGtal::ForwardSegmentComputer)
Definition
SegmentComputerUtils.h:681
DGtal::trace
Trace trace
DGtal::nextMaximalSegment
void nextMaximalSegment(SC &s, const typename SC::ConstIterator &end, DGtal::ForwardSegmentComputer)
Definition
SegmentComputerUtils.h:797
DGtal::firstMaximalSegment
void firstMaximalSegment(SC &s, const typename SC::ConstIterator &i, const typename SC::ConstIterator &begin, const typename SC::ConstIterator &end, DGtal::ForwardSegmentComputer)
Definition
SegmentComputerUtils.h:412
std
STL namespace.
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
index
unsigned int index(DGtal::uint32_t n, unsigned int b)
Definition
testBits.cpp:44
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
examples
geometry
curves
exampleAlphaThickSegmentTgtCover.cpp
Generated on
for DGtal by
1.18.0