DGtal  1.2.0
Functions
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);
81  trace.endBlock();
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  }
95  trace.endBlock();
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 );
140  viewer << CustomColors3D( Color::Black, Color::White )
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:67
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...
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
Definition: Surfaces.h:79
std::ostream & error()
void beginBlock(const std::string &keyword="")
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...
DigitalSurface< MyDigitalSurfaceContainer > MyDigitalSurface
DigitalSetBoundary< KSpace, DigitalSet > MyDigitalSurfaceContainer
Trace trace
Definition: Common.h:154
Aim: Define utilities to convert a digital set into an image.
Definition: SetFromImage.h:64
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
Aim: implements methods to read a "Vol" file format.
Definition: VolReader.h:90
HalfEdgeDataStructure::Size Size
ImageContainerBySTLVector< Domain, Value > Image
void usage(int, char **argv)

References DGtal::Trace::beginBlock(), DGtal::Trace::endBlock(), DGtal::Trace::error(), DGtal::Trace::info(), DGtal::KhalimskySpaceND< dim, TInteger >::init(), DGtal::Viewer3D< TSpace, TKSpace >::show(), DGtal::trace, DGtal::KhalimskySpaceND< dim, TInteger >::unsigns(), and usage().

◆ 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 }

Referenced by main().