DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Data Fields | Private Types | Private Member Functions
DGtal::LInfLocalDistance< TImage, TSet > Class Template Reference

#include <FMMPointFunctors.h>

Public Types

typedef TImage Image
typedef Image::Point Point
typedef Image::Value Value
typedef TSet Set

Public Member Functions

 BOOST_CONCEPT_ASSERT ((CImage< TImage >))
 BOOST_CONCEPT_ASSERT ((CDigitalSet< TSet >))
 BOOST_STATIC_ASSERT ((boost::is_same< Point, typename TSet::Point >::value))
 LInfLocalDistance (Image &aImg, TSet &aSet)
 LInfLocalDistance (const LInfLocalDistance &other)
LInfLocalDistanceoperator= (const LInfLocalDistance &other)
 ~LInfLocalDistance ()
Value operator() (const Point &aPoint)
void selfDisplay (std::ostream &out) const

Data Fields

ImagemyImgPtr
SetmySetPtr

Private Types

typedef std::vector< ValueValues

Private Member Functions

Value compute (Values &aValueList) const

Detailed Description

template<typename TImage, typename TSet>
class DGtal::LInfLocalDistance< TImage, TSet >

Aim: Class for the computation of the LInf-distance at some point p, from the available distance values of some points lying in the 1-neighborhood of p (ie. points at a L1-distance to p equal to 1).

Description of template class 'LInfLocalDistance'

If there is only one available distance value v in the 1-neighborhood of p, the computed value is merely incremented or decremented. Otherwise, it is the maximum over all the available distance value in the 1-neighborhood of p.

It is a model of CPointFunctor.

Template Parameters:
TImagemodel of CImage used for the mapping point-distance value
TSetmodel of CDigitalSet for storing points whose distance value is known
See also:
FMM

Definition at line 356 of file FMMPointFunctors.h.


Member Typedef Documentation

template<typename TImage, typename TSet>
typedef TImage DGtal::LInfLocalDistance< TImage, TSet >::Image

Definition at line 364 of file FMMPointFunctors.h.

template<typename TImage, typename TSet>
typedef Image::Point DGtal::LInfLocalDistance< TImage, TSet >::Point

Definition at line 365 of file FMMPointFunctors.h.

template<typename TImage, typename TSet>
typedef TSet DGtal::LInfLocalDistance< TImage, TSet >::Set

Definition at line 370 of file FMMPointFunctors.h.

template<typename TImage, typename TSet>
typedef Image::Value DGtal::LInfLocalDistance< TImage, TSet >::Value

Definition at line 366 of file FMMPointFunctors.h.

template<typename TImage, typename TSet>
typedef std::vector<Value> DGtal::LInfLocalDistance< TImage, TSet >::Values
private

Definition at line 375 of file FMMPointFunctors.h.


Constructor & Destructor Documentation

template<typename TImage , typename TSet>
DGtal::LInfLocalDistance< TImage, TSet >::LInfLocalDistance ( Image aImg,
TSet &  aSet 
)
inline

Constructor from an image and a set. NB: only pointers are stored

Parameters:
aImgany distance map
aSetany digital set

Definition at line 465 of file FMMPointFunctors.ih.

: myImgPtr(&aImg), mySetPtr(&aSet)
{
ASSERT( myImgPtr );
ASSERT( mySetPtr );
}
template<typename TImage , typename TSet>
DGtal::LInfLocalDistance< TImage, TSet >::LInfLocalDistance ( const LInfLocalDistance< TImage, TSet > &  other)
inline

Copy constructor.

Parameters:
otherthe object to clone.

Definition at line 475 of file FMMPointFunctors.ih.

: myImgPtr(other.myImgPtr), mySetPtr(other.mySetPtr)
{
ASSERT( myImgPtr );
ASSERT( mySetPtr );
}
template<typename TImage , typename TSet >
DGtal::LInfLocalDistance< TImage, TSet >::~LInfLocalDistance ( )
inline

Destructor. Does nothing.

Definition at line 502 of file FMMPointFunctors.ih.

{
}

Member Function Documentation

template<typename TImage, typename TSet>
DGtal::LInfLocalDistance< TImage, TSet >::BOOST_CONCEPT_ASSERT ( (CImage< TImage >)  )

image

template<typename TImage, typename TSet>
DGtal::LInfLocalDistance< TImage, TSet >::BOOST_CONCEPT_ASSERT ( (CDigitalSet< TSet >)  )

set

