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
volBreadthFirstTraversal.cpp File Reference
#include <iostream>
#include <queue>
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/io/Color.h"
#include "DGtal/io/colormaps/HueShadeColorMap.h"
#include "DGtal/io/viewers/PolyscopeViewer.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/DigitalSurface.h"
#include "DGtal/topology/LightImplicitDigitalSurface.h"
Include dependency graph for volBreadthFirstTraversal.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 volBreadthFirstTraversal.

This file is part of the DGtal library.

Definition in file volBreadthFirstTraversal.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

[volBreadthFirstTraversal-readVol]

[volBreadthFirstTraversal-readVol]

[volBreadthFirstTraversal-KSpace]

[volBreadthFirstTraversal-KSpace]

[volBreadthFirstTraversal-SurfelAdjacency]

[volBreadthFirstTraversal-SurfelAdjacency]

[volBreadthFirstTraversal-SetUpDigitalSurface]

[volBreadthFirstTraversal-SetUpDigitalSurface]

[volBreadthFirstTraversal-ExtractingSurface]

[volBreadthFirstTraversal-ExtractingSurface]

[volBreadthFirstTraversal-DisplayingSurface]

[volBreadthFirstTraversal-DisplayingSurface]

Definition at line 61 of file volBreadthFirstTraversal.cpp.

62{
63 if ( argc < 4 )
64 {
65 usage( argc, argv );
66 return 1;
67 }
68 std::string inputFilename = argv[ 1 ];
69 unsigned int minThreshold = atoi( argv[ 2 ] );
70 unsigned int maxThreshold = atoi( argv[ 3 ] );
71
73 trace.beginBlock( "Reading vol file into an image." );
76 DigitalSet set3d (image.domain());
78 minThreshold, maxThreshold);
79 trace.endBlock();
81
82
84 trace.beginBlock( "Construct the Khalimsky space from the image domain." );
85 KSpace ks;
86 bool space_ok = ks.init( image.domain().lowerBound(),
87 image.domain().upperBound(), true );
88 if (!space_ok)
89 {
90 trace.error() << "Error in the Khamisky space construction."<<std::endl;
91 return 2;
92 }
93 trace.endBlock();
95
97 typedef SurfelAdjacency<KSpace::dimension> MySurfelAdjacency;
98 MySurfelAdjacency surfAdj( true ); // interior in all directions.
100
102 trace.beginBlock( "Set up digital surface." );
106 SCell bel = Surfaces<KSpace>::findABel( ks, set3d, 100000 );
107 MyDigitalSurfaceContainer* ptrSurfContainer =
108 new MyDigitalSurfaceContainer( ks, set3d, surfAdj, bel );
109 MyDigitalSurface digSurf( ptrSurfContainer ); // acquired
110 trace.endBlock();
112
114 trace.beginBlock( "Extracting boundary by tracking from an initial bel." );
115 typedef BreadthFirstVisitor<MyDigitalSurface> MyBreadthFirstVisitor;
116 typedef MyBreadthFirstVisitor::Node MyNode;
117 typedef MyBreadthFirstVisitor::Size MySize;
118 MyBreadthFirstVisitor visitor( digSurf, bel );
119 unsigned long nbSurfels = 0;
120 MyNode node;
121 while ( ! visitor.finished() )
122 {
123 node = visitor.current();
124 ++nbSurfels;
125 visitor.expand();
126 }
127 MySize maxDist = node.second;
128 trace.endBlock();
130
132 trace.beginBlock( "Displaying surface in PolyscopeViewer." );
133 PolyscopeViewer<> viewer;
134 MyBreadthFirstVisitor visitor2( digSurf, bel );
135 viewer << Color::White
136 << ks.unsigns( bel );
137 visitor2.expand();
138 while ( ! visitor2.finished() )
139 {
140 node = visitor2.current();
141 viewer << WithQuantity(ks.unsigns(node.first), "value", node.second);
142 visitor2.expand();
143 }
144 trace.info() << "nb surfels = " << nbSurfels << std::endl;
145 trace.endBlock();
146 viewer.show();
147 return 0;
149}
Aim: This class is useful to perform a breadth-first exploration of a graph given a starting point or...
static const Color White
Definition Color.h:424
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
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.
Cell unsigns(const SCell &p) const
Creates an unsigned cell from a signed one.
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of an impl...
void show() override
Starts the event loop and display of elements.
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...
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
DigitalSetBoundary< KSpace, DigitalSet > MyDigitalSurfaceContainer
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())
Attach a property to an element.
Definition Display3D.h:327
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::KhalimskySpaceND< dim, TInteger >::unsigns(), usage(), and DGtal::Color::White.

◆ usage()

void usage ( int ,
char ** argv )

Definition at line 54 of file volBreadthFirstTraversal.cpp.

55{
56 std::cerr << "Usage: " << argv[ 0 ] << " <fileName.vol> <minT> <maxT>" << std::endl;
57 std::cerr << "\t - displays the boundary of the shape stored in vol file <fileName.vol>." << std::endl;
58 std::cerr << "\t - voxel v belongs to the shape iff its value I(v) follows minT <= I(v) <= maxT." << std::endl;
59}