DGtal  1.0.beta
exampleAlphaThickSegment.cpp
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 
81  anAlphaSegment2.init(fc.begin());
82  while (anAlphaSegment2.end() != fc.end() && anAlphaSegment2.extendFront()) {
83  }
84  aBoard << CustomStyle( anAlphaSegment2.className(), new CustomColors( DGtal::Color::Blue, DGtal::Color::None ) );
85  aBoard << anAlphaSegment2;
86 
87  // Example of thickness definition change: usin the euclidean thickness definition.
89  AlphaThickSegmentComputer2D anAlphaSegment2Eucl(5, functions::Hull2D::EuclideanThickness);
91 
92  anAlphaSegment2Eucl.init(fc.begin());
93  while (anAlphaSegment2Eucl.end() != fc.end() &&
94  anAlphaSegment2Eucl.extendFront()) {
95  }
96 
97  aBoard << CustomStyle( anAlphaSegment2Eucl.className(),
98  new CustomColors( DGtal::Color(20, 250, 255), DGtal::Color::None ) );
99  aBoard << anAlphaSegment2Eucl;
100 
101 
102  FCConstIterator fcIt = fc.begin();
103  while (anAlphaSegment3.extendFront(*fcIt)) {
104  fcIt++;
105  }
106 
107 
108  aBoard << CustomStyle( anAlphaSegment3.className(), new CustomColors( DGtal::Color::Green, DGtal::Color::None ) );
109  aBoard << anAlphaSegment3;
110 
111 
112 
113  aBoard.saveEPS("exampleAlphaThickSegment.eps");
114 
115  trace.endBlock();
116  return 0;
117 }
118 // //
void beginBlock(const std::string &keyword="")
Trace trace
Definition: Common.h:137
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