File failed to load: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/config/TeX-MML-AM_CHTML/MathJax.js
DGtal 2.0.0
volTrackBoundary.cpp File Reference
#include <iostream>
#include <queue>
#include "DGtal/base/Common.h"
#include "DGtal/io/viewers/PolyscopeViewer.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/io/Color.h"
#include "DGtal/images/ImageSelector.h"
#include "DGtal/images/imagesSetsUtils/SetFromImage.h"
#include "DGtal/shapes/Shapes.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/topology/helpers/Surfaces.h"
Include dependency graph for volTrackBoundary.cpp:

Go to the source code of this file.

Functions

void usage (int, char **argv)
int main (int argc, char **argv)

Detailed Description

Author
Jacques-Olivier Lachaud (jacqu.nosp@m.es-o.nosp@m.livie.nosp@m.r.la.nosp@m.chaud.nosp@m.@uni.nosp@m.v-sav.nosp@m.oie..nosp@m.fr ) Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
Date
2012/02/06

An example file named volTrackBoundary.

This file is part of the DGtal library.

Definition in file volTrackBoundary.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

[volTrackBoundary-readVol]

[volTrackBoundary-readVol]

[volTrackBoundary-KSpace]

[volTrackBoundary-KSpace]

[volTrackBoundary-SurfelAdjacency]

[volTrackBoundary-SurfelAdjacency]

[volTrackBoundary-ExtractingSurface]

[volTrackBoundary-ExtractingSurface]

[volTrackBoundary-DisplayingSurface]

[volTrackBoundary-DisplayingSurface]

Definition at line 67 of file volTrackBoundary.cpp.

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." );
82 DigitalSet set3d (image.domain());
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}
Structure representing an RGB triple with alpha component.
Definition Color.h:77
Aim: implements association bewteen points lying in a digital domain and values.
Definition Image.h:70
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
static void trackBoundary(SCellSet &surface, const KSpace &K, const SurfelAdjacency< KSpace::dimension > &surfel_adj, const PointPredicate &pp, const SCell &start_surfel)
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
KhalimskySpaceND< 3, Integer > KSpace
Definition StdDefs.h:146
KSpace::SCell SCell
Definition StdDefs.h:149
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition StdDefs.h:173
Trace trace
ImageContainerBySTLVector< Domain, Value > Type
static void append(Set &aSet, const ForegroundPredicate &isForeground, typename Image::Domain::ConstIterator itBegin, typename Image::Domain::ConstIterator itEnd)
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
Image image(domain)

References DGtal::SetFromImage< TSet >::append(), DGtal::Surfaces< TKSpace >::findABel(), image(), DGtal::VolReader< TImageContainer, TFunctor >::importVol(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), DGtal::PolyscopeViewer< Space, KSpace >::show(), DGtal::trace, DGtal::Surfaces< TKSpace >::trackBoundary(), and usage().

◆ usage()

void usage ( int ,
char ** argv )

Definition at line 60 of file volTrackBoundary.cpp.

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}