34 #include <QtGui/qapplication.h>
35 #include "DGtal/io/viewers/Viewer3D.h"
36 #include "DGtal/io/DrawWithDisplay3DModifier.h"
37 #include "DGtal/io/Color.h"
38 #include "DGtal/base/Common.h"
39 #include "DGtal/helpers/StdDefs.h"
40 #include "DGtal/shapes/Shapes.h"
41 #include "DGtal/io/colormaps/HueShadeColorMap.h"
42 #include "DGtal/io/colormaps/GradientColorMap.h"
45 using namespace DGtal;
50 #include <boost/program_options/options_description.hpp>
51 #include <boost/program_options/parsers.hpp>
52 #include <boost/program_options/variables_map.hpp>
54 namespace po = boost::program_options;
57 #include "DGtal/io/readers/VolReader.h"
58 #include "DGtal/images/ImageContainerBySTLVector.h"
59 #include "DGtal/images/ImageContainerBySTLMap.h"
60 #include "DGtal/images/ConstImageAdapter.h"
61 #include "DGtal/base/BasicFunctors.h"
62 #include "DGtal/kernel/BasicPointPredicates.h"
65 #include "DGtal/topology/SurfelAdjacency.h"
66 #include "DGtal/topology/helpers/FrontierPredicate.h"
67 #include "DGtal/topology/LightExplicitDigitalSurface.h"
70 #include "DGtal/geometry/volumes/distance/FMM.h"
73 int main(
int argc,
char** argv )
78 po::options_description general_opt(
"Allowed options are");
79 general_opt.add_options()
80 (
"help,h",
"display this message")
81 (
"inputImage,i", po::value<string>(),
"Grey-level image (vol format)" )
82 (
"threshold,t", po::value<int>()->default_value(1),
"Set defined by the voxels whose value is below t" )
83 (
"width,w", po::value<double>()->default_value(3.0),
"Band width where DT is computed" );
86 po::store(po::parse_command_line(argc, argv, general_opt), vm);
88 if(vm.count(
"help")||argc<=1)
90 trace.
info()<<
"3d incremental DT transform" << std::endl
91 <<
"Basic usage: "<<std::endl
92 << argv[0] <<
" [other options] -i <vol file> -t <threshold> " << std::endl
93 << general_opt <<
"\n";
99 int t = vm[
"threshold"].as<
int>();
101 double maximalWidth = vm[
"width"].as<
double>();
111 typedef Frontier::SurfelConstIterator SurfelIterator;
113 if (!(vm.count(
"inputImage")))
115 trace.
emphase() <<
"you should use option -i" << std::endl;
120 string imageFileName = vm[
"inputImage"].as<std::string>();
130 BinaryImage binaryImage(labelImage, labelImage.domain(), g, thresholder);
137 Domain d = labelImage.domain();
150 trace.
emphase() <<
"starting bel not found" << std::endl;
156 std::pair<Point,Point> bpair = functor(bel);
157 SurfelPredicate surfelPredicate( ks, binaryImage,
158 binaryImage( bpair.second ),
159 binaryImage( bpair.first ) );
160 Frontier frontier( ks, surfelPredicate,
177 DistanceImage image( d, 0.0 );
178 PointSet points(image);
179 FMM::initFromBelsRange( ks, frontier.begin(), frontier.end(), image, points, 0.5 );
184 FMM fmm( image, points, d.
predicate(), d.
size(), maximalWidth );
193 QApplication application(argc,argv);
199 colorMap.addColor(
Color( 255, 0, 0 ) );
200 colorMap.addColor(
Color( 0, 250, 0 ) );
201 for (DistanceImage::const_iterator it = image.begin(), itEnd = image.end();
205 viewer <<
CustomColors3D( colorMap(it->second), colorMap(it->second) ) ;
210 double a = -extent[0]/2, b = extent[1]/2;
211 double c = 0, mu = (a+b);
213 << a <<
", " << b <<
", " << c <<
", " << mu <<
")"
217 viewer << Viewer3D::updateDisplay;
218 return application.exec();