DGtal  1.5.beta
greedy-dss-decomposition.cpp File Reference
#include <cmath>
#include <iostream>
#include <sstream>
#include "DGtal/base/Common.h"
#include "DGtal/io/boards/Board2D.h"
#include "DGtal/io/Color.h"
#include "DGtal/io/colormaps/GradientColorMap.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/geometry/curves/ArithmeticalDSSComputer.h"
#include "DGtal/geometry/curves/FreemanChain.h"
#include "DGtal/geometry/curves/GreedySegmentation.h"
Include dependency graph for greedy-dss-decomposition.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
Jacques-Olivier Lachaud (jacqu.nosp@m.es-o.nosp@m.livie.nosp@m.r.la.nosp@m.chaud.nosp@m.@uni.nosp@m.v-sav.nosp@m.oie..nosp@m.fr ) Laboratory of Mathematics (CNRS, UMR 5807), University of Savoie, France
Tristan Roussillon (trist.nosp@m.an.r.nosp@m.oussi.nosp@m.llon.nosp@m.@liri.nosp@m.s.cn.nosp@m.rs.fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2010/11/26

An example file named greedy-dss-decomposition.

This file is part of the DGtal library.

Definition in file greedy-dss-decomposition.cpp.

Function Documentation

◆ main()

int main ( void  )

Definition at line 70 of file greedy-dss-decomposition.cpp.

71 {
72  trace.beginBlock ( "Example dgtalboard-5-greedy-dss" );
73 
74  typedef FreemanChain<int> Contour4;
76  typedef GreedySegmentation<DSS4> Decomposition4;
77 
78  // A Freeman chain code is a string composed by the coordinates of the first pixel, and the list of elementary displacements.
79  std::stringstream ss(stringstream::in | stringstream::out);
80  ss << "31 16 11121212121212212121212212122122222322323233323333333323333323303330330030300000100010010010001000101010101111" << endl;
81 
82  // Construct the Freeman chain
83  Contour4 theContour( ss );
84 
85  // Segmentation
86  Decomposition4 theDecomposition( theContour.begin(),theContour.end(),DSS4() );
87 
88  // Draw the domain and the contour
89  Point p1( 0, 0 );
90  Point p2( 31, 31 );
91  Domain domain( p1, p2 );
92  Board2D aBoard;
93  aBoard << SetMode( domain.className(), "Grid" )
94  << domain
95  << SetMode( "PointVector", "Grid" );
96 
97  // Draw each segment
98  string styleName = "";
99  for ( Decomposition4::SegmentComputerIterator
100  it = theDecomposition.begin(),
101  itEnd = theDecomposition.end();
102  it != itEnd; ++it )
103  {
104  aBoard << SetMode( "ArithmeticalDSS", "Points" )
105  << it->primitive();
106  aBoard << SetMode( "ArithmeticalDSS", "BoundingBox" )
107  << CustomStyle( "ArithmeticalDSS/BoundingBox",
108  new CustomPenColor( Color::Blue ) )
109  << it->primitive();
110  }
111 
112 
113  aBoard.saveSVG("greedy-dss-decomposition.svg");
114  aBoard.saveEPS("greedy-dss-decomposition.eps");
115  #ifdef WITH_CAIRO
116  aBoard.saveCairo("greedy-dss-decomposition.png");
117  #endif
118 
119  trace.endBlock();
120 
121  return 0;
122 }
Aim: This class is a wrapper around ArithmeticalDSS that is devoted to the dynamic recognition of dig...
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
Aim: Computes the greedy segmentation of a range given by a pair of ConstIterators....
std::string className() const
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
void saveSVG(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1011
void saveCairo(const char *filename, CairoType type=CairoPNG, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition: Board.cpp:1138
Trace trace
Definition: Common.h:153
Custom style class redefining the pen color. You may use Board2D::Color::None for transparent color.
Definition: Board2D.h:313
Modifier class in a Board2D stream. Useful to choose your own mode for a given class....
Definition: Board2D.h:247
Domain domain

References DGtal::Trace::beginBlock(), DGtal::HyperRectDomain< TSpace >::className(), domain, DGtal::Trace::endBlock(), LibBoard::Board::saveCairo(), LibBoard::Board::saveEPS(), LibBoard::Board::saveSVG(), and DGtal::trace.