DGtal  1.5.beta
exampleAlphaThickSegment.cpp File Reference
#include <iostream>
#include "ConfigExamples.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/base/Common.h"
#include "DGtal/geometry/curves/AlphaThickSegmentComputer.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/io/readers/PointListReader.h"
Include dependency graph for exampleAlphaThickSegment.cpp:

Go to the source code of this file.

Functions

int main ()
 

Detailed Description

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Bertrand Kerautret (kerau.nosp@m.tre@.nosp@m.loria.nosp@m..fr ) LORIA (CNRS, UMR 7503), University of Nancy, France
Date
2015/01/30

An example file named exampleAlphaThickSegment

This file is part of the DGtal library.

Definition in file exampleAlphaThickSegment.cpp.

Function Documentation

◆ main()

int main ( void  )

[exampleAlphaThickSegmentEuclDef]

[exampleAlphaThickSegmentEuclDef]

Definition at line 56 of file exampleAlphaThickSegment.cpp.

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 }
Aim: This class is devoted to the recognition of alpha thick segments as described in ....
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
Structure representing an RGB triple with alpha component.
Definition: Color.h:68
static const Color None
Definition: Color.h:412
static const Color Green
Definition: Color.h:417
static const Color Blue
Definition: Color.h:419
void beginBlock(const std::string &keyword="")
double endBlock()
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:804
Trace trace
Definition: Common.h:153
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:279

References DGtal::FreemanChain< TInteger >::begin(), DGtal::Trace::beginBlock(), DGtal::Color::Blue, DGtal::FreemanChain< TInteger >::end(), DGtal::Trace::endBlock(), DGtal::Color::Green, DGtal::Color::None, LibBoard::Board::saveEPS(), and DGtal::trace.