DGtal  0.9.3
Functions
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.

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

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="")
Trace trace
Definition: Common.h:137
bool testL1LengthEstimator(std::string &filename)
double endBlock()
std::ostream & emphase()
std::ostream & info()

◆ testL1LengthEstimator()

bool testL1LengthEstimator ( std::string &  filename)

L1 test

Definition at line 64 of file testL1LengthEstimator.cpp.

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

Referenced by main().

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
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 
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
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 
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 
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 }
ConstIterator end() const
MyDigitalSurface::ConstIterator ConstIterator
Trace trace
Definition: Common.h:137
Quantity eval() const
Quantity eval() const
Aim: a simple model of CGlobalCurveEstimator that compute the length of a curve using the l_1 metric ...
PointsRange getPointsRange() const
Definition: GridCurve.h:426
Aim: a model of CGlobalCurveEstimator that computes the length of a digital curve using its MLP (give...
void init(const double h, const ConstIterator &itb, const ConstIterator &ite, const bool &isClosed)
void init(const double h, const ConstIterator &itb, const ConstIterator &ite)
void init(const double h, const ConstIterator &itb, const ConstIterator &ite)
Aim: a model of CGlobalCurveEstimator that computes the length of a digital curve using its FP (faith...
Aim: a model of CGlobalCurveEstimator that segments the digital curve into DSS and computes the lengt...
bool initFromVectorStream(std::istream &in)
bool isClosed() const
std::ostream & info()
Quantity eval() const
Quantity eval() const
void init(const double h, const ConstIterator &itb, const ConstIterator &ite, const bool &isClosed)
ConstIterator begin() const
Aim: a simple model of CGlobalCurveEstimator that compute the length of a curve using the l_1 metric ...
Aim: describes, in a cellular space of dimension n, a closed or open sequence of signed d-cells (or d...
Definition: GridCurve.h:172
ArrowsRange getArrowsRange() const
Definition: GridCurve.h:450