DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
FMMErosion.cpp
Go to the documentation of this file.
1
16
29
31
#include <iostream>
32
#include "DGtal/base/Common.h"
33
34
#include "ConfigExamples.h"
35
36
//image
37
#include "DGtal/images/ImageContainerBySTLVector.h"
38
#include "DGtal/images/ImageContainerBySTLMap.h"
39
#include "DGtal/base/BasicFunctors.h"
40
#include "DGtal/kernel/BasicPointPredicates.h"
41
42
//IO
43
#include "DGtal/io/readers/VolReader.h"
44
#include "DGtal/io/writers/VolWriter.h"
45
46
//frontier
47
#include "DGtal/topology/SurfelAdjacency.h"
48
#include "DGtal/topology/helpers/FrontierPredicate.h"
49
#include "DGtal/topology/LightExplicitDigitalSurface.h"
50
51
// FMM
52
#include "DGtal/geometry/volumes/distance/FMM.h"
53
55
56
using namespace
std
;
57
using namespace
DGtal
;
58
using namespace
Z3i
;
59
61
62
64
int
main
(
int
argc,
char
** argv )
65
{
66
trace
.
beginBlock
(
"Example FMMErosion"
);
67
trace
.
info
() <<
"Args:"
;
68
for
(
int
i = 0; i < argc; ++i )
69
trace
.
info
() <<
" "
<< argv[ i ];
70
trace
.
info
() << endl;
71
72
DGtal::trace
.
beginBlock
(
"image reading..."
);
73
75
string
imageFileName = examplesPath +
"samples/cat10.vol"
;
76
trace
.
info
() << imageFileName <<std::endl;
77
typedef
ImageContainerBySTLVector<Domain, bool>
BinaryImage;
78
BinaryImage binaryImage =
VolReader<BinaryImage>::importVol
( imageFileName);
80
81
DGtal::trace
.
endBlock
();
82
83
DGtal::trace
.
beginBlock
(
"Search for a bel..."
);
84
85
//space and starting bel
87
KSpace
ks;
88
Domain
domain
= binaryImage.
domain
();
89
ks.
init
(
domain
.lowerBound(),
domain
.upperBound(),
true
);
90
KSpace::SCell
bel;
91
92
try
{
93
//getting a bel
94
bel =
Surfaces<KSpace>::findABel
( ks, binaryImage, (
unsigned
int
)
domain
.size() );
95
trace
.
info
() <<
"starting bel: "
<< bel << std::endl;
96
97
}
catch
(
DGtal::InputException
& i) {
98
trace
.
emphase
() <<
"starting bel not found"
<< std::endl;
99
return
0;
100
}
102
103
DGtal::trace
.
endBlock
();
104
105
DGtal::trace
.
beginBlock
(
"Implicit frontier..."
);
106
107
//implicit frontier
109
typedef
functors::FrontierPredicate<KSpace, BinaryImage>
SurfelPredicate;
110
typedef
LightExplicitDigitalSurface<KSpace, SurfelPredicate>
Frontier;
111
functors::SCellToIncidentPoints<KSpace>
toIncidentPoints( ks );
112
std::pair<Point,Point> bpair = toIncidentPoints( bel );
113
SurfelPredicate surfelPredicate( ks, binaryImage,
114
binaryImage( bpair.first ),
115
binaryImage( bpair.second ) );
116
Frontier frontier( ks, surfelPredicate,
117
SurfelAdjacency<KSpace::dimension>
(
true
), bel );
119
120
DGtal::trace
.
endBlock
();
121
122
const
double
maximalDistance = 3.0;
123
124
DGtal::trace
.
beginBlock
(
"FMM..."
);
125
127
typedef
ImageContainerBySTLMap<Domain,double>
DistanceImage;
128
typedef
DigitalSetFromMap<DistanceImage>
AcceptedPointSet;
129
typedef
FMM<DistanceImage, AcceptedPointSet, BinaryImage >
FMM
;
131
133
DistanceImage imageDistance(
domain
, 0.0 );
134
AcceptedPointSet pointSet( imageDistance );
135
functors::SCellToInnerPoint<KSpace>
toInnerPoint( ks );
136
for
(Frontier::SurfelConstIterator it = frontier.begin(), itEnd = frontier.end();
137
it != itEnd; ++it)
138
{
139
pointSet.insert( toInnerPoint(*it) );
140
imageDistance.setValue( toInnerPoint(*it), 0.5 );
141
}
143
145
FMM
fmm( imageDistance, pointSet, binaryImage,
146
domain
.size(), maximalDistance );
147
fmm.
compute
();
148
trace
.
info
() << fmm << std::endl;
150
151
DGtal::trace
.
endBlock
();
152
153
DGtal::trace
.
beginBlock
(
"Erosion"
);
154
trace
.
info
() <<
"Erosion of radius: "
<< maximalDistance << std::endl;
155
157
for
(AcceptedPointSet::ConstIterator it = pointSet.begin(), itEnd = pointSet.end();
158
it != itEnd; ++it)
159
{
160
binaryImage.setValue(*it, 0);
161
}
163
164
DGtal::trace
.
endBlock
();
165
166
DGtal::trace
.
beginBlock
(
"image writing..."
);
167
169
string
outputFileName =
"eroded.vol"
;
170
trace
.
info
() <<
"to "
<< outputFileName << std::endl;
171
VolWriter<BinaryImage,functors::Cast<unsigned char>
>::exportVol(outputFileName, binaryImage);
173
174
DGtal::trace
.
endBlock
();
175
176
177
trace
.
endBlock
();
178
return
0;
179
}
180
// //
DGtal::DigitalSetFromMap
Aim: An adapter for viewing an associative image container like ImageContainerBySTLMap as a simple di...
Definition
DigitalSetFromMap.h:75
DGtal::FMM
Aim: Fast Marching Method (FMM) for nd distance transforms.
Definition
FMM.h:151
DGtal::FMM::compute
void compute()
DGtal::ImageContainerBySTLMap
Definition
ImageContainerBySTLMap.h:98
DGtal::ImageContainerBySTLVector
Definition
ImageContainerBySTLVector.h:127
DGtal::InputException
Definition
Exceptions.h:64
DGtal::KhalimskySpaceND::init
bool init(const Point &lower, const Point &upper, bool isClosed)
Specifies the upper and lower bounds for the maximal cells in this space.
DGtal::KhalimskySpaceND< 3, Integer >::SCell
SignedKhalimskyCell< dim, Integer > SCell
Definition
KhalimskySpaceND.h:417
DGtal::LightExplicitDigitalSurface
Aim: A model of CDigitalSurfaceContainer which defines the digital surface as connected surfels....
Definition
LightExplicitDigitalSurface.h:119
DGtal::Surfaces::findABel
static SCell findABel(const KSpace &K, const PointPredicate &pp, unsigned int nbtries=1000)
DGtal::SurfelAdjacency
Aim: Represent adjacencies between surfel elements, telling if it follows an interior to exterior ord...
Definition
SurfelAdjacency.h:66
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::emphase
std::ostream & emphase()
DGtal::Trace::info
std::ostream & info()
DGtal::Trace::endBlock
double endBlock()
DGtal::Domain
DGtal::VoronoiMap::domain
const Domain & domain() const
Definition
VoronoiMap.h:265
DGtal::functors::FrontierPredicate
Aim: The predicate on surfels that represents the frontier between two regions in an image....
Definition
FrontierPredicate.h:68
DGtal::functors::SCellToIncidentPoints
Aim: transforms a signed cell c into a pair of points corresponding to the signed cells of greater di...
Definition
SCellsFunctors.h:386
DGtal::functors::SCellToInnerPoint
Aim: transforms a signed cell c into a point corresponding to the signed cell of greater dimension th...
Definition
SCellsFunctors.h:235
DGtal::Z3i
Z3i this namespace gathers the standard of types for 3D imagery.
DGtal::Z3i::KSpace
KhalimskySpaceND< 3, Integer > KSpace
Definition
StdDefs.h:146
DGtal
DGtal is the top-level namespace which contains all DGtal functions and types.
Definition
ClosedIntegerHalfPlane.h:49
DGtal::trace
Trace trace
std
STL namespace.
DGtal::VolReader::importVol
static ImageContainer importVol(const std::string &filename, const Functor &aFunctor=Functor())
DGtal::VolWriter
Aim: Export a 3D Image using the Vol formats.
Definition
VolWriter.h:69
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
domain
Domain domain
Definition
testProjection.cpp:88
examples
tutorial-examples
FMMErosion.cpp
Generated on
for DGtal by
1.18.0