DGtal  1.5.beta
volTrackBoundary.cpp File Reference
#include <iostream>
#include <queue>
#include "DGtal/base/Common.h"
#include "DGtal/io/viewers/Viewer3D.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/io/DrawWithDisplay3DModifier.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 qglViewer.

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 68 of file volTrackBoundary.cpp.

69 {
70  if ( argc < 4 )
71  {
72  usage( argc, argv );
73  return 1;
74  }
75  std::string inputFilename = argv[ 1 ];
76  unsigned int minThreshold = atoi( argv[ 2 ] );
77  unsigned int maxThreshold = atoi( argv[ 3 ] );
78 
80  trace.beginBlock( "Reading vol file into an image." );
82  Image image = VolReader<Image>::importVol(inputFilename);
83  DigitalSet set3d (image.domain());
85  minThreshold, maxThreshold);
86  trace.endBlock();
88 
89 
91  trace.beginBlock( "Construct the Khalimsky space from the image domain." );
92  KSpace ks;
93  bool space_ok = ks.init( image.domain().lowerBound(),
94  image.domain().upperBound(), true );
95  if (!space_ok)
96  {
97  trace.error() << "Error in the Khamisky space construction."<<std::endl;
98  return 2;
99  }
100  trace.endBlock();
102 
104  typedef SurfelAdjacency<KSpace::dimension> MySurfelAdjacency;
105  MySurfelAdjacency surfAdj( true ); // interior in all directions.
107 
109  trace.beginBlock( "Extracting boundary by tracking from an initial bel." );
110  KSpace::SCellSet boundary;
111  SCell bel = Surfaces<KSpace>::findABel( ks, set3d, 100000 );
112  Surfaces<KSpace>::trackBoundary( boundary, ks,
113  surfAdj,
114  set3d, bel );
115  trace.endBlock();
117 
119  trace.beginBlock( "Displaying surface in Viewer3D." );
120  QApplication application(argc,argv);
121  Viewer3D<> viewer( ks );
122  viewer.show();
123  viewer << SetMode3D( bel.className(), "Basic" );
124  viewer << CustomColors3D(Color(250, 0, 0 ), Color( 128, 128, 128 ) );
125  unsigned long nbSurfels = 0;
126  for ( KSpace::SCellSet::const_iterator it = boundary.begin(),
127  it_end = boundary.end(); it != it_end; ++it, ++nbSurfels )
128  viewer << *it;
129  viewer << Viewer3D<>::updateDisplay;
130  trace.info() << "nb surfels = " << nbSurfels << std::endl;
131  trace.endBlock();
132  return application.exec();
134 }
Structure representing an RGB triple with alpha component.
Definition: Color.h:68
Aim: A wrapper class around a STL associative container for storing sets of digital points within som...
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.
std::set< SCell > SCellSet
Preferred type for defining a set of SCell(s).
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()
Trace trace
Definition: Common.h:153
Aim: Define utilities to convert a digital set into an image.
Definition: SetFromImage.h:64
Modifier class in a Display3D stream. Useful to choose your own mode for a given class....
Represents a signed cell in a cellular grid space by its Khalimsky coordinates and a boolean value.
std::string className() const
Return the style name used for drawing this object.
Aim: implements methods to read a "Vol" file format.
Definition: VolReader.h:90
ImageContainerBySTLVector< Domain, Value > Image
void usage(int, char **argv)

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

◆ usage()

void usage ( int  ,
char **  argv 
)

Definition at line 61 of file volTrackBoundary.cpp.

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

Referenced by main().