DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
cubicalComplexThinning.cpp
Go to the documentation of this file.
1
16
29
31
#include "ConfigExamples.h"
32
#include "DGtal/helpers/StdDefs.h"
33
// Cellular grid
34
#include "DGtal/topology/CubicalComplex.h"
36
#include "DGtal/topology/ParDirCollapse.h"
38
// Shape construction
39
#include "DGtal/shapes/GaussDigitizer.h"
40
#include "DGtal/shapes/Shapes.h"
41
#include "DGtal/shapes/EuclideanShapesDecorator.h"
42
#include "DGtal/shapes/parametric/Flower2D.h"
43
// Drawing
44
#include "DGtal/io/boards/Board2D.h"
46
47
using namespace
std
;
48
using namespace
DGtal
;
49
using namespace
Z2i
;
50
52
53
template
<
typename
CC,
typename
KSpace>
54
void
getComplex
(
CC
& complex,
KSpace
&
K
)
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
}
71
72
template
<
typename
CC>
73
void
drawComplex
(
Board2D
& board,
CC
& complex )
74
{
75
board.
clear
();
76
typedef
typename
CC::CellMapConstIterator
CellMapConstIterator
;
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
}
96
98
// //
99
100
101
int
main
(
int
,
char
** )
102
{
103
typedef
map<Cell, CubicalCellData>
Map
;
104
typedef
CubicalComplex< KSpace, Map >
CC
;
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
}
DGtal::Board2D
Aim: This class specializes a 'Board' class so as to display DGtal objects more naturally (with <<)....
Definition
Board2D.h:71
DGtal::Color::Color
Color()
Definition
Color.h:139
DGtal::CubicalComplex< KSpace, Map >
DGtal::CubicalComplex< KSpace, Map >::CellMapConstIterator
CellMap::const_iterator CellMapConstIterator
Definition
CubicalComplex.h:252
DGtal::Flower2D< Space >
DGtal::GaussDigitizer< Space, MyEuclideanShape >
DGtal::GaussDigitizer::attach
void attach(ConstAlias< EuclideanShape > shape)
DGtal::KhalimskySpaceND::init
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
DGtal::ParDirCollapse::collapseSurface
void collapseSurface()
DGtal::ParDirCollapse::attach
void attach(Alias< CC > pComplex)
DGtal::ParDirCollapse::collapseIsthmus
void collapseIsthmus()
DGtal::ParDirCollapse::eval
unsigned int eval(unsigned int iterations)
DGtal::Shapes::digitalShaper
static void digitalShaper(TDigitalSet &aSet, const TShapeFunctor &aFunctor)
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::endBlock
double endBlock()
DGtal::Domain
LibBoard::Board::clear
void clear(const DGtal::Color &color=DGtal::Color::None)
Definition
Board.cpp:151
LibBoard::Board::saveEPS
void saveEPS(const char *filename, PageSize size=Board::BoundingBox, double margin=10.0) const
Definition
Board.cpp:804
drawComplex
void drawComplex(Board2D &board, CC &complex)
Definition
cubicalComplexThinning.cpp:73
DGtal::Z2i
Z2i this namespace gathers the standard of types for 2D imagery.
DGtal::Z2i::KSpace
KhalimskySpaceND< 2, Integer > KSpace
Definition
StdDefs.h:77
DGtal::Z2i::RealPoint
Space::RealPoint RealPoint
Definition
StdDefs.h:97
DGtal::Z2i::DigitalSet
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition
StdDefs.h:100
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::Dimension
DGtal::uint32_t Dimension
Definition
Common.h:119
DGtal::trace
Trace trace
std
STL namespace.
DGtal::CustomColors
Custom style class redefining the pen color and the fill color. You may use Board2D::Color::None for ...
Definition
Board2D.h:279
DGtal::CustomStyle::CustomStyle
CustomStyle(std::string classname, DrawableWithBoard2D *style)
Definition
Board2D.h:224
K
KSpace K
Definition
testCubicalComplex.cpp:62
Map
std::unordered_map< Cell, CubicalCellData > Map
Definition
testCubicalComplex.cpp:57
CC
CubicalComplex< KSpace, Map > CC
Definition
testCubicalComplex.cpp:58
CellMapConstIterator
CC::CellMapConstIterator CellMapConstIterator
Definition
testCubicalComplex.cpp:59
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
getComplex
void getComplex(CC &complex, KSpace &K)
Definition
testParDirCollapse.cpp:55
examples
topology
cubicalComplexThinning.cpp
Generated on
for DGtal by
1.18.0