DGtal  0.9.4.1
volDTGranulo-template.cpp
1 
31 #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/imagesSetsUtils/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 <QtGui/qapplication.h>
54 #include "DGtal/io/viewers/Viewer3D.h"
55 #include "DGtal/io/colormaps/GradientColorMap.h"
57 
58 using namespace DGtal;
59 
60 int main(int argc, char ** argv)
61 {
62 
64  //Load a vol image and store it into a ImageContainerBySTLVector
65  //
66  // ...
67  //
68 
69 
71  //Visualization 2
72  //
73 
75  //Create a new viewer instance
76  QApplication application(argc,argv);
77  Viewer3D<> viewer;
78  viewer.show();
80 
81  // - iterate over the loaded image domain and send strictly positive
82  //values to the viewer
83  //
84  // Do not forget a viewer2 << DGtal::Viewer3D<>::updateDisplay;
85  // when you're done.
86 
87 
89  //Distance transformation
90 
91  //Create a Point Predicate from the input image and a thresholder
92  // (see SimpleThresholdForegroundPredicate)
93 
94  // ...
95 
96 
97  // Compute the distance map for the L2 metric
98 
99  // ...
100 
102 
103 
105  //Visualization 2
106  //
107 
108  // Create a new instance of Viewer3D
109 
111  //Create the colormap from the maximal distance value
112  //and a GradientColorMap
113  DT::Value maxDT = (*std::max_element(distancemap.constRange().begin(),
114  distancemap.constRange().end()));
115  GradientColorMap<DT::Value> gradient( 0, maxDT);
116  gradient.addColor(DGtal::Color::Blue);
117  gradient.addColor(DGtal::Color::Green);
118  gradient.addColor(DGtal::Color::Yellow);
119  gradient.addColor(DGtal::Color::Red);
121 
122 
123 
125  //Granulometry
126 
127 
128  //Create an empty image with the same size as the input one
129 
130  //...
131 
132 
133  //Compute the granulometry function
134 
135  //...
136 
137 
138  //Export the granulometry map to a vol
140  VolWriter<Image, CastFunctor<unsigned char> >::exportVol("granulo.vol", imageGranulo);
142 
143 
144 
146  //Visualization 3
147  //
148  // Create a visualization of the granulometry function
149 
150  return 0;
151 }
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Aim: Export a 3D Image using the Vol formats.
Definition: VolWriter.h:68
static const Color Yellow
Definition: Color.h:397
static const Color Blue
Definition: Color.h:394
int main(int argc, char **argv)
DGtal is the top-level namespace which contains all DGtal functions and types.
virtual void show()
Overload QWidget method in order to add a call to updateList() method (to ensure that the lists are w...
static const Color Red
Definition: Color.h:391
static const Color Green
Definition: Color.h:392