DGtal  0.9.2
exampleAlphaThickSegment.cpp
1 
30 #include <iostream>
32 #include "ConfigExamples.h"
33 #include "DGtal/helpers/StdDefs.h"
34 #include "DGtal/base/Common.h"
35 #include "DGtal/geometry/curves/AlphaThickSegmentComputer.h"
36 #include "DGtal/io/boards/Board2D.h"
37 #include "DGtal/io/readers/PointListReader.h"
39 
40 using namespace std;
41 using namespace DGtal;
42 
44 
45 int main( )
46 {
47  trace.beginBlock ( "Example exampleAlphaThickSegment" );
48 
49 
51  typedef AlphaThickSegmentComputer< Z2i::Point, FCConstIterator > AlphaThickSegmentComputer2D;
52  Board2D aBoard;
53 
54  // Reading input contour
55  std::string freemanChainFilename = examplesPath + "samples/contourS.fc";
56  fstream fst;
57  fst.open (freemanChainFilename.c_str(), ios::in);
59  fst.close();
60  aBoard << fc;
61 
62  //construction of an AlphaThickSegmentComputer2D from the freemanchain iterator
63  AlphaThickSegmentComputer2D anAlphaSegment(15), anAlphaSegment2(5), anAlphaSegment3(2);
64  anAlphaSegment.init(fc.begin());
65  while (anAlphaSegment.end() != fc.end() &&
66  anAlphaSegment.extendFront()) {
67  }
68  aBoard << anAlphaSegment;
69 
70  anAlphaSegment2.init(fc.begin());
71  while (anAlphaSegment2.end() != fc.end() && anAlphaSegment2.extendFront()) {
72  }
73  aBoard << CustomStyle( anAlphaSegment2.className(), new CustomColors( DGtal::Color::Blue, DGtal::Color::None ) );
74  aBoard << anAlphaSegment2;
75 
76  // Example of thickness definition change: usin the euclidean thickness definition.
78  AlphaThickSegmentComputer2D anAlphaSegment2Eucl(5, functions::Hull2D::EuclideanThickness);
80 
81  anAlphaSegment2Eucl.init(fc.begin());
82  while (anAlphaSegment2Eucl.end() != fc.end() &&
83  anAlphaSegment2Eucl.extendFront()) {
84  }
85 
86  aBoard << CustomStyle( anAlphaSegment2Eucl.className(),
87  new CustomColors( DGtal::Color(20, 250, 255), DGtal::Color::None ) );
88  aBoard << anAlphaSegment2Eucl;
89 
90 
91  FCConstIterator fcIt = fc.begin();
92  while (anAlphaSegment3.extendFront(*fcIt)) {
93  fcIt++;
94  }
95 
96 
97  aBoard << CustomStyle( anAlphaSegment3.className(), new CustomColors( DGtal::Color::Green, DGtal::Color::None ) );
98  aBoard << anAlphaSegment3;
99 
100 
101 
102  aBoard.saveEPS("exampleAlphaThickSegment.eps");
103 
104  trace.endBlock();
105  return 0;
106 }
107 // //
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:130
STL namespace.
double endBlock()
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:278
static const Color None
Definition: Color.h:387
static const Color Blue
Definition: Color.h:394
DGtal is the top-level namespace which contains all DGtal functions and types.
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
Aim: This class is devoted to the recognition of alpha thick segments as described in ...
static const Color Green
Definition: Color.h:392
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)...
Definition: Board2D.h:70