DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
volTrackBoundary.cpp
Go to the documentation of this file.
1
13
35
36
39
#include <iostream>
40
#include <queue>
41
#include "DGtal/base/Common.h"
42
#include "DGtal/io/viewers/PolyscopeViewer.h"
43
#include "DGtal/io/readers/VolReader.h"
44
#include "DGtal/io/Color.h"
45
#include "DGtal/images/ImageSelector.h"
46
#include "DGtal/images/imagesSetsUtils/SetFromImage.h"
47
#include "DGtal/shapes/Shapes.h"
48
#include "DGtal/helpers/StdDefs.h"
49
#include "DGtal/topology/helpers/Surfaces.h"
51
53
54
using namespace
std
;
55
using namespace
DGtal
;
56
using namespace
Z3i
;
57
59
60
void
usage
(
int
/*argc*/
,
char
** argv )
61
{
62
std::cerr <<
"Usage: "
<< argv[ 0 ] <<
" <fileName.vol> <minT> <maxT>"
<< std::endl;
63
std::cerr <<
"\t - displays the boundary of the shape stored in vol file <fileName.vol>."
<< std::endl;
64
std::cerr <<
"\t - voxel v belongs to the shape iff its value I(v) follows minT <= I(v) <= maxT."
<< std::endl;
65
}
66
67
int
main
(
int
argc,
char
** argv )
68
{
69
if
( argc < 4 )
70
{
71
usage
( argc, argv );
72
return
1;
73
}
74
std::string inputFilename = argv[ 1 ];
75
unsigned
int
minThreshold = atoi( argv[ 2 ] );
76
unsigned
int
maxThreshold = atoi( argv[ 3 ] );
77
79
trace
.
beginBlock
(
"Reading vol file into an image."
);
80
typedef
ImageSelector < Domain, int>::Type
Image
;
81
Image
image
=
VolReader<Image>::importVol
(inputFilename);
82
DigitalSet
set3d (
image
.
domain
());
83
SetFromImage<DigitalSet>::append<Image>
(set3d,
image
,
84
minThreshold, maxThreshold);
85
trace
.
endBlock
();
87
88
90
trace
.
beginBlock
(
"Construct the Khalimsky space from the image domain."
);
91
KSpace
ks;
92
bool
space_ok = ks.
init
(
image
.
domain
().
lowerBound
(),
93
image
.
domain
().
upperBound
(),
true
);
94
if
(!space_ok)
95
{
96
trace
.
error
() <<
"Error in the Khamisky space construction."
<<std::endl;
97
return
2;
98
}
99
trace
.
endBlock
();
101
103
typedef
SurfelAdjacency<KSpace::dimension>
MySurfelAdjacency;
104
MySurfelAdjacency surfAdj(
true
);
// interior in all directions.
106
108
trace
.
beginBlock
(
"Extracting boundary by tracking from an initial bel."
);
109
KSpace::SCellSet
boundary;
110
SCell
bel =
Surfaces<KSpace>::findABel
( ks, set3d, 100000 );
111
Surfaces<KSpace>::trackBoundary
( boundary, ks,
112
surfAdj,
113
set3d, bel );
114
trace
.
endBlock
();
116
118
trace
.
beginBlock
(
"Displaying surface in PolyscopeViewer."
);
119
PolyscopeViewer<>
viewer( ks );
120
viewer <<
Color
( 128, 128, 128 );
121
unsigned
long
nbSurfels = 0;
122
for
( KSpace::SCellSet::const_iterator it = boundary.begin(),
123
it_end = boundary.end(); it != it_end; ++it, ++nbSurfels )
124
viewer << *it;
125
trace
.
info
() <<
"nb surfels = "
<< nbSurfels << std::endl;
126
trace
.
endBlock
();
127
viewer.
show
();
128
return
0;
130
}
DGtal::Color::Color
Color()
Definition
Color.h:139
DGtal::HyperRectDomain::lowerBound
const Point & lowerBound() const
DGtal::HyperRectDomain::upperBound
const Point & upperBound() const
DGtal::Image
Aim: implements association between points lying in a digital domain and values.
Definition
Image.h:70
DGtal::Image::domain
const Domain & domain() const
Definition
Image.h:192
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::KhalimskySpaceND< 3, Integer >::SCellSet
std::set< SCell > SCellSet
Definition
KhalimskySpaceND.h:447
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::Surfaces::trackBoundary
static void trackBoundary(SCellSet &surface, const KSpace &K, const SurfelAdjacency< KSpace::dimension > &surfel_adj, const PointPredicate &pp, const SCell &start_surfel)
DGtal::Surfaces::findABel
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)
DGtal::SurfelAdjacency
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
Definition
SurfelAdjacency.h:66
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::error
std::ostream & error()
DGtal::Trace::info
std::ostream & info()
DGtal::Trace::endBlock
double endBlock()
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::SCell
KSpace::SCell SCell
Definition
StdDefs.h:149
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
DGtal::trace
Trace trace
std
STL namespace.
DGtal::ImageSelector::Type
ImageContainerBySTLVector< Domain, Value > Type
Definition
ImageSelector.h:84
DGtal::SetFromImage::append
static void append(Set &aSet, const ForegroundPredicate &isForeground, typename Image::Domain::ConstIterator itBegin, typename Image::Domain::ConstIterator itEnd)
DGtal::VolReader::importVol
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
usage
void usage(int, char **argv)
Definition
testPolynomial.cpp:58
image
Image image(domain)
examples
topology
volTrackBoundary.cpp
Generated on
for DGtal by
1.18.0