DGtal  0.9.3
Functions
volScanBoundary.cpp File Reference
#include <iostream>
#include <queue>
#include "DGtal/helpers/StdDefs.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/topology/helpers/Surfaces.h"
#include "DGtal/io/viewers/Viewer3D.h"
Include dependency graph for volScanBoundary.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 volScanBoundary.

This file is part of the DGtal library.

Definition in file volScanBoundary.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

[volScanBoundary-readVol]

[volScanBoundary-readVol]

[volScanBoundary-KSpace]

[volScanBoundary-KSpace]

[volScanBoundary-ExtractingSurface]

[volScanBoundary-ExtractingSurface]

[volScanBoundary-DisplayingSurface]

[volScanBoundary-DisplayingSurface]

Definition at line 66 of file volScanBoundary.cpp.

References DGtal::Trace::beginBlock(), DGtal::Image< TImageContainer >::domain(), DGtal::Trace::endBlock(), DGtal::Trace::error(), image(), DGtal::Trace::info(), DGtal::Viewer3D< Space, KSpace >::show(), DGtal::trace, and usage().

67 {
68  if ( argc < 4 )
69  {
70  usage( argc, argv );
71  return 1;
72  }
73  std::string inputFilename = argv[ 1 ];
74  unsigned int minThreshold = atoi( argv[ 2 ] );
75  unsigned int maxThreshold = atoi( argv[ 3 ] );
76 
78  trace.beginBlock( "Reading vol file into an image." );
80  Image image = VolReader<Image>::importVol(inputFilename);
81  DigitalSet set3d (image.domain());
83  minThreshold, maxThreshold);
84  trace.endBlock();
86 
87 
89  trace.beginBlock( "Construct the Khalimsky space from the image domain." );
90  KSpace ks;
91  bool space_ok = ks.init( image.domain().lowerBound(),
92  image.domain().upperBound(), true );
93  if (!space_ok)
94  {
95  trace.error() << "Error in the Khamisky space construction."<<std::endl;
96  return 2;
97  }
98  trace.endBlock();
100 
102  trace.beginBlock( "Extracting boundary by scanning the space. " );
103  KSpace::SCellSet boundary;
104  Surfaces<KSpace>::sMakeBoundary( boundary, ks, set3d,
105  image.domain().lowerBound(),
106  image.domain().upperBound() );
107  trace.endBlock();
109 
111  trace.beginBlock( "Displaying surface in Viewer3D." );
112  QApplication application(argc,argv);
113  Viewer3D<> viewer( ks );
114  viewer.show();
115  KSpace::SCell dummy_scell;
116  viewer << SetMode3D( dummy_scell.className(), "Basic" );
117  viewer << CustomColors3D(Color(250, 0, 0 ), Color( 128, 128, 128 ) );
118  unsigned long nbSurfels = 0;
119  for ( KSpace::SCellSet::const_iterator it = boundary.begin(),
120  it_end = boundary.end(); it != it_end; ++it, ++nbSurfels )
121  viewer << *it;
122  viewer << Viewer3D<>::updateDisplay;
123  trace.info() << "nb surfels = " << nbSurfels << std::endl;
124  trace.endBlock();
125  return application.exec();
127 }
void beginBlock(const std::string &keyword="")
DigitalSetSelector< Domain, BIG_DS+HIGH_BEL_DS >::Type DigitalSet
Definition: StdDefs.h:100
Trace trace
Definition: Common.h:137
Aim: A utility class for constructing surfaces (i.e. set of (n-1)-cells).
Definition: Surfaces.h:78
KhalimskySpaceND< 2, Integer > KSpace
Definition: StdDefs.h:77
double endBlock()
Aim: implements methods to read a "Vol" file format.
Definition: VolReader.h:89
Aim: Define utilities to convert a digital set into an image.
Definition: SetFromImage.h:63
std::ostream & info()
ImageContainerBySTLVector< Domain, Value > Image
const Domain & domain() const
Definition: Image.h:192
Structure representing an RGB triple with alpha component.
Definition: Color.h:66
std::ostream & error()
void usage(int, char **argv)
Image image(domain)
Modifier class in a Display3D stream. Useful to choose your own mode for a given class. Realizes the concept CDrawableWithDisplay3D.

◆ usage()

void usage ( int  ,
char **  argv 
)

Definition at line 59 of file volScanBoundary.cpp.

Referenced by main().

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