DGtal 1.3.0
No Matches
greedyAlphaThickDecomposition.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/geometry/curves/GreedySegmentation.h"
#include <DGtal/io/readers/GenericReader.h>

Go to the source code of this file.


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/.

Bertrand Kerautret (kerau.nosp@m.tre@.nosp@m.loria.nosp@m..fr ) LORIA (CNRS, UMR 7503), University of Nancy, France

An example file named exampleAlphaThickSegment

This file is part of the DGtal library.

Definition in file greedyAlphaThickDecomposition.cpp.

Function Documentation

◆ main()

int main ( void  )







Definition at line 57 of file greedyAlphaThickDecomposition.cpp.

59 trace.beginBlock ( "Example of greedy alpha thick segment decompotion" );
61 typedef std::vector<Z2i::RealPoint>::const_iterator ConstIterator;
62 typedef AlphaThickSegmentComputer<Z2i::RealPoint, ConstIterator > AlphaThickSegmentComputer2D;
64 Board2D aBoard;
65 std::string file = examplesPath + "samples/contourSnoisy.sdp";
66 std::vector<Z2i::RealPoint> aContour = PointListReader<Z2i::RealPoint>::getPointsFromFile (file);
70 // displaying contour
71 aBoard << SetMode(aContour[0].className(), "Grid");
72 std::vector<LibBoard::Point> poly;
73 for (unsigned int i = 0; i< aContour.size(); i++) poly.push_back(LibBoard::Point(aContour[i][0], aContour[i][1]));
75 aBoard.fillPolyline(poly);
77 // Computing greedy Alpha Thick decomposition.
79 aBoard << SetMode("AlphaThickSegment", "BoundingBox");
83 DecompositionAT theDecomposition(aContour.begin(), aContour.end(), AlphaThickSegmentComputer2D(4));
87 for ( DecompositionAT::SegmentComputerIterator
88 it = theDecomposition.begin(),
89 itEnd = theDecomposition.end();
90 it != itEnd; ++it )
91 {
92 aBoard << CustomStyle( (*it).className(),
94 aBoard<< *it;
95 }
98 aBoard.saveEPS("greedyAlphaThickDecomposition.eps");
100 trace.endBlock();
101 return 0;
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
static const Color Gray
Definition: Color.h:414
static const Color Blue
Definition: Color.h:419
Aim: Computes the greedy segmentation of a range given by a pair of ConstIterators....
void beginBlock(const std::string &keyword="")
double endBlock()
Board & setPenColor(const DGtal::Color &color)
Definition: Board.cpp:298
void fillPolyline(const std::vector< Point > &points, int depthValue=-1)
Definition: Board.cpp:551
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:805
MyDigitalSurface::ConstIterator ConstIterator
Trace trace
Definition: Common.h:154
Custom style class redefining the pen color. You may use Board2D::Color::None for transparent color.
Definition: Board2D.h:313
static std::vector< TPoint > getPointsFromFile(const std::string &filename, std::vector< unsigned int > aVectPosition=std::vector< unsigned int >())
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition: Board2D.h:247
Struct representing a 2D point.
Definition: Point.h:27

References DGtal::Trace::beginBlock(), DGtal::Color::Blue, DGtal::Trace::endBlock(), LibBoard::Board::fillPolyline(), DGtal::PointListReader< TPoint >::getPointsFromFile(), DGtal::Color::Gray, LibBoard::Board::saveEPS(), LibBoard::Board::setPenColor(), and DGtal::trace.