DGtal 1.3.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Data Fields
DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor > Class Template Reference

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

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

Member Typedef Documentation

◆ ConstIterator

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

Definition at line 1307 of file SegmentComputerEstimators.h.

◆ Quantity

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

Definition at line 1308 of file SegmentComputerEstimators.h.

◆ SegmentComputer

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

Definition at line 1306 of file SegmentComputerEstimators.h.

Constructor & Destructor Documentation

◆ CurvatureFromDSSBaseEstimator() [1/2]

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

◆ CurvatureFromDSSBaseEstimator() [2/2]

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

1351 : myH( other.myH ), myBegin( other.myBegin ), myEnd( other.myEnd ),
1352 mySCPtr( other.mySCPtr ), myFunctor( other.myFunctor )
1353 {
1354 }

◆ ~CurvatureFromDSSBaseEstimator()

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

Destructor

Definition at line 1374 of file SegmentComputerEstimators.h.

1374{}

Member Function Documentation

◆ attach()

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

1513 {
1514 mySCPtr = &aSC;
1515 ASSERT( mySCPtr );
1516 };

References DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::mySCPtr.

◆ BOOST_CONCEPT_ASSERT()

template<typename DSSComputer , typename Functor = detail::CurvatureFromDSSLength>
DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::BOOST_CONCEPT_ASSERT ( (concepts::CUnaryFunctor< Functor, SegmentComputer, Quantity >)  )

◆ eval() [1/2]

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

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

References DGtal::detail::isNotEmpty(), DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::isValid(), DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::myBegin, DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::myEnd, DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::myFunctor, DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::myH, and DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::mySCPtr.

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

◆ eval() [2/2]

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

1491 {
1492 ASSERT( isValid() );
1493
1494 // do-while loop to deal with the case of a whole circular range
1495 if (isNotEmpty(itb, ite))
1496 {
1497 ConstIterator it = itb;
1498 do
1499 {
1500 *result++ = eval( it );
1501 ++it;
1502 } while (it != ite);
1503 }
1504
1505 return result;
1506 }

References DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::eval(), DGtal::detail::isNotEmpty(), and DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::isValid().

◆ init()

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

1395 {
1396 myH = h;
1397 myBegin = itb;
1398 myEnd = ite;
1399 ASSERT( myH > 0 );
1400 }

References DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::myBegin, DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::myEnd, and DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::myH.

◆ isValid()

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

1381 {
1382 return (myH > 0)&&(mySCPtr != 0);
1383 };

References DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::myH, and DGtal::detail::CurvatureFromDSSBaseEstimator< DSSComputer, Functor >::mySCPtr.

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

◆ operator=()

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

Field Documentation

◆ myBegin

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

◆ myEnd

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

◆ myFunctor

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

◆ myH

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

◆ mySCPtr

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: