DGtal
2.1.0
Loading...
Searching...
No Matches
volDTGranulo-template.cpp
Go to the documentation of this file.
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/PolyscopeViewer.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
PolyscopeViewer<>
viewer;
77
78
// - iterate over the loaded image domain and send strictly positive
79
// values to the viewer
80
//
81
// If needed, to not forget to a viewer.allowReuseList to group values togethe
82
// Do not forget a viewer.show(); when you're done.
83
84
86
//Distance transformation
87
88
//Create a Point Predicate from the input image and a thresholder
89
// (see SimpleThresholdForegroundPredicate)
90
91
// ...
92
93
94
// Compute the distance map for the L2 metric
95
96
// ...
97
99
100
102
//Visualization 2
103
//
104
105
// Create a new instance of PolyscopeViewer
106
108
//Create the colormap from the maximal distance value
109
//and a GradientColorMap
110
DT::Value maxDT = (*boost::first_max_element(distancemap.constRange().begin(),
111
distancemap.constRange().end()));
112
GradientColorMap<DT::Value>
gradient( 0, maxDT);
113
gradient.
addColor
(
DGtal::Color::Blue
);
114
gradient.
addColor
(
DGtal::Color::Green
);
115
gradient.
addColor
(
DGtal::Color::Yellow
);
116
gradient.
addColor
(
DGtal::Color::Red
);
118
119
120
122
//Granulometry
123
124
125
//Create an empty image with the same size as the input one
126
127
//...
128
129
130
//Compute the granulometry function
131
132
//...
133
134
135
//Export the granulometry map to a vol
137
VolWriter<Image, CastFunctor<unsigned char>
>::exportVol(
"granulo.vol"
, imageGranulo);
139
140
141
143
//Visualization 3
144
//
145
// Create a visualization of the granulometry function
146
147
return
0;
148
}
DGtal::Color::Red
static const Color Red
Definition
Color.h:425
DGtal::Color::Blue
static const Color Blue
Definition
Color.h:428
DGtal::Color::Yellow
static const Color Yellow
Definition
Color.h:431
DGtal::Color::Green
static const Color Green
Definition
Color.h:426
DGtal::GradientColorMap
Aim: This class template may be used to (linearly) convert scalar values in a given range into a colo...
Definition
GradientColorMap.h:120
DGtal::GradientColorMap::addColor
void addColor(const Color &color)
DGtal::PolyscopeViewer
Definition
PolyscopeViewer.h:52
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::VolWriter
Aim: Export a 3D Image using the Vol formats.
Definition
VolWriter.h:69
main
int main()
Definition
testBits.cpp:56
examples
tutorial-examples
volDTGranulo-template.cpp
Generated on Tue Aug 26 2025 14:27:43 for DGtal by
1.9.8