DGtal  0.9.4beta
Public Types | Public Member Functions | Data Fields
DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor > Class Template Reference

#include <DGtal/geometry/curves/estimation/SegmentComputerEstimators.h>

Inheritance diagram for DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >:
[legend]
Collaboration diagram for DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >:
[legend]

Public Types

typedef DSSComputer SegmentComputer
 
typedef DSSComputer::ConstIterator ConstIterator
 
typedef double Quantity
 

Public Member Functions

 BOOST_CONCEPT_ASSERT ((concepts::CUnaryFunctor< Functor, SegmentComputer, Quantity >))
 
 CurvatureFromDSSBaseEstimator ()
 
 CurvatureFromDSSBaseEstimator (const CurvatureFromDSSBaseEstimator &other)
 
CurvatureFromDSSBaseEstimatoroperator= (const CurvatureFromDSSBaseEstimator &other)
 
 ~CurvatureFromDSSBaseEstimator ()
 
bool isValid () const
 
void init (const double h, const ConstIterator &itb, const ConstIterator &ite)
 
Quantity eval (const ConstIterator &)
 
template<typename OutputIterator >
OutputIterator eval (const ConstIterator &itb, const ConstIterator &ite, OutputIterator result)
 
void attach (const SegmentComputer &aSC)
 

Data Fields

double myH
 
ConstIterator myBegin
 
ConstIterator myEnd
 
const SegmentComputermySCPtr
 
Functor myFunctor
 

Detailed Description

template<typename DSSComputer, typename Functor = detail::CurvatureFromDSSLength>
class DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >

Description of class 'CurvatureFromDSSBaseEstimator'

Aim: computes a curvature quantity from the length and/or the width of a DSS.

Template Parameters
DSSComputera model of segment computer devoted to the DSS recognition.

The computation is delegated to a functor.

Template Parameters
Functora model of unary functor taking a DSS as input and returning a double

This class is a model of CSegmentComputerEstimator

Definition at line 1301 of file SegmentComputerEstimators.h.

Member Typedef Documentation

template<typename DSSComputer, typename Functor = detail::CurvatureFromDSSLength>
typedef DSSComputer::ConstIterator DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::ConstIterator

Definition at line 1308 of file SegmentComputerEstimators.h.

template<typename DSSComputer, typename Functor = detail::CurvatureFromDSSLength>
typedef double DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::Quantity

Definition at line 1309 of file SegmentComputerEstimators.h.

template<typename DSSComputer, typename Functor = detail::CurvatureFromDSSLength>
typedef DSSComputer DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::SegmentComputer

Definition at line 1307 of file SegmentComputerEstimators.h.

Constructor & Destructor Documentation

template<typename DSSComputer, typename Functor = detail::CurvatureFromDSSLength>
DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::CurvatureFromDSSBaseEstimator ( )
inline
template<typename DSSComputer, typename Functor = detail::CurvatureFromDSSLength>
DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::CurvatureFromDSSBaseEstimator ( const CurvatureFromDSSBaseEstimator< DSSComputer, Functor > &  other)
inline

Copy constructor.

Parameters
otherthe object to copy.

Definition at line 1351 of file SegmentComputerEstimators.h.

template<typename DSSComputer, typename Functor = detail::CurvatureFromDSSLength>
DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::~CurvatureFromDSSBaseEstimator ( )
inline

Destructor

Definition at line 1375 of file SegmentComputerEstimators.h.

1375 {}

Member Function Documentation

template<typename DSSComputer, typename Functor = detail::CurvatureFromDSSLength>
void DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::attach ( const SegmentComputer aSC)
inline

Attach the estimator to aSC

Parameters
aSCan instance of segment computer.

Definition at line 1516 of file SegmentComputerEstimators.h.

1517  {
1518  mySCPtr = &aSC;
1519  ASSERT( mySCPtr );
1520  };
template<typename DSSComputer, typename Functor = detail::CurvatureFromDSSLength>
DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::BOOST_CONCEPT_ASSERT ( (concepts::CUnaryFunctor< Functor, SegmentComputer, Quantity >)  )
template<typename DSSComputer, typename Functor = detail::CurvatureFromDSSLength>
Quantity DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::eval ( const ConstIterator )
inline

Unique estimation

Returns
the estimated quantity

Definition at line 1407 of file SegmentComputerEstimators.h.

Referenced by DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, detail::CurvatureFromDSSLength >::eval().

