DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Data Fields
DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor > Class Template Reference

#include <SegmentComputerEstimators.h>

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

Public Types

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

Public Member Functions

 BOOST_CONCEPT_ASSERT ((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 &it)
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 1309 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 1316 of file SegmentComputerEstimators.h.

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

Definition at line 1317 of file SegmentComputerEstimators.h.

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

Definition at line 1315 of file SegmentComputerEstimators.h.


Constructor & Destructor Documentation

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

Default constructor. NB: not valid.

Definition at line 1351 of file SegmentComputerEstimators.h.

: myH( 0.0 ), myBegin(), myEnd(), mySCPtr(0), myFunctor()
{
}
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 1359 of file SegmentComputerEstimators.h.

: myH( other.myH ), myBegin( other.myBegin ), myEnd( other.myEnd ),
mySCPtr( other.mySCPtr ), myFunctor( other.myFunctor )
{
}
template<typename DSSComputer, typename Functor = detail::CurvatureFromDSSLength>
DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::~CurvatureFromDSSBaseEstimator ( )
inline

Destructor

Definition at line 1383 of file SegmentComputerEstimators.h.

{}

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 1525 of file SegmentComputerEstimators.h.

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

Unique estimation

Parameters:
itany iterator
Returns:
the estimated quantity

Definition at line 1416 of file SegmentComputerEstimators.h.

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

{
ASSERT( isValid() );
//types
typedef typename DSSComputer::Integer Integer;
typedef typename DSSComputer::Vector Vector;
//curvature value
Quantity k = 0;
//begin and end iterators
//(back point on the first point)
//(front point on the last point)
ConstIterator back = mySCPtr->begin();
ConstIterator front = mySCPtr->end();
bool isConnectedAtBack = isNotEmpty(myBegin, back)
&&((*boost::prior(back)-*back).norm(Vector::L1) <= NumberTraits<Integer>::ONE);
bool isConnectedAtFront = isNotEmpty(front, myEnd)
&&((*boost::prior(front)-*front).norm(Vector::L1) <= NumberTraits<Integer>::ONE);
if (isConnectedAtBack) {
if (isConnectedAtFront) {
--back;
//parameters
Integer mu = mySCPtr->getMu();
Integer omega = mySCPtr->getOmega();
//cases
if ( (mySCPtr->getRemainder(*back)<=mu-1)&&
(mySCPtr->getRemainder(*front)<=mu-1) ) { //convex
k = myFunctor(*mySCPtr) / myH;
} else if ( (mySCPtr->getRemainder(*back)>=mu+omega)&&
(mySCPtr->getRemainder(*front)>=mu+omega) ) { //concave
k = -myFunctor(*mySCPtr) / myH;
} //else //inflection
} else {
--back;
//parameters
Integer mu = mySCPtr->getMu();
Integer omega = mySCPtr->getOmega();
//cases
if ( (mySCPtr->getRemainder(*back)<=mu-1) ) { //convex
k = myFunctor(*mySCPtr) / myH;
} else if ( (mySCPtr->getRemainder(*back)>=mu+omega) ) { //concave
k = -myFunctor(*mySCPtr) / myH;
} //else //inflection
}
} else if (isConnectedAtFront) {
//parameters
Integer mu = mySCPtr->getMu();
Integer omega = mySCPtr->getOmega();
//cases
if ( (mySCPtr->getRemainder(*front)<=mu-1) ) { //convex
k = myFunctor(*mySCPtr) / myH;
} else if ( (mySCPtr->getRemainder(*front)>=mu+omega) ) { //concave
k = -myFunctor(*mySCPtr) / myH;
} //else //inflection
} //else cannot be extended: k is set to 0
return k;
}
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 1502 of file SegmentComputerEstimators.h.

{
ASSERT( isValid() );
// do-while loop to deal with the case of a whole circular range
if (isNotEmpty(itb, ite))
{
ConstIterator it = itb;
do
{
*result++ = eval( it );
++it;
} while (it != ite);
}
return result;
}
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
itb,beginiterator
ite,enditerator

Definition at line 1403 of file SegmentComputerEstimators.h.

{
myH = h;
myBegin = itb;
myEnd = ite;
ASSERT( myH > 0 );
}
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 1389 of file SegmentComputerEstimators.h.

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

{
return (myH > 0)&&(mySCPtr != 0);
};
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 1368 of file SegmentComputerEstimators.h.

{
if (this != &other)
{
myH = other.myH;
myBegin = other.myBegin;
myEnd = other.myEnd;
mySCPtr = other.mySCPtr;
myFunctor = other.myFunctor;
}
return *this;
}

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

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