DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testLambdaMST3D.cpp
Go to the documentation of this file.
1
16
29
31
#include <iostream>
32
#include <fstream>
33
#include <vector>
34
#include <iterator>
35
#include "DGtal/base/Common.h"
36
#include "ConfigTest.h"
37
#include "DGtal/helpers/StdDefs.h"
38
#include "DGtal/io/readers/PointListReader.h"
39
#include "DGtal/geometry/curves/Naive3DDSSComputer.h"
40
#include "DGtal/geometry/curves/estimation/LambdaMST3D.h"
41
#include "DGtal/geometry/curves/estimation/FunctorsLambdaMST.h"
42
#include "DGtal/geometry/curves/SaturatedSegmentation.h"
43
45
46
using namespace
std
;
47
using namespace
DGtal
;
48
using namespace
Z3i
;
49
using namespace
functors
;
50
52
// Functions for testing class LambdaMST3D.
54
55
class
testLambdaMST3D
56
{
57
typedef
DGtal::Z3i::Point
Point
;
58
typedef
DGtal::Z2i::Point
Point2D
;
59
typedef
std::vector < Point >
Range
;
60
typedef
std::list < Point2D >
Range2D
;
61
typedef
Range::const_iterator
ConstIterator
;
62
typedef
Range2D::const_iterator
ConstIterator2D
;
63
typedef
Naive3DDSSComputer < ConstIterator, int, 8 >
SegmentComputer
;
64
typedef
SaturatedSegmentation<SegmentComputer>
Segmentation
;
65
typedef
ArithmeticalDSSComputer < ConstIterator2D, int, 8 >
SegmentComputer2D
;
66
typedef
SaturatedSegmentation<SegmentComputer2D>
Segmentation2D
;
67
private
:
68
Range
curve
;
69
public
:
70
testLambdaMST3D
()
71
{
72
fstream inputStream;
73
inputStream.open ( (testPath +
"samples/sinus3D.dat"
).c_str(), std::ios::in );
74
try
{
75
curve
=
PointListReader<Point>::getPointsFromInputStream
( inputStream );
76
if
(
curve
.size() == 0)
throw
IOException
();
77
}
catch
(
DGtal::IOException
& ioe) {
78
trace
.
error
() <<
"Size is null."
<< endl;
79
}
80
}
81
bool
lambda64ByPoint
()
82
{
83
Segmentation
segmenter (
curve
.begin(),
curve
.end(),
SegmentComputer
() );
84
LambdaMST3D < Segmentation > lmst64;
85
lmst64.
attach
( segmenter );
86
lmst64.
init
(
curve
.begin(),
curve
.end() );
87
for
(
ConstIterator
it =
curve
.begin(); it !=
curve
.end(); ++it )
88
lmst64.
eval
( *it );
89
return
true
;
90
}
91
bool
lambda64
()
92
{
93
Segmentation
segmenter (
curve
.begin(),
curve
.end(),
SegmentComputer
() );
94
LambdaMST3D < Segmentation > lmst64;
95
lmst64.
attach
( segmenter );
96
lmst64.
init
(
curve
.begin(),
curve
.end() );
97
vector < RealVector > tangent;
98
lmst64.
eval
< back_insert_iterator< vector < RealVector > > > (
curve
.begin(),
curve
.end(), back_insert_iterator< vector < RealVector > > ( tangent ) );
99
return
true
;
100
}
101
102
bool
lambda64Filtered
()
103
{
104
Segmentation
segmenter (
curve
.begin(),
curve
.end(),
SegmentComputer
() );
105
LambdaMST3D < Segmentation, Lambda64Function, DSSLengthLessEqualFilter < SegmentComputer > > lmst64;
106
lmst64.
attach
( segmenter );
107
lmst64.
getDSSFilter
( ).init ( 1 );
108
lmst64.
init
(
curve
.begin(),
curve
.end() );
109
for
(
ConstIterator
it =
curve
.begin(); it !=
curve
.end(); ++it )
110
lmst64.
eval
( *it );
111
return
true
;
112
}
113
114
bool
lambdaSinByPoint
()
115
{
116
Segmentation
segmenter (
curve
.begin(),
curve
.end(),
SegmentComputer
() );
117
LambdaMST3D < Segmentation, LambdaSinFromPiFunction > lmst;
118
lmst.
attach
( segmenter );
119
lmst.
init
(
curve
.begin(),
curve
.end() );
120
for
(
ConstIterator
it =
curve
.begin(); it !=
curve
.end(); ++it )
121
lmst.
eval
( *it );
122
return
true
;
123
}
124
125
bool
lambdaSin
()
126
{
127
Segmentation
segmenter (
curve
.begin(),
curve
.end(),
SegmentComputer
() );
128
LambdaMST3D < Segmentation, LambdaSinFromPiFunction > lmst;
129
lmst.
attach
( segmenter );
130
lmst.
init
(
curve
.begin(),
curve
.end() );
131
vector < RealVector > tangent;
132
lmst.
eval
< back_insert_iterator< vector < RealVector > > > (
curve
.begin(),
curve
.end(), back_insert_iterator< vector < RealVector > > ( tangent ) );
133
return
true
;
134
}
135
136
bool
lambdaExpByPoint
()
137
{
138
Segmentation
segmenter (
curve
.begin(),
curve
.end(),
SegmentComputer
() );
139
LambdaMST3D < Segmentation, LambdaExponentialFunction > lmst;
140
lmst.
attach
( segmenter );
141
lmst.
init
(
curve
.begin(),
curve
.end() );
142
for
(
ConstIterator
it =
curve
.begin(); it !=
curve
.end(); ++it )
143
lmst.
eval
( *it );
144
return
true
;
145
}
146
147
bool
lambdaExp
()
148
{
149
Segmentation
segmenter (
curve
.begin(),
curve
.end(),
SegmentComputer
() );
150
LambdaMST3D < Segmentation, LambdaExponentialFunction > lmst;
151
lmst.
attach
( segmenter );
152
lmst.
init
(
curve
.begin(),
curve
.end() );
153
vector < RealVector > tangent;
154
lmst.
eval
< back_insert_iterator< vector < RealVector > > > (
curve
.begin(),
curve
.end(), back_insert_iterator< vector < RealVector > > ( tangent ) );
155
return
true
;
156
}
157
};
158
159
161
// Standard services - public :
162
163
int
main
(
int
,
char
** )
164
{
165
bool
res =
true
;
166
testLambdaMST3D
testLMST;
167
trace
.
beginBlock
(
"Testing LambdaMST3D"
);
168
trace
.
beginBlock
(
"Testing point only calculation"
);
169
res &= testLMST.
lambda64ByPoint
();
170
res &= testLMST.
lambda64Filtered
();
171
res &= testLMST.
lambdaSinByPoint
();
172
res &= testLMST.
lambdaExpByPoint
();
173
trace
.
endBlock
();
174
trace
.
beginBlock
(
"Testing calculation for whole curve"
);
175
res &= testLMST.
lambda64
();
176
res &= testLMST.
lambdaSin
();
177
res &= testLMST.
lambdaExp
();
178
trace
.
endBlock
();
179
trace
.
endBlock
();
180
trace
.
emphase
() << ( res ?
"Passed."
:
"Error."
) << endl;
181
return
res ? 0 : 1;
182
}
183
// //
DGtal::IOException
Definition
Exceptions.h:53
DGtal::LambdaMST3DEstimator::attach
void attach(Alias< TSegmentation > segmentComputer)
DGtal::LambdaMST3DEstimator::eval
RealVector eval(const Point &p)
DGtal::LambdaMST3DEstimator::init
void init(ConstIterator itb, ConstIterator ite)
DGtal::LambdaMST3DEstimator::getDSSFilter
DSSFilter & getDSSFilter()
DGtal::SaturatedSegmentation
Aim: Computes the saturated segmentation, that is the whole set of maximal segments within a range gi...
Definition
SaturatedSegmentation.h:154
DGtal::Trace::beginBlock
void beginBlock(const std::string &keyword="")
DGtal::Trace::emphase
std::ostream & emphase()
DGtal::Trace::error
std::ostream & error()
DGtal::Trace::endBlock
double endBlock()
testLambdaMST3D
Definition
testLambdaMST3D.cpp:56
testLambdaMST3D::testLambdaMST3D
testLambdaMST3D()
Definition
testLambdaMST3D.cpp:70
testLambdaMST3D::lambda64Filtered
bool lambda64Filtered()
Definition
testLambdaMST3D.cpp:102
testLambdaMST3D::Point
DGtal::Z3i::Point Point
Definition
testLambdaMST3D.cpp:57
testLambdaMST3D::Point2D
DGtal::Z2i::Point Point2D
Definition
testLambdaMST3D.cpp:58
testLambdaMST3D::lambdaSinByPoint
bool lambdaSinByPoint()
Definition
testLambdaMST3D.cpp:114
testLambdaMST3D::ConstIterator2D
Range2D::const_iterator ConstIterator2D
Definition
testLambdaMST3D.cpp:62
testLambdaMST3D::Segmentation
SaturatedSegmentation< SegmentComputer > Segmentation
Definition
testLambdaMST3D.cpp:64
testLambdaMST3D::ConstIterator
Range::const_iterator ConstIterator
Definition
testLambdaMST3D.cpp:61
testLambdaMST3D::SegmentComputer
Naive3DDSSComputer< ConstIterator, int, 8 > SegmentComputer
Definition
testLambdaMST3D.cpp:63
testLambdaMST3D::Range2D
std::list< Point2D > Range2D
Definition
testLambdaMST3D.cpp:60
testLambdaMST3D::lambda64
bool lambda64()
Definition
testLambdaMST3D.cpp:91
testLambdaMST3D::lambdaExp
bool lambdaExp()
Definition
testLambdaMST3D.cpp:147
testLambdaMST3D::Segmentation2D
SaturatedSegmentation< SegmentComputer2D > Segmentation2D
Definition
testLambdaMST3D.cpp:66
testLambdaMST3D::curve
Range curve
Definition
testLambdaMST3D.cpp:68
testLambdaMST3D::SegmentComputer2D
ArithmeticalDSSComputer< ConstIterator2D, int, 8 > SegmentComputer2D
Definition
testLambdaMST3D.cpp:65
testLambdaMST3D::Range
std::vector< Point > Range
Definition
testLambdaMST3D.cpp:59
testLambdaMST3D::lambda64ByPoint
bool lambda64ByPoint()
Definition
testLambdaMST3D.cpp:81
testLambdaMST3D::lambdaExpByPoint
bool lambdaExpByPoint()
Definition
testLambdaMST3D.cpp:136
testLambdaMST3D::lambdaSin
bool lambdaSin()
Definition
testLambdaMST3D.cpp:125
DGtal::Z2i::Point
Space::Point Point
Definition
StdDefs.h:95
DGtal::Z3i
Z3i this namespace gathers the standard of types for 3D imagery.
DGtal::Z3i::Point
Space::Point Point
Definition
StdDefs.h:168
DGtal::functors
functors namespace gathers all DGtal functors.
Definition
BasicBoolFunctors.h:49
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::PointListReader::getPointsFromInputStream
static std::vector< TPoint > getPointsFromInputStream(std::istream &in, std::vector< unsigned int > aVectPosition=std::vector< unsigned int >())
main
int main(int, char **)
Definition
testIntegerComputer.cpp:331
tests
geometry
curves
estimation
testLambdaMST3D.cpp
Generated on
for DGtal by
1.18.0