template<typename TImage, typename TSet>
DGtal::LInfLocalDistance< TImage, TSet >::BOOST_STATIC_ASSERT ( (boost::is_same< Point, typename TSet::Point >::value)  )
template<typename TImage , typename TSet >
DGtal::LInfLocalDistance< TImage, TSet >::Value DGtal::LInfLocalDistance< TImage, TSet >::compute ( Values aValueList) const
inlineprivate

Returns the LInf-distance at some point, knowing the distance of its neighbors

Parameters:
aValueListthe distance of (some of) the neighbors
Returns:
the computed distance.

Definition at line 568 of file FMMPointFunctors.ih.

{
ASSERT(aValueList.size() > 0);
if ( aValueList.size() == 1 )
{
Value d = aValueList.back();
if (d >= 0) ++d;
else --d;
return d;
}
else
{ //max element
typename Values::iterator it =
std::max_element( aValueList.begin(), aValueList.end(), absComparator<Value> );
return *it;
}
}
template<typename TImage , typename TSet >
DGtal::LInfLocalDistance< TImage, TSet >::Value DGtal::LInfLocalDistance< TImage, TSet >::operator() ( const Point aPoint)
inline

LInf-distance computation at aPoint , from the available distance values of the 1-neighbors of aPoint .

Parameters:
aPointthe point for which the distance is computed
Returns:
the distance value at aPoint.

Definition at line 510 of file FMMPointFunctors.ih.

References DGtal::findAndGetValue().

{
//distance values
Values v;
v.reserve(Point::dimension);
//two 1-neighbors
Point neighbor1 = aPoint;
Point neighbor2 = aPoint;
typename Point::Iterator it1 = neighbor1.begin();
typename Point::Iterator it2 = neighbor2.begin();
typename Point::ConstIterator it = aPoint.begin();
typename Point::ConstIterator itEnd = aPoint.end();
for ( ; it != itEnd; ++it, ++it1, ++it2)
{//for each dimension
typename Point::Coordinate c = *it;
*it1 = (c+1);
*it2 = (c-1);
//neighboring values
Value d, d1, d2 = 0;
bool flag1 = findAndGetValue( *myImgPtr, *mySetPtr, neighbor1, d1 );
bool flag2 = findAndGetValue( *myImgPtr, *mySetPtr, neighbor2, d2 );
if ( flag1 || flag2 )
{
if ( flag1 && flag2 )
{ //take the minimal value
if (std::abs(d1) < std::abs(d2))
d = d1;
else
d = d2;
} else
{
if (flag1) d = d1;
if (flag2) d = d2;
}
v.push_back(d);
}
*it1 = c;
*it2 = c;
} //end for each dimension
//computation of the new value
return this->compute(v);
}
template<typename TImage , typename TSet >
DGtal::LInfLocalDistance< TImage, TSet > & DGtal::LInfLocalDistance< TImage, TSet >::operator= ( const LInfLocalDistance< TImage, TSet > &  other)
inline

Assignment.

Parameters:
otherthe object to copy.
Returns:
a reference on 'this'.

Definition at line 486 of file FMMPointFunctors.ih.

References DGtal::LInfLocalDistance< TImage, TSet >::myImgPtr, and DGtal::LInfLocalDistance< TImage, TSet >::mySetPtr.

{
if( this != &other)
{
myImgPtr = other.myImgPtr;
mySetPtr = other.mySetPtr;
ASSERT( myImgPtr );
ASSERT( mySetPtr );
}
return *this;
}
template<typename TImage , typename TSet >
void DGtal::LInfLocalDistance< TImage, TSet >::selfDisplay ( std::ostream &  out) const
inline

Writes/Displays the object on an output stream.

Parameters:
outthe output stream where the object is written.

Definition at line 593 of file FMMPointFunctors.ih.

{
out << "LInf";
}

Field Documentation

template<typename TImage, typename TSet>
Image* DGtal::LInfLocalDistance< TImage, TSet >::myImgPtr

Aliasing pointer on the underlying image.

Definition at line 380 of file FMMPointFunctors.h.

Referenced by DGtal::LInfLocalDistance< TImage, TSet >::operator=().

template<typename TImage, typename TSet>
Set* DGtal::LInfLocalDistance< TImage, TSet >::mySetPtr

Aliasing pointer on the underlying set.

Definition at line 382 of file FMMPointFunctors.h.

Referenced by DGtal::LInfLocalDistance< TImage, TSet >::operator=().


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