DGtal 2.1.0
Loading...
Searching...
No Matches
volDTGranulo-template.cpp File Reference

An example of generating a grid curve from a parametric shape and estimating its length. More...

#include <iostream>
#include <fstream>
#include <algorithm>
#include "DGtal/base/Common.h"
#include "DGtal/helpers/StdDefs.h"
#include "DGtal/images/ImageContainerBySTLVector.h"
#include "DGtal/io/readers/VolReader.h"
#include "DGtal/io/writers/VolWriter.h"
#include "DGtal/images/SimpleThresholdForegroundPredicate.h"
#include "DGtal/geometry/volumes/distance/DistanceTransformation.h"
#include "DGtal/shapes/implicit/ImplicitBall.h"
#include "DGtal/base/BasicFunctors.h"
#include "DGtal/io/viewers/PolyscopeViewer.h"
#include "DGtal/io/colormaps/GradientColorMap.h"
Include dependency graph for volDTGranulo-template.cpp:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

An example of generating a grid curve from a parametric shape and estimating its length.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Author
Tristan Roussillon (trist.nosp@m.an.r.nosp@m.oussi.nosp@m.llon.nosp@m.@liri.nosp@m.s.cn.nosp@m.rs.fr)
Date
2010/10/17

This file is part of the DGtal library.

Definition in file volDTGranulo-template.cpp.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

[volGranulo-viewer]

[volGranulo-viewer]

[volGranulo-cmap]

[volGranulo-cmap]

[volGranulo-export]

[volGranulo-export]

Definition at line 59 of file volDTGranulo-template.cpp.

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}
static const Color Red
Definition Color.h:425
static const Color Blue
Definition Color.h:428
static const Color Yellow
Definition Color.h:431
static const Color Green
Definition Color.h:426
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:69

References DGtal::GradientColorMap< PValue, PDefaultPreset, PDefaultFirstColor, PDefaultLastColor >::addColor(), DGtal::Color::Blue, DGtal::Color::Green, DGtal::Color::Red, and DGtal::Color::Yellow.