DGtal  1.4.beta
cubicalComplexThinning.cpp File Reference
#include "ConfigExamples.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/topology/CubicalComplex.h"
#include "DGtal/topology/ParDirCollapse.h"
#include "DGtal/shapes/GaussDigitizer.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/shapes/EuclideanShapesDecorator.h"
#include "DGtal/shapes/parametric/Flower2D.h"
#include "DGtal/io/boards/Board2D.h"
Include dependency graph for cubicalComplexThinning.cpp:

Go to the source code of this file.

Functions

template<typename CC , typename KSpace >
void getComplex (CC &complex, KSpace &K)
 
template<typename CC >
void drawComplex (Board2D &board, CC &complex)
 
int main (int, char **)
 

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
Kacper Pluta (kacpe.nosp@m.r.pl.nosp@m.uta@e.nosp@m.siee.nosp@m..fr ) Laboratoire d'Informatique Gaspard-Monge - LIGM, France
Date
2016/01/16

An example file named cubicalComplexThinning.

This file is part of the DGtal library.

Definition in file cubicalComplexThinning.cpp.

Function Documentation

◆ drawComplex()

template<typename CC >
void drawComplex ( Board2D board,
CC complex 
)

Definition at line 73 of file cubicalComplexThinning.cpp.

74 {
75  board.clear();
77  for ( Dimension d = 0; d <= 2; ++d )
78  for ( CellMapConstIterator it = complex.begin( d ), itE = complex.end( d );
79  it != itE; ++it )
80  {
81  if ( d == 0 )
82  board << CustomStyle( it->first.className(),
83  new CustomColors( Color( 0, 0, 0 ),
84  Color( 0, 0, 0 ) ) );
85  else if ( d == 1 )
86  board << CustomStyle( it->first.className(),
87  new CustomColors( Color( 200, 0, 0 ),
88  Color( 100, 255, 100 ) ) );
89  else
90  board << CustomStyle( it->first.className(),
91  new CustomColors( Color( 0, 0, 200 ),
92  Color( 100, 255, 100 ) ) );
93  board << it->first;
94  }
95 }
Structure representing an RGB triple with alpha component.
Definition: Color.h:68
ConstIterator end() const
ConstIterator begin() const
CellMap::const_iterator CellMapConstIterator
Const iterator for visiting type CellMap.
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition: Board.cpp:151
DGtal::uint32_t Dimension
Definition: Common.h:136
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition: Board2D.h:279
CC::CellMapConstIterator CellMapConstIterator

References DGtal::CubicalComplex< TKSpace, TCellContainer >::begin(), LibBoard::Board::clear(), and DGtal::CubicalComplex< TKSpace, TCellContainer >::end().

◆ getComplex()

template<typename CC , typename KSpace >
void getComplex ( CC complex,
KSpace K 
)

Definition at line 54 of file cubicalComplexThinning.cpp.

55 {
56  typedef Flower2D< Space > MyEuclideanShape;
57  MyEuclideanShape shape( RealPoint( 0.0, 0.0 ), 16, 5, 5, M_PI_2/2. );
58 
59  typedef GaussDigitizer< Space, MyEuclideanShape > MyGaussDigitizer;
60  MyGaussDigitizer digShape;
61  digShape.attach( shape );
62  digShape.init ( shape.getLowerBound(), shape.getUpperBound(), 1.0 );
63  Domain domainShape = digShape.getDomain();
64  DigitalSet aSet( domainShape );
65  Shapes<Domain>::digitalShaper( aSet, digShape );
66 
67  K.init ( domainShape.lowerBound(), domainShape.upperBound(), true );
68  complex.clear();
69  complex.construct ( aSet );
70 }
void construct(const TDigitalSet &set)
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: Model of the concept StarShaped represents any flower with k-petals in the plane.
Definition: Flower2D.h:65
void attach(ConstAlias< EuclideanShape > shape)
const Point & lowerBound() const
const Point & upperBound() const
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
Aim: A utility class for constructing different shapes (balls, diamonds, and others).
KSpace K
PointVector< 3, double > RealPoint

References DGtal::GaussDigitizer< TSpace, TEuclideanShape >::attach(), DGtal::CubicalComplex< TKSpace, TCellContainer >::clear(), DGtal::CubicalComplex< TKSpace, TCellContainer >::construct(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), K, DGtal::HyperRectDomain< TSpace >::lowerBound(), and DGtal::HyperRectDomain< TSpace >::upperBound().

◆ main()

int main ( int  ,
char **   
)

[create]

[create]

[init]

[init]

[thinn]

[thinn]

[thinnSurface]

[thinnSurface]

[thinnIsthmus]

[thinnIsthmus]

Definition at line 101 of file cubicalComplexThinning.cpp.

102 {
103  typedef map<Cell, CubicalCellData> Map;
105  Board2D board;
106  KSpace K;
107  CC complex ( K );
109  ParDirCollapse < CC > thinning ( K );
111  trace.beginBlock ( "ParDirCollapse -- 2 iterations." );
112  getComplex< CC, KSpace > ( complex, K );
113  drawComplex<CC> ( board, complex );
114  board.saveEPS ( "ComplexBeforeThinning.eps" );
116  thinning.attach ( &complex );
118 
120  thinning.eval ( 2 );
122  drawComplex<CC> ( board, complex );
123  board.saveEPS ( "ParDirCollapse_2.eps" );
124  trace.endBlock();
125 
126  trace.beginBlock ( "ParDirCollapse -- collapseSurface." );
127  getComplex< CC, KSpace > ( complex, K );
128  thinning.attach ( &complex );
130  thinning.collapseSurface ();
132  drawComplex<CC> ( board, complex );
133  board.saveEPS ( "ParDirCollapse_collapseSurface.eps" );
134  trace.endBlock();
135 
136  trace.beginBlock ( "ParDirCollapse -- collapseIsthmus." );
137  getComplex< CC, KSpace > ( complex, K );
138  thinning.attach ( &complex );
140  thinning.collapseIsthmus ();
142  drawComplex<CC> ( board, complex );
143  board.saveEPS ( "ParDirCollapse_collapseIsthmus.eps" );
144  trace.endBlock();
145  return 0;
146 }
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition: Board2D.h:71
Aim: This class represents an arbitrary cubical complex living in some Khalimsky space....
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
Aim: Implements thinning algorithms in cubical complexes. The implementation supports any model of cu...
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
std::unordered_map< Cell, CubicalCellData > Map
CubicalComplex< KSpace, Map > CC

References DGtal::ParDirCollapse< CC >::attach(), DGtal::Trace::beginBlock(), DGtal::ParDirCollapse< CC >::collapseIsthmus(), DGtal::ParDirCollapse< CC >::collapseSurface(), DGtal::Trace::endBlock(), DGtal::ParDirCollapse< CC >::eval(), K, LibBoard::Board::saveEPS(), and DGtal::trace.