DGtal  1.2.0
volDTGranulo-template.cpp
1 
32 #include <iostream>
33 #include <fstream>
34 #include <algorithm>
36 
38 #include "DGtal/base/Common.h"
39 #include "DGtal/helpers/StdDefs.h"
40 
41 #include "DGtal/images/ImageContainerBySTLVector.h"
42 
43 #include "DGtal/io/readers/VolReader.h"
44 #include "DGtal/io/writers/VolWriter.h"
45 
46 #include "DGtal/images/SimpleThresholdForegroundPredicate.h"
47 #include "DGtal/geometry/volumes/distance/DistanceTransformation.h"
48 #include "DGtal/shapes/implicit/ImplicitBall.h"
49 #include "DGtal/base/BasicFunctors.h"
51 
53 #include "DGtal/io/viewers/Viewer3D.h"
54 #include "DGtal/io/colormaps/GradientColorMap.h"
56 
57 using namespace DGtal;
58 
59 int main(int argc, char ** argv)
60 {
61 
63  //Load a vol image and store it into a ImageContainerBySTLVector
64  //
65  // ...
66  //
67 
68 
70  //Visualization 2
71  //
72 
74  //Create a new viewer instance
75  QApplication application(argc,argv);
76  Viewer3D<> viewer;
77  viewer.show();
79 
80  // - iterate over the loaded image domain and send strictly positive
81  //values to the viewer
82  //
83  // Do not forget a viewer2 << DGtal::Viewer3D<>::updateDisplay;
84  // when you're done.
85 
86 
88  //Distance transformation
89 
90  //Create a Point Predicate from the input image and a thresholder
91  // (see SimpleThresholdForegroundPredicate)
92 
93  // ...
94 
95 
96  // Compute the distance map for the L2 metric
97 
98  // ...
99 
101 
102 
104  //Visualization 2
105  //
106 
107  // Create a new instance of Viewer3D
108 
110  //Create the colormap from the maximal distance value
111  //and a GradientColorMap
112  DT::Value maxDT = (*boost::first_max_element(distancemap.constRange().begin(),
113  distancemap.constRange().end()));
114  GradientColorMap<DT::Value> gradient( 0, maxDT);
115  gradient.addColor(DGtal::Color::Blue);
116  gradient.addColor(DGtal::Color::Green);
117  gradient.addColor(DGtal::Color::Yellow);
118  gradient.addColor(DGtal::Color::Red);
120 
121 
122 
124  //Granulometry
125 
126 
127  //Create an empty image with the same size as the input one
128 
129  //...
130 
131 
132  //Compute the granulometry function
133 
134  //...
135 
136 
137  //Export the granulometry map to a vol
139  VolWriter<Image, CastFunctor<unsigned char> >::exportVol("granulo.vol", imageGranulo);
141 
142 
143 
145  //Visualization 3
146  //
147  // Create a visualization of the granulometry function
148 
149  return 0;
150 }
static const Color Yellow
Definition: Color.h:398
static const Color Green
Definition: Color.h:393
static const Color Red
Definition: Color.h:392
static const Color Blue
Definition: Color.h:395
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Export a 3D Image using the Vol formats.
Definition: VolWriter.h:69
int main(int argc, char **argv)