1408  {
1409  ASSERT( isValid() );
1410 
1411  //types
1412  typedef typename DSSComputer::Integer Integer;
1413  typedef typename DSSComputer::Vector Vector;
1414 
1415  //curvature value
1416  Quantity k = 0;
1417 
1418 
1419  //begin and end iterators
1420  //(back point on the first point)
1421  //(front point on the last point)
1422  ConstIterator back = mySCPtr->begin();
1423  ConstIterator front = mySCPtr->end();
1424  bool isConnectedAtBack = isNotEmpty(myBegin, back)
1425  &&((*boost::prior(back)-*back).norm(Vector::L_1) <= NumberTraits<Integer>::ONE);
1426  bool isConnectedAtFront = isNotEmpty(front, myEnd)
1427  &&((*boost::prior(front)-*front).norm(Vector::L_1) <= NumberTraits<Integer>::ONE);
1428 
1429 
1430  if (isConnectedAtBack) {
1431  if (isConnectedAtFront) {
1432 
1433  --back;
1434 
1435  //parameters
1436  Integer mu = mySCPtr->mu();
1437  Integer omega = mySCPtr->omega();
1438 
1439  //cases
1440  if ( (mySCPtr->remainder(*back)<=mu-1)&&
1441  (mySCPtr->remainder(*front)<=mu-1) ) { //convex
1442  k = myFunctor(*mySCPtr) / myH;
1443  } else if ( (mySCPtr->remainder(*back)>=mu+omega)&&
1444  (mySCPtr->remainder(*front)>=mu+omega) ) { //concave
1445  k = -myFunctor(*mySCPtr) / myH;
1446  } //else //inflection
1447 
1448  } else {
1449 
1450  --back;
1451 
1452  //parameters
1453  Integer mu = mySCPtr->mu();
1454  Integer omega = mySCPtr->omega();
1455 
1456  //cases
1457  if ( (mySCPtr->remainder(*back)<=mu-1) ) { //convex
1458  k = myFunctor(*mySCPtr) / myH;
1459  } else if ( (mySCPtr->remainder(*back)>=mu+omega) ) { //concave
1460  k = -myFunctor(*mySCPtr) / myH;
1461  } //else //inflection
1462 
1463  }
1464  } else if (isConnectedAtFront) {
1465 
1466  //parameters
1467  Integer mu = mySCPtr->mu();
1468  Integer omega = mySCPtr->omega();
1469 
1470  //cases
1471  if ( (mySCPtr->remainder(*front)<=mu-1) ) { //convex
1472  k = myFunctor(*mySCPtr) / myH;
1473  } else if ( (mySCPtr->remainder(*front)>=mu+omega) ) { //concave
1474  k = -myFunctor(*mySCPtr) / myH;
1475  } //else //inflection
1476 
1477  } //else cannot be extended: k is set to 0
1478 
1479  return k;
1480 
1481  }
DGtal::int32_t Integer
Definition: StdDefs.h:74
bool isNotEmpty(const IC &itb, const IC &ite, IteratorType)
static const Integer ONE
Definition: NumberTraits.h:102
template<typename DSSComputer, typename Functor = detail::CurvatureFromDSSLength>
template<typename OutputIterator >
OutputIterator DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::eval ( const ConstIterator itb,
const ConstIterator ite,
OutputIterator  result 
)
inline

Estimation for a subrange [itb , ite )

Parameters
itbsubrange begin iterator
itesubrange end iterator
resultoutput iterator on the estimated quantity
Returns
the estimated quantity from itb till ite (excluded)

Definition at line 1493 of file SegmentComputerEstimators.h.

1495  {
1496  ASSERT( isValid() );
1497 
1498  // do-while loop to deal with the case of a whole circular range
1499  if (isNotEmpty(itb, ite))
1500  {
1501  ConstIterator it = itb;
1502  do
1503  {
1504  *result++ = eval( it );
1505  ++it;
1506  } while (it != ite);
1507  }
1508 
1509  return result;
1510  }
bool isNotEmpty(const IC &itb, const IC &ite, IteratorType)
template<typename DSSComputer, typename Functor = detail::CurvatureFromDSSLength>
void DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::init ( const double  h,
const ConstIterator itb,
const ConstIterator ite 
)
inline

Initialisation.

Parameters
hgrid size
itbbegin iterator
iteend iterator

Definition at line 1395 of file SegmentComputerEstimators.h.

template<typename DSSComputer, typename Functor = detail::CurvatureFromDSSLength>
bool DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::isValid ( ) const
inline

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

Definition at line 1381 of file SegmentComputerEstimators.h.

Referenced by DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, detail::CurvatureFromDSSLength >::eval().

1382  {
1383  return (myH > 0)&&(mySCPtr != 0);
1384  };
template<typename DSSComputer, typename Functor = detail::CurvatureFromDSSLength>
CurvatureFromDSSBaseEstimator& DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::operator= ( const CurvatureFromDSSBaseEstimator< DSSComputer, Functor > &  other)
inline

Assignement.

Parameters
otherthe object to copy.

Definition at line 1360 of file SegmentComputerEstimators.h.

1361  {
1362  if (this != &other)
1363  {
1364  myH = other.myH;
1365  myBegin = other.myBegin;
1366  myEnd = other.myEnd;
1367  mySCPtr = other.mySCPtr;
1368  myFunctor = other.myFunctor;
1369  }
1370  return *this;
1371  }

Field Documentation

template<typename DSSComputer, typename Functor = detail::CurvatureFromDSSLength>
ConstIterator DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::myBegin
template<typename DSSComputer, typename Functor = detail::CurvatureFromDSSLength>
ConstIterator DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::myEnd
template<typename DSSComputer, typename Functor = detail::CurvatureFromDSSLength>
Functor DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::myFunctor
template<typename DSSComputer, typename Functor = detail::CurvatureFromDSSLength>
double DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::myH
template<typename DSSComputer, typename Functor = detail::CurvatureFromDSSLength>
const SegmentComputer* DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::mySCPtr

Aliasing pointer on a constant segment computer

Definition at line 1330 of file SegmentComputerEstimators.h.

Referenced by DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, detail::CurvatureFromDSSLength >::operator=().


The documentation for this class was generated from the following file: