DGtal 1.4.2
Loading...
Searching...
No Matches
volBreadthFirstTraversal.cpp File Reference
#include <iostream>
#include <queue>
#include <QImageReader>
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/io/DrawWithDisplay3DModifier.h"
#include "DGtal/io/Color.h"
#include "DGtal/io/colormaps/HueShadeColorMap.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 "DGtal/io/viewers/Viewer3D.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 qglViewer.

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 63 of file volBreadthFirstTraversal.cpp.

64{
65 if ( argc < 4 )
66 {
67 usage( argc, argv );
68 return 1;
69 }
70 std::string inputFilename = argv[ 1 ];
71 unsigned int minThreshold = atoi( argv[ 2 ] );
72 unsigned int maxThreshold = atoi( argv[ 3 ] );
73
75 trace.beginBlock( "Reading vol file into an image." );
77 Image image = VolReader<Image>::importVol(inputFilename);
78 DigitalSet set3d (image.domain());
80 minThreshold, maxThreshold);
83
84
86 trace.beginBlock( "Construct the Khalimsky space from the image domain." );
87 KSpace ks;
88 bool space_ok = ks.init( image.domain().lowerBound(),
89 image.domain().upperBound(), true );
90 if (!space_ok)
91 {
92 trace.error() << "Error in the Khamisky space construction."<<std::endl;
93 return 2;
94 }
97
99 typedef SurfelAdjacency<KSpace::dimension> MySurfelAdjacency;
100 MySurfelAdjacency surfAdj( true ); // interior in all directions.
102
104 trace.beginBlock( "Set up digital surface." );
108 SCell bel = Surfaces<KSpace>::findABel( ks, set3d, 100000 );
109 MyDigitalSurfaceContainer* ptrSurfContainer =
110 new MyDigitalSurfaceContainer( ks, set3d, surfAdj, bel );
111 MyDigitalSurface digSurf( ptrSurfContainer ); // acquired
112 trace.endBlock();
114
116 trace.beginBlock( "Extracting boundary by tracking from an initial bel." );
117 typedef BreadthFirstVisitor<MyDigitalSurface> MyBreadthFirstVisitor;
118 typedef MyBreadthFirstVisitor::Node MyNode;
119 typedef MyBreadthFirstVisitor::Size MySize;
120 MyBreadthFirstVisitor visitor( digSurf, bel );
121 unsigned long nbSurfels = 0;
122 MyNode node;
123 while ( ! visitor.finished() )
124 {
125 node = visitor.current();
126 ++nbSurfels;
127 visitor.expand();
128 }
129 MySize maxDist = node.second;
130 trace.endBlock();
132
134 trace.beginBlock( "Displaying surface in Viewer3D." );
135 QApplication application(argc,argv);
136 Viewer3D<> viewer;
137 viewer.show();
138 HueShadeColorMap<MySize,1> hueShade( 0, maxDist );
139 MyBreadthFirstVisitor visitor2( digSurf, bel );
141 << ks.unsigns( bel );
142 visitor2.expand();
143 while ( ! visitor2.finished() )
144 {
145 node = visitor2.current();
146 Color c = hueShade( node.second );
147 viewer << CustomColors3D( Color::Red, c )
148 << ks.unsigns( node.first );
149 visitor2.expand();
150 }
151 viewer << Viewer3D<>::updateDisplay;
152 trace.info() << "nb surfels = " << nbSurfels << std::endl;
153 trace.endBlock();
154 return application.exec();
156}
Aim: This class is useful to perform a breadth-first exploration of a graph given a starting point or...
Structure representing an RGB triple with alpha component.
Definition Color.h:68
static const Color Red
Definition Color.h:416
static const Color White
Definition Color.h:415
static const Color Black
Definition Color.h:413
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as the boundary of a given...
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
Aim: Represents a set of n-1-cells in a nD space, together with adjacency relation between these cell...
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Aim: implements association bewteen points lying in a digital domain and values.
Definition Image.h:70
Aim: This class is a model of CCellularGridSpaceND. It represents the cubical grid as a cell complex,...
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...
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...
void beginBlock(const std::string &keyword="")
std::ostream & error()
std::ostream & info()
double endBlock()
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
Z3i::SCell SCell
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
DigitalSetBoundary< KSpace, DigitalSet > MyDigitalSurfaceContainer
Trace trace
Definition Common.h:153
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())
ImageContainerBySTLVector< Domain, Value > Image

References DGtal::SetFromImage< TSet >::append(), DGtal::Trace::beginBlock(), DGtal::Color::Black, DGtal::Trace::endBlock(), DGtal::Trace::error(), DGtal::Surfaces< TKSpace >::findABel(), DGtal::VolReader< TImageContainer, TFunctor >::importVol(), DGtal::Trace::info(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), DGtal::Color::Red, DGtal::Viewer3D< TSpace, TKSpace >::show(), DGtal::trace, DGtal::KhalimskySpaceND< dim, TInteger >::unsigns(), and DGtal::Color::White.

◆ usage()

void usage ( int ,
char ** argv )

Definition at line 56 of file volBreadthFirstTraversal.cpp.

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