DGtal  1.3.beta
geometry/curves/exampleAlphaThickSegment.cpp

This example a simple alpha-thick segment recognition given from a freeman chain contour.

See also
Alpha-thick Segment Recognition
Simple example of some alpha-thick segments recognition with alpha = 2, 5 and 15.
#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"
using namespace std;
using namespace DGtal;
int main( )
{
trace.beginBlock ( "Example exampleAlphaThickSegment" );
typedef AlphaThickSegmentComputer< Z2i::Point, FCConstIterator > AlphaThickSegmentComputer2D;
Board2D aBoard;
// Reading input contour
std::string freemanChainFilename = examplesPath + "samples/contourS.fc";
fstream fst;
fst.open (freemanChainFilename.c_str(), ios::in);
fst.close();
aBoard << fc;
//construction of an AlphaThickSegmentComputer2D from the freemanchain iterator
AlphaThickSegmentComputer2D anAlphaSegment(15), anAlphaSegment2(5), anAlphaSegment3(2);
anAlphaSegment.init(fc.begin());
while (anAlphaSegment.end() != fc.end() &&
anAlphaSegment.extendFront()) {
}
aBoard << anAlphaSegment;
// Example of thickness definition change: usin the euclidean thickness definition.
AlphaThickSegmentComputer2D anAlphaSegment2Eucl(5, functions::Hull2D::EuclideanThickness);
anAlphaSegment2Eucl.init(fc.begin());
while (anAlphaSegment2Eucl.end() != fc.end() &&
anAlphaSegment2Eucl.extendFront()) {
}
aBoard << CustomStyle( anAlphaSegment2Eucl.className(),
new CustomColors( DGtal::Color(20, 250, 255), DGtal::Color::None ) );
aBoard << anAlphaSegment2Eucl;
anAlphaSegment2.init(fc.begin());
while (anAlphaSegment2.end() != fc.end() && anAlphaSegment2.extendFront()) {
}
aBoard << CustomStyle( anAlphaSegment2.className(), new CustomColors( DGtal::Color::Blue, DGtal::Color::None ) );
aBoard << anAlphaSegment2;
FCConstIterator fcIt = fc.begin();
while (anAlphaSegment3.extendFront(*fcIt)) {
fcIt++;
}
aBoard << CustomStyle( anAlphaSegment3.className(), new CustomColors( DGtal::Color::Green, DGtal::Color::None ) );
aBoard << anAlphaSegment3;
aBoard.saveEPS("exampleAlphaThickSegment.eps");
return 0;
}
// //
DGtal::Trace::endBlock
double endBlock()
DGtal::Color::Green
static const Color Green
Definition: Color.h:393
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
DGtal::trace
Trace trace
Definition: Common.h:154
DGtal::FreemanChain::ConstIterator
Definition: FreemanChain.h:141
DGtal::FreemanChain
Definition: FreemanChain.h:113
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Color::Blue
static const Color Blue
Definition: Color.h:395
DGtal::AlphaThickSegmentComputer
Aim: This class is devoted to the recognition of alpha thick segments as described in ....
Definition: AlphaThickSegmentComputer.h:127
DGtal::CustomStyle
Definition: Board2D.h:217
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::CustomColors
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:278
main
int main(int argc, char **argv)
Definition: testArithmeticDSS-benchmark.cpp:147
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:70
LibBoard::Board::saveEPS
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
DGtal::Color::None
static const Color None
Definition: Color.h:388