DGtal
2.2.0
Toggle main menu visibility
Loading...
Searching...
No Matches
testLambdaMST2D.cpp
Go to the documentation of this file.
1
16
29
31
#include <iostream>
32
#include <fstream>
33
#include <iterator>
34
#include <vector>
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/ArithmeticalDSSComputer.h"
40
#include "DGtal/geometry/curves/estimation/LambdaMST2D.h"
41
#include "DGtal/geometry/curves/SaturatedSegmentation.h"
42
44
45
using namespace
std
;
46
using namespace
DGtal
;
47
using namespace
Z2i
;
48
50
// Functions for testing class LambdaMST2D.
52
53
class
testLambdaMST2D
54
{
55
typedef
vector < Point >
Range
;
56
typedef
Range::const_iterator
ConstIterator
;
57
typedef
ArithmeticalDSSComputer < ConstIterator, int, 8 >
SegmentComputer
;
58
typedef
SaturatedSegmentation<SegmentComputer>
Segmentation
;
59
private
:
60
Range
curve
;
61
public
:
62
testLambdaMST2D
()
63
{
64
fstream inputStream;
65
inputStream.open ( (testPath +
"samples/sinus2D4.dat"
).c_str(), ios::in );
66
try
{
67
curve
=
PointListReader<Point>::getPointsFromInputStream
( inputStream );
68
if
(
curve
.size() == 0)
throw
IOException
();
69
}
catch
(
DGtal::IOException
& ioe) {
70
trace
.
error
() <<
"Size is null."
<< endl;
71
}
72
}
73
bool
lambda64ByPoint
()
74
{
75
Segmentation
segmenter (
curve
.begin(),
curve
.end(),
SegmentComputer
() );
76
LambdaMST2D < Segmentation > lmst64;
77
lmst64.
attach
( segmenter );
78
for
(
ConstIterator
it =
curve
.begin(); it !=
curve
.end(); ++it )
79
lmst64.
eval
( *it );
80
return
true
;
81
}
82
bool
lambda64
()
83
{
84
Segmentation
segmenter (
curve
.begin(),
curve
.end(),
SegmentComputer
() );
85
LambdaMST2D < Segmentation > lmst64;
86
lmst64.
attach
( segmenter );
87
lmst64.
init
(
curve
.begin(),
curve
.end() );
88
std::vector < RealVector > tangent;
89
lmst64.
eval
< back_insert_iterator< vector < RealVector > > > (
curve
.begin(),
curve
.end(), back_inserter ( tangent ) );
90
return
true
;
91
}
92
};
93
94
96
// Standard services - public :
97
98
int
main
(
int
,
char
** )
99
{
100
bool
res =
true
;
101
testLambdaMST2D
testLMST;
102
trace
.
beginBlock
(
"Testing LambdaMST2D"
);
103
trace
.
beginBlock
(
"Testing point only calculation"
);
104
res &= testLMST.
lambda64ByPoint
();
105
trace
.
endBlock
();
106
trace
.
beginBlock
(
"Testing calculation for whole curve"
);
107
res &= testLMST.
lambda64
();
108
trace
.
endBlock
();
109
trace
.
emphase
() << ( res ?
"Passed."
:
"Error."
) << endl;
110
trace
.
endBlock
();
111
return
res ? 0 : 1;
112
}
113
// //
DGtal::IOException
Definition
Exceptions.h:53
DGtal::LambdaMST2DEstimator::eval
RealVector eval(const Point &p)
DGtal::LambdaMST2DEstimator::init
void init(ConstIterator itb, ConstIterator ite)
DGtal::LambdaMST2DEstimator::attach
void attach(Alias< TSegmentation > SegmentComputer)
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()
testLambdaMST2D
Definition
testLambdaMST2D.cpp:54
testLambdaMST2D::ConstIterator
Range::const_iterator ConstIterator
Definition
testLambdaMST2D.cpp:56
testLambdaMST2D::lambda64ByPoint
bool lambda64ByPoint()
Definition
testLambdaMST2D.cpp:73
testLambdaMST2D::Range
vector< Point > Range
Definition
testLambdaMST2D.cpp:55
testLambdaMST2D::lambda64
bool lambda64()
Definition
testLambdaMST2D.cpp:82
testLambdaMST2D::Segmentation
SaturatedSegmentation< SegmentComputer > Segmentation
Definition
testLambdaMST2D.cpp:58
testLambdaMST2D::testLambdaMST2D
testLambdaMST2D()
Definition
testLambdaMST2D.cpp:62
testLambdaMST2D::curve
Range curve
Definition
testLambdaMST2D.cpp:60
testLambdaMST2D::SegmentComputer
ArithmeticalDSSComputer< ConstIterator, int, 8 > SegmentComputer
Definition
testLambdaMST2D.cpp:57
DGtal::Z2i
Z2i this namespace gathers the standard of types for 2D imagery.
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
testLambdaMST2D.cpp
Generated on
for DGtal by
1.18.0