DGtal 1.4.0
Loading...
Searching...
No Matches
testL1LengthEstimator.cpp File Reference
#include <iostream>
#include "DGtal/base/Common.h"
#include "DGtal/kernel/SpaceND.h"
#include "DGtal/kernel/domains/HyperRectDomain.h"
#include "DGtal/kernel/sets/DigitalSetSelector.h"
#include "DGtal/topology/KhalimskySpaceND.h"
#include "DGtal/topology/SurfelAdjacency.h"
#include "DGtal/topology/SurfelNeighborhood.h"
#include "DGtal/geometry/curves/GridCurve.h"
#include "DGtal/geometry/2d/L1LengthEstimator.h"
#include "DGtal/geometry/2d/TwoStepLocalLengthEstimator.h"
#include "DGtal/geometry/2d/MLPLengthEstimator.h"
#include "DGtal/geometry/2d/FPLengthEstimator.h"
#include "DGtal/geometry/2d/DSSLengthEstimator.h"
#include "ConfigTest.h"
Include dependency graph for testL1LengthEstimator.cpp:

Go to the source code of this file.

Functions

bool testL1LengthEstimator (std::string &filename)
 
int main (int argc, char **argv)
 

Detailed Description

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
David Coeurjolly (david.nosp@m..coe.nosp@m.urjol.nosp@m.ly@l.nosp@m.iris..nosp@m.cnrs.nosp@m..fr ) Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
Date
2011/06/27

Functions for testing class L1LengthEstimator.

This file is part of the DGtal library.

Definition in file testL1LengthEstimator.cpp.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 129 of file testL1LengthEstimator.cpp.

130{
131 trace.beginBlock ( "Testing class LengthEstimators" );
132 trace.info() << "Args:";
133 for ( int i = 0; i < argc; ++i )
134 trace.info() << " " << argv[ i ];
135 trace.info() << endl;
136
137 std::string sinus2D4 = testPath + "samples/sinus2D4.dat";
138
139
140
141 bool res = testL1LengthEstimator(sinus2D4); // && ... other tests
142 trace.emphase() << ( res ? "Passed." : "Error." ) << endl;
143 trace.endBlock();
144 return res ? 0 : 1;
145}
void beginBlock(const std::string &keyword="")
std::ostream & emphase()
std::ostream & info()
double endBlock()
Trace trace
Definition Common.h:153
bool testL1LengthEstimator(std::string &filename)

References DGtal::Trace::beginBlock(), DGtal::Trace::emphase(), DGtal::Trace::endBlock(), DGtal::Trace::info(), testL1LengthEstimator(), and DGtal::trace.

◆ testL1LengthEstimator()

bool testL1LengthEstimator ( std::string & filename)

L1 test

Definition at line 64 of file testL1LengthEstimator.cpp.

65{
66
67 trace.info() << "Reading GridCurve " << endl;
68
69 ifstream instream; // input stream
70 instream.open (filename.c_str(), ifstream::in);
71
72 GridCurve<KhalimskySpaceND<2> > c; //grid curve
73 c.initFromVectorStream(instream);
74
76 GridCurve<KhalimskySpaceND<2> >::ArrowsRange ra = c.getArrowsRange(); //range
77 L1LengthEstimator< GridCurve<KhalimskySpaceND<2> >::ArrowsRange::ConstIterator > l1length;
78 TwoStepLocalLengthEstimator< GridCurve<KhalimskySpaceND<2> >::ArrowsRange::ConstIterator > locallength(1.0,sqrt(2.0));
79
80 l1length.init(1, ra.begin(), ra.end(), c.isClosed());
81 trace.info() << "L1 length (h=1) = "<< l1length.eval()<<std::endl;
82
83 l1length.init(10, ra.begin(), ra.end(), c.isClosed());
84 trace.info() << "L1 length (h=10) = "<< l1length.eval()<<std::endl;
85
87 TwoStepLocalLengthEstimator< GridCurve<KhalimskySpaceND<2> >::ArrowsRange::ConstIterator > locallength(1.0,sqrt(2.0));
88
89 localength.init(1, ra.begin(), ra.end(), c.isClosed());
90 trace.info() << "Local length (h=1) = "<< localength.eval()<<std::endl;
91
92
94 GridCurve<KhalimskySpaceND<2> >::PointsRange rp = c.getPointsRange(); //range
95 MLPLengthEstimator< GridCurve<KhalimskySpaceND<2> >::PointsRange::ConstIterator > MLPlength;
96
97 MLPlength.init(1, rp.begin(), rp.end(), c.isClosed());
98 trace.info() << "MLP Length (h=1) = "<< MLPlength.eval()<<std::endl;
99
100 MLPlength.init(10, rp.begin(), rp.end(), c.isClosed());
101 trace.info() << "MLP Length (h=10) = "<< MLPlength.eval()<<std::endl;
102
104 FPLengthEstimator< GridCurve<KhalimskySpaceND<2> >::PointsRange::ConstIterator > FPlength;
105
106 FPlength.init(1, rp.begin(), rp.end(), c.isClosed());
107 trace.info() << "FP Length (h=1) = "<< FPlength.eval()<<std::endl;
108
109 FPlength.init(10, rp.begin(), rp.end(), c.isClosed());
110 trace.info() << "FP Length (h=10) = "<< FPlength.eval()<<std::endl;
111
113 DSSLengthEstimator< GridCurve<KhalimskySpaceND<2> >::PointsRange::ConstIterator > DSSlength;
114
115 DSSlength.init(1, rp.begin(), rp.end(), c.isClosed());
116 trace.info() << "DSS Length (h=1) = "<< DSSlength.eval()<<std::endl;
117
118 DSSlength.init(10, rp.begin(), rp.end(), c.isClosed());
119 trace.info() << "DSS Length (h=10) = "<< DSSlength.eval()<<std::endl;
120
121 return true;
122}
Aim: a model of CGlobalCurveEstimator that segments the digital curve into DSS and computes the lengt...
Quantity eval(const ConstIterator &itb, const ConstIterator &ite, const double h=1.) const
Aim: a model of CGlobalCurveEstimator that computes the length of a digital curve using its FP (faith...
Quantity eval(const ConstIterator &itb, const ConstIterator &ite, const double h=1.) const
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
Definition GridCurve.h:173
ConstIterator begin() const
bool initFromVectorStream(std::istream &in)
PointsRange getPointsRange() const
Definition GridCurve.h:426
ArrowsRange getArrowsRange() const
Definition GridCurve.h:450
ConstIterator end() const
Aim: a simple model of CGlobalCurveEstimator that compute the length of a curve using the l_1 metric ...
Quantity eval(const ConstIterator &itb, const ConstIterator &ite, const double h) const
Aim: a model of CGlobalCurveEstimator that computes the length of a digital curve using its MLP (give...
Quantity eval(const ConstIterator &itb, const ConstIterator &ite, const double h=1.) const
Aim: a simple model of CGlobalCurveEstimator that compute the length of a curve using the l_1 metric ...

References DGtal::GridCurve< TKSpace >::begin(), DGtal::GridCurve< TKSpace >::end(), DGtal::DSSLengthEstimator< TConstIterator >::eval(), DGtal::FPLengthEstimator< TConstIterator >::eval(), DGtal::L1LengthEstimator< TConstIterator >::eval(), DGtal::MLPLengthEstimator< TConstIterator >::eval(), DGtal::GridCurve< TKSpace >::getArrowsRange(), DGtal::GridCurve< TKSpace >::getPointsRange(), DGtal::Trace::info(), DGtal::GridCurve< TKSpace >::initFromVectorStream(), and DGtal::trace.

Referenced by main().