DGtal  1.0.0
exampleAlphaThickSegment.cpp
Go to the documentation of this file.
1 
41 #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/io/readers/PointListReader.h"
50 
51 using namespace std;
52 using namespace DGtal;
53 
55 
56 int main( )
57 {
58  trace.beginBlock ( "Example exampleAlphaThickSegment" );
59 
60 
62  typedef AlphaThickSegmentComputer< Z2i::Point, FCConstIterator > AlphaThickSegmentComputer2D;
63  Board2D aBoard;
64 
65  // Reading input contour
66  std::string freemanChainFilename = examplesPath + "samples/contourS.fc";
67  fstream fst;
68  fst.open (freemanChainFilename.c_str(), ios::in);
70  fst.close();
71  aBoard << fc;
72 
73  //construction of an AlphaThickSegmentComputer2D from the freemanchain iterator
74  AlphaThickSegmentComputer2D anAlphaSegment(15), anAlphaSegment2(5), anAlphaSegment3(2);
75  anAlphaSegment.init(fc.begin());
76  while (anAlphaSegment.end() != fc.end() &&
77  anAlphaSegment.extendFront()) {
78  }
79  aBoard << anAlphaSegment;
80  // Example of thickness definition change: usin the euclidean thickness definition.
82  AlphaThickSegmentComputer2D anAlphaSegment2Eucl(5, functions::Hull2D::EuclideanThickness);
84 
85  anAlphaSegment2Eucl.init(fc.begin());
86  while (anAlphaSegment2Eucl.end() != fc.end() &&
87  anAlphaSegment2Eucl.extendFront()) {
88  }
89 
90  aBoard << CustomStyle( anAlphaSegment2Eucl.className(),
91  new CustomColors( DGtal::Color(20, 250, 255), DGtal::Color::None ) );
92  aBoard << anAlphaSegment2Eucl;
93 
94 
95  anAlphaSegment2.init(fc.begin());
96  while (anAlphaSegment2.end() != fc.end() && anAlphaSegment2.extendFront()) {
97  }
98  aBoard << CustomStyle( anAlphaSegment2.className(), new CustomColors( DGtal::Color::Blue, DGtal::Color::None ) );
99  aBoard << anAlphaSegment2;
100 
101 
102 
103  FCConstIterator fcIt = fc.begin();
104  while (anAlphaSegment3.extendFront(*fcIt)) {
105  fcIt++;
106  }
107 
108 
109  aBoard << CustomStyle( anAlphaSegment3.className(), new CustomColors( DGtal::Color::Green, DGtal::Color::None ) );
110  aBoard << anAlphaSegment3;
111 
112 
113 
114  aBoard.saveEPS("exampleAlphaThickSegment.eps");
115 
116  trace.endBlock();
117  return 0;
118 }
119 // //
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:144
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
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
DGtal is the top-level namespace which contains all DGtal functions and types.
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