DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
volScanBoundary.cpp
Go to the documentation of this file.
1
13
34
35
38
#include <iostream>
39
#include <queue>
40
#include "DGtal/helpers/StdDefs.h"
41
#include "DGtal/io/readers/VolReader.h"
42
#include "DGtal/io/Color.h"
43
#include "DGtal/images/ImageSelector.h"
44
#include "DGtal/images/imagesSetsUtils/SetFromImage.h"
45
#include "DGtal/shapes/Shapes.h"
46
#include "DGtal/topology/helpers/Surfaces.h"
47
#include "DGtal/io/viewers/PolyscopeViewer.h"
49
51
52
using namespace
std
;
53
using namespace
DGtal
;
54
using namespace
Z3i
;
55
57
58
void
usage
(
int
,
char
** argv )
59
{
60
std::cerr <<
"Usage: "
<< argv[ 0 ] <<
" <fileName.vol> <minT> <maxT>"
<< std::endl;
61
std::cerr <<
"\t - displays the boundary of the shape stored in vol file <fileName.vol>."
<< std::endl;
62
std::cerr <<
"\t - voxel v belongs to the shape iff its value I(v) follows minT <= I(v) <= maxT."
<< std::endl;
63
}
64
65
int
main
(
int
argc,
char
** argv )
66
{
67
if
( argc < 4 )
68
{
69
usage
( argc, argv );
70
return
1;
71
}
72
std::string inputFilename = argv[ 1 ];
73
unsigned
int
minThreshold = atoi( argv[ 2 ] );
74
unsigned
int
maxThreshold = atoi( argv[ 3 ] );
75
77
trace
.
beginBlock
(
"Reading vol file into an image."
);
78
typedef
ImageSelector < Domain, int>::Type
Image
;
79
Image
image
=
VolReader<Image>::importVol
(inputFilename);
80
DigitalSet
set3d (
image
.
domain
());
81
SetFromImage<DigitalSet>::append<Image>
(set3d,
image
,
82
minThreshold, maxThreshold);
83
trace
.
endBlock
();
85
86
88
trace
.
beginBlock
(
"Construct the Khalimsky space from the image domain."
);
89
KSpace
ks;
90
bool
space_ok = ks.
init
(
image
.
domain
().
lowerBound
(),
91
image
.
domain
().
upperBound
(),
true
);
92
if
(!space_ok)
93
{
94
trace
.
error
() <<
"Error in the Khamisky space construction."
<<std::endl;
95
return
2;
96
}
97
trace
.
endBlock
();
99
101
trace
.
beginBlock
(
"Extracting boundary by scanning the space. "
);
102
KSpace::SCellSet
boundary;
103
Surfaces<KSpace>::sMakeBoundary
( boundary, ks, set3d,
104
image
.
domain
().
lowerBound
(),
105
image
.
domain
().
upperBound
() );
106
trace
.
endBlock
();
108
110
trace
.
beginBlock
(
"Displaying surface in PolyscopeViewer."
);
111
PolyscopeViewer<>
viewer( ks );
112
KSpace::SCell
dummy_scell;
113
viewer.
currentStyle
.
mode
|=
DisplayStyle::SIMPLIFIED
;
114
viewer <<
Color
( 128, 128, 128 );
115
unsigned
long
nbSurfels = 0;
116
for
( KSpace::SCellSet::const_iterator it = boundary.begin(),
117
it_end = boundary.end(); it != it_end; ++it, ++nbSurfels )
118
viewer << *it;
119
trace
.
info
() <<
"nb surfels = "
<< nbSurfels << std::endl;
120
trace
.
endBlock
();
121
viewer.
show
();
122
return
0;
124
}
DGtal::Color::Color
Color()
Definition
Color.h:139
DGtal::Display3D::currentStyle
DisplayStyle currentStyle
Definition
Display3D.h:748
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 >::SCell
SignedKhalimskyCell< dim, Integer > SCell
Definition
KhalimskySpaceND.h:417
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::sMakeBoundary
static void sMakeBoundary(SCellSet &aBoundary, const KSpace &aKSpace, const PointPredicate &pp, const Point &aLowerBound, const Point &aUpperBound)
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::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::DisplayStyle::SIMPLIFIED
@ SIMPLIFIED
Definition
Display3D.h:198
DGtal::DisplayStyle::mode
size_t mode
Definition
Display3D.h:201
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
volScanBoundary.cpp
Generated on
for DGtal by
1.18.0