DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
3dKSSurfaceExtraction.cpp
Go to the documentation of this file.
1
16
29
39
40
42
#include <iostream>
43
#include "DGtal/base/Common.h"
44
45
#include "DGtal/base/Common.h"
46
#include "DGtal/io/readers/VolReader.h"
47
#include "DGtal/io/viewers/PolyscopeViewer.h"
48
#include "DGtal/io/Color.h"
49
50
#include "DGtal/images/ImageSelector.h"
51
#include "DGtal/helpers/StdDefs.h"
52
#include "ConfigExamples.h"
53
#include "DGtal/io/Color.h"
54
#include "DGtal/io/colormaps/GradientColorMap.h"
55
#include "DGtal/topology/KhalimskySpaceND.h"
56
#include "DGtal/topology/helpers/Surfaces.h"
57
58
60
61
using namespace
std
;
62
using namespace
DGtal
;
63
using namespace
Z3i
;
64
66
67
int
main
()
68
{
69
70
Point
p1( 0, 0, 0 );
71
Point
p2( 20, 20, 20 );
72
Point
c( 10, 10, 10 );
73
Domain
domain
( p1, p2);
74
75
// Generate the digital set from randam seeds and distance threshold.
76
DigitalSet
diamond_set(
domain
);
77
//srand ( time(NULL) );
78
unsigned
int
nbSeeds = 35;
79
vector<Point> vCenters;
80
vector<uint> vRad;
81
for
(
unsigned
int
i=0;i<nbSeeds; i++){
82
vCenters.push_back(
Point
(rand()%p2[0], rand()%p2[1],
83
rand()%p2[2]));
84
vRad.push_back(rand()%7);
85
}
86
for
(
Domain::ConstIterator
it =
domain
.begin(); it !=
domain
.end(); ++it ){
87
for
(
unsigned
int
i=0;i<nbSeeds; i++){
88
if
( (*it - vCenters.at(i) ).norm1() <= vRad.at(i) &&
domain
.isInside(*it) &&
89
domain
.isInside(*it+
Point
(1,1,1)) &&
domain
.isInside(*it-
Point
(1,1,1)) ){
90
diamond_set.
insertNew
( *it );
91
break
;
92
}
93
}
94
}
95
96
97
//A KhalimskySpace is constructed from the domain boundary points.
98
KSpace
K
;
99
K
.
init
(p1, p2,
true
);
100
101
SurfelAdjacency<3>
SAdj(
true
);
102
vector<vector<SCell> > vectConnectedSCell;
103
104
105
//Here since the last argument is set to true, the resulting
106
//SignedKhalimskySpaceND are signed in order to indicate the direction
107
//of exterior. You can also get the SignefKhalimskySpaceND with default
108
//sign:
109
110
Surfaces<KSpace>::extractAllConnectedSCell
(vectConnectedSCell,
K
, SAdj, diamond_set,
false
);
111
112
113
PolyscopeViewer<>
viewer (
K
);
114
115
116
// Each connected components are simply displayed with a specific color.
117
GradientColorMap<long>
gradient(0, vectConnectedSCell.size());
118
gradient.
addColor
(
Color::Red
);
119
gradient.
addColor
(
Color::Yellow
);
120
gradient.
addColor
(
Color::Green
);
121
gradient.
addColor
(
Color::Cyan
);
122
gradient.
addColor
(
Color::Blue
);
123
gradient.
addColor
(
Color::Magenta
);
124
gradient.
addColor
(
Color::Red
);
125
126
127
for
(
unsigned
int
i=0; i< vectConnectedSCell.size();i++){
128
DGtal::Color
col= gradient(i);
129
viewer << col;
130
for
(
unsigned
int
j=0; j< vectConnectedSCell.at(i).size();j++){
131
viewer << vectConnectedSCell.at(i).at(j);
132
}
133
}
134
135
136
viewer <<
Color
(250, 200,200, 200);
137
viewer << diamond_set;
138
//viewer << ClippingPlane(0,1,0.0,-2);
139
viewer.
show
();
140
return
0;
141
}
142
// //
DGtal::Color
Structure representing an RGB triple with alpha component.
Definition
Color.h:77
DGtal::Color::Red
static const Color Red
Definition
Color.h:425
DGtal::Color::Color
Color()
Definition
Color.h:139
DGtal::Color::Blue
static const Color Blue
Definition
Color.h:428
DGtal::Color::Yellow
static const Color Yellow
Definition
Color.h:431
DGtal::Color::Cyan
static const Color Cyan
Definition
Color.h:429
DGtal::Color::Green
static const Color Green
Definition
Color.h:426
DGtal::Color::Magenta
static const Color Magenta
Definition
Color.h:430
DGtal::DigitalSetByAssociativeContainer::insertNew
void insertNew(const Point &p)
DGtal::GradientColorMap
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Definition
GradientColorMap.h:120
DGtal::GradientColorMap::addColor
void addColor(const Color &color)
DGtal::HyperRectDomain< Space >::ConstIterator
Iterator ConstIterator
Definition
HyperRectDomain.h:125
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::PolyscopeViewer
Definition
PolyscopeViewer.h:57
DGtal::PolyscopeViewer::show
void show() override
Starts the event loop and display of elements.
Definition
PolyscopeViewer.h:73
DGtal::Point
DGtal::Surfaces::extractAllConnectedSCell
static void extractAllConnectedSCell(std::vector< std::vector< SCell > > &aVectConnectedSCell, const KSpace &aKSpace, const SurfelAdjacency< KSpace::dimension > &aSurfelAdj, const PointPredicate &pp, bool forceOrientCellExterior=false)
DGtal::SurfelAdjacency
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
Definition
SurfelAdjacency.h:66
DGtal::Domain
DGtal::Z3i
Z3i this namespace gathers the standard of types for 3D imagery.
DGtal::Z3i::KSpace
KhalimskySpaceND< 3, Integer > KSpace
Definition
StdDefs.h:146
DGtal::Z3i::DigitalSet
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition
StdDefs.h:173
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
std
STL namespace.
K
KSpace K
Definition
testCubicalComplex.cpp:62
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
domain
Domain domain
Definition
testProjection.cpp:88
examples
topology
3dKSSurfaceExtraction.cpp
Generated on
for DGtal by
1.18.0