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

#include <FMM.h>

Collaboration diagram for DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >:
Collaboration graph
[legend]

Public Types

typedef TImage Image
typedef TSet AcceptedPointSet
typedef TPointPredicate PointPredicate
typedef Image::Point Vector
typedef Image::Point Point
typedef Point::Dimension Dimension
typedef TPointFunctor PointFunctor
typedef PointFunctor::Value Value

Public Member Functions

 BOOST_CONCEPT_ASSERT ((CImage< TImage >))
 BOOST_CONCEPT_ASSERT ((CDigitalSet< TSet >))
 BOOST_CONCEPT_ASSERT ((CPointPredicate< TPointPredicate >))
 BOOST_CONCEPT_ASSERT ((CPointFunctor< TPointFunctor >))
 BOOST_STATIC_ASSERT ((boost::is_same< Point, typename AcceptedPointSet::Point >::value))
 BOOST_STATIC_ASSERT ((boost::is_same< Point, typename PointPredicate::Point >::value))
 FMM (Image &aImg, AcceptedPointSet &aSet, const PointPredicate &aPointPredicate)
 FMM (Image &aImg, AcceptedPointSet &aSet, const PointPredicate &aPointPredicate, const Area &aAreaThreshold, const Value &aValueThreshold)
 FMM (Image &aImg, AcceptedPointSet &aSet, const PointPredicate &aPointPredicate, PointFunctor &aPointFunctor)
 FMM (Image &aImg, AcceptedPointSet &aSet, const PointPredicate &aPointPredicate, const Area &aAreaThreshold, const Value &aValueThreshold, PointFunctor &aPointFunctor)
 ~FMM ()
void compute ()
bool computeOneStep (Point &aPoint, Value &aValue)
Value min () const
Value max () const
Value getMin () const
Value getMax () const
void selfDisplay (std::ostream &out) const
bool isValid () const

Static Public Member Functions

template<typename TIteratorOnPoints >
static void initFromPointsRange (const TIteratorOnPoints &itb, const TIteratorOnPoints &ite, Image &aImg, AcceptedPointSet &aSet, const Value &aValue)
template<typename KSpace , typename TIteratorOnBels >
static void initFromBelsRange (const KSpace &aK, const TIteratorOnBels &itb, const TIteratorOnBels &ite, Image &aImg, AcceptedPointSet &aSet, const Value &aValue, bool aFlagIsPositive=false)
template<typename KSpace , typename TIteratorOnBels , typename TImplicitFunction >
static void initFromBelsRange (const KSpace &aK, const TIteratorOnBels &itb, const TIteratorOnBels &ite, const TImplicitFunction &aF, Image &aImg, AcceptedPointSet &aSet, bool aFlagIsPositive=false)
template<typename TIteratorOnPairs >
static void initFromIncidentPointsRange (const TIteratorOnPairs &itb, const TIteratorOnPairs &ite, Image &aImg, AcceptedPointSet &aSet, const Value &aValue, bool aFlagIsPositive=false)

Static Public Attributes

static const Dimension dimension = Point::dimension

Private Types

typedef std::pair< Point, ValuePointValue
typedef std::set< PointValue,
details::PointValueCompare
< PointValue > > 
CandidatePointSet
typedef unsigned long Area

Private Member Functions

 FMM (const FMM &other)
FMMoperator= (const FMM &other)
void init ()
bool addNewAcceptedPoint (Point &aPoint, Value &aValue)
void update (const Point &aPoint)
bool addNewCandidate (const Point &aPoint)

Private Attributes

ImagemyImage
AcceptedPointSetmyAcceptedPoints
CandidatePointSet myCandidatePoints
PointFunctormyPointFunctorPtr
const bool myFlagIsOwning
const PointPredicatemyPointPredicate
Area myAreaThreshold
Value myValueThreshold
Value myMinValue
Value myMaxValue

Detailed Description

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
class DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >

Aim: Fast Marching Method (FMM) for nd distance transforms.

Description of template class 'FMM'

In this approach, a signed distance function is computed at each digital point by marching out from an initial set of points, for which the values of the signed distance are known. This set is an initialization of the so-called accepted point set. Each digital point adjacent to one of the accepted points is put into the so-called candidate point set. A tentative value is computed for its signed distance, using only the values of the accepted points lying in its neighborhood. This task is delegated to an instance of a point functor, which is defined as L2FirstOrderLocalDistance by default. However, you are free to use L2SecondOrderLocalDistance, which provides more accurate distance values, L1LocalDistance and LInfLocalDistance for other norms.

See also:
FMMPointFunctors.h

Then the point of smallest tentative value is added to the set of accepted points. The tentative values of the candidates adjacent to the newly added point are updated using the distance value of the newly added point. The search of the point of smallest tentative value is accelerated using a STL set of pairs (point, tentative value).

Template Parameters:
TImageany model of CImage
TSetany model of CDigitalSet
TPointPredicateany model of CPointPredicate, used to bound the computation within a domain
TPointFunctorany model of CPointFunctor, used to compute the new distance value

You can define the FMM type as follows:

typedef FMM<DistanceImage, PointSet, Domain::Predicate > FMM;

You can run the algorithm as follows (d is a domain):

FMM fmm( image, points, d.predicate(), d.size(), maximalWidth );
fmm.compute();
trace.info() << fmm << std::endl;
See also:
exampleFMM2D.cpp
exampleFMM3D.cpp
testFMM.cpp

Definition at line 148 of file FMM.h.


Member Typedef Documentation

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
typedef TSet DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::AcceptedPointSet

Definition at line 162 of file FMM.h.

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
typedef unsigned long DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::Area
private

Definition at line 186 of file FMM.h.

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
typedef std::set<PointValue, details::PointValueCompare<PointValue> > DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::CandidatePointSet
private

Definition at line 185 of file FMM.h.

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
typedef Point::Dimension DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::Dimension

Definition at line 172 of file FMM.h.

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
typedef TImage DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::Image

Definition at line 161 of file FMM.h.

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
typedef Image::Point DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::Point

Definition at line 167 of file FMM.h.

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
typedef TPointFunctor DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::PointFunctor

Definition at line 176 of file FMM.h.

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
typedef TPointPredicate DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::PointPredicate

Definition at line 163 of file FMM.h.

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
typedef std::pair<Point, Value> DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::PointValue
private

Definition at line 183 of file FMM.h.

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
typedef PointFunctor::Value DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::Value

Definition at line 177 of file FMM.h.

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
typedef Image::Point DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::Vector

Definition at line 166 of file FMM.h.


Constructor & Destructor Documentation

template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::FMM ( Image aImg,
AcceptedPointSet aSet,
const PointPredicate aPointPredicate 
)
inline

Constructor.

See also:
init

Definition at line 49 of file FMM.ih.

References DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::init(), and DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::myAcceptedPoints.

: myImage( aImg ), myAcceptedPoints( aSet ),
myPointFunctorPtr( new PointFunctor(aImg, aSet) ),
myFlagIsOwning( true ),
myPointPredicate( aPointPredicate ),
myAreaThreshold( std::numeric_limits<Area>::max() ),
myValueThreshold( std::numeric_limits<Value>::max() )
{
if (myAcceptedPoints.size() == 0) throw InputException();
init();
}
template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::FMM ( Image aImg,
AcceptedPointSet aSet,
const PointPredicate aPointPredicate,
const Area aAreaThreshold,
const Value aValueThreshold 
)
inline

Constructor.

See also:
init

Definition at line 66 of file FMM.ih.

References DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::init(), and DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::myAcceptedPoints.

: myImage( aImg ), myAcceptedPoints( aSet ),
myPointFunctorPtr( new PointFunctor(aImg, aSet) ),
myFlagIsOwning( true ),
myPointPredicate( aPointPredicate ),
myAreaThreshold( aAreaThreshold ),
myValueThreshold( aValueThreshold )
{
if (myAcceptedPoints.size() == 0) throw InputException();
init();
}
template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::FMM ( Image aImg,
AcceptedPointSet aSet,
const PointPredicate aPointPredicate,
PointFunctor aPointFunctor 
)
inline

Constructor.

See also:
init

Definition at line 85 of file FMM.ih.

References DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::init(), and DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::myAcceptedPoints.

: myImage( aImg ), myAcceptedPoints( aSet ),
myPointFunctorPtr( &aPointFunctor ),
myFlagIsOwning( false ),
myPointPredicate( aPointPredicate ),
myAreaThreshold( std::numeric_limits<Area>::max() ),
myValueThreshold( std::numeric_limits<Value>::max() )
{
if (myAcceptedPoints.size() == 0) throw InputException();
init();
}
template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::FMM ( Image aImg,
AcceptedPointSet aSet,
const PointPredicate aPointPredicate,
const Area aAreaThreshold,
const Value aValueThreshold,
PointFunctor aPointFunctor 
)
inline

Constructor.

See also:
init

Definition at line 103 of file FMM.ih.

References DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::init(), and DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::myAcceptedPoints.

: myImage( aImg ), myAcceptedPoints( aSet ),
myPointFunctorPtr( &aPointFunctor ),
myFlagIsOwning( false ),
myPointPredicate( aPointPredicate ),
myAreaThreshold( aAreaThreshold ),
myValueThreshold( aValueThreshold )
{
if (myAcceptedPoints.size() == 0) throw InputException();
init();
}
template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::~FMM ( )
inline

Destructor.

Definition at line 122 of file FMM.ih.

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::FMM ( const FMM< TImage, TSet, TPointPredicate, TPointFunctor > &  other)
private

Copy constructor.

Parameters:
otherthe object to clone. Forbidden by default.

Member Function Documentation

template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
bool DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::addNewAcceptedPoint ( Point aPoint,
Value aValue 
)
inlineprivate

Inserts the candidate of min distance into the set of accepted points and updates the distance values of the candidate points.

Parameters:
aPointinserted point (if true)
aValuedistance value of the inserted point (if true)
Returns:
'true' if the point of min distance is accepted 'false' otherwise.

Definition at line 403 of file FMM.ih.

References DGtal::insertAndSetValue().

{
if ( (myAcceptedPoints.size()+1) < myAreaThreshold )
{//if a new point can be accepted
bool flagStop = false;
typename CandidatePointSet::iterator it = myCandidatePoints.begin();
typename CandidatePointSet::iterator itEnd = myCandidatePoints.end();
while ( (it != itEnd) && (!flagStop) )
{ //while there are candidates and no point has been accepted
//pair of min distance
PointValue minPair = *it;
if ( std::abs(minPair.second) < myValueThreshold )
{ //if distance below a given threshold
//the point of min distance is removed from the set of candidates
myCandidatePoints.erase(*it);
//it can be inserted into the set of accepted points
minPair.first, minPair.second ) )
{ //if it does not belong to the set
//the set of candidates is updated with
//the neighbors of the new accepted point
aPoint = minPair.first;
aValue = minPair.second;
if (aValue > myMaxValue) myMaxValue = aValue;
if (aValue < myMinValue) myMinValue = aValue;
update( aPoint );
flagStop = true;
}
else
{ //otherwise it has already been accepted
//with a smaller distance and the next candidate
//should be considered
it = myCandidatePoints.begin();
}
}//end if distance below a given threshold
else return false;
} //end while there are candidates
return flagStop; //true if a point has been accepted
} //end if a new point can be accepted
else return false;
}
template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
bool DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::addNewCandidate ( const Point aPoint)
inlineprivate

Tests a new point as a candidate. If it is not yet accepted and if the point predicate returns 'true', computes its distance and inserts it into the set of candidate points.

Parameters:
aPointany point
Returns:
'true' if inserted, 'false' otherwise.

Definition at line 476 of file FMM.ih.

{
//if it lies within the computation domain
//and if it is not already accepted
if ( (myPointPredicate(aPoint) )
&& ( myAcceptedPoints.find(aPoint) == myAcceptedPoints.end() ) )
{
ASSERT( myPointFunctorPtr );
Value d = myPointFunctorPtr->operator()( aPoint );
PointValue newPair( aPoint, d );
//insert the new candidate with its distance
myCandidatePoints.insert(newPair);
return true;
}
else return false;
}
template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::BOOST_CONCEPT_ASSERT ( (CImage< TImage >)  )
template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::BOOST_CONCEPT_ASSERT ( (CDigitalSet< TSet >)  )
template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::BOOST_CONCEPT_ASSERT ( (CPointPredicate< TPointPredicate >)  )
template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::BOOST_CONCEPT_ASSERT ( (CPointFunctor< TPointFunctor >)  )
template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::BOOST_STATIC_ASSERT ( (boost::is_same< Point, typename AcceptedPointSet::Point >::value)  )
template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::BOOST_STATIC_ASSERT ( (boost::is_same< Point, typename PointPredicate::Point >::value)  )
template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
void DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::compute ( )
inline

Computation of the signed distance function by marching out from the initial set of accepted points. While it is possible, the candidate of min distance is inserted into the set of accepted points.

See also:
computeOneStep

Definition at line 264 of file FMM.ih.

{
Point p = Point::diagonal(0);
Value d = 0;
while ( addNewAcceptedPoint( p, d ) )
{ }
}
template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
bool DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::computeOneStep ( Point aPoint,
Value aValue 
)
inline

Inserts the candidate of min distance into the set of accepted points if it is possible and then updates the distance values associated to the candidate points.

Parameters:
aPointinserted point (if inserted)
aValueits distance value (if inserted)
Returns:
'true' if the point of min distance is accepted 'false' otherwise.
See also:
addNewAcceptedPoint

Definition at line 276 of file FMM.ih.

{
return addNewAcceptedPoint(aPoint, aValue);
}
template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::Value DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::getMax ( ) const
inline

Computes the maximal distance value in the set of accepted points.

NB: in O(n log n) where n is the size of the set

Returns:
maximal distance value.

Definition at line 319 of file FMM.ih.

{
ASSERT( set.size() >= 1 );
typename AcceptedPointSet::ConstIterator it = set.begin();
typename AcceptedPointSet::ConstIterator itEnd = set.end();
Value vmax = myImage( *it );
for (++it; it != itEnd; ++it)
{
Value v = myImage( *it );
if (v > vmax) vmax = v;
}
return vmax;
}
template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::Value DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::getMin ( ) const
inline

Computes the minimal distance value in the set of accepted points.

NB: in O(n log n) where n is the size of the set

Returns:
minimal distance value.

Definition at line 300 of file FMM.ih.

{
ASSERT( set.size() >= 1 );
typename AcceptedPointSet::ConstIterator it = set.begin();
typename AcceptedPointSet::ConstIterator itEnd = set.end();
Value vmin = myImage( *it );
for (++it; it != itEnd; ++it)
{
Value v = myImage( *it );
if (v < vmin) vmin = v;
}
return vmin;
}
template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
void DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::init ( )
inlineprivate

Initialize the set of candidate points

Definition at line 382 of file FMM.ih.

Referenced by DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::FMM().

{
typename AcceptedPointSet::Iterator it = myAcceptedPoints.begin();
typename AcceptedPointSet::Iterator itEnd = myAcceptedPoints.end();
for ( ; it != itEnd; ++it)
{
update( *it );
}
}
template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
template<typename KSpace , typename TIteratorOnBels >
void DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::initFromBelsRange ( const KSpace &  aK,
const TIteratorOnBels &  itb,
const TIteratorOnBels &  ite,
Image aImg,
AcceptedPointSet aSet,
const Value aValue,
bool  aFlagIsPositive = false 
)
static

Initialize aImg and aSet from the points incident to the signed cells of the range [itb , ite ) Assign to the inner points a distance equal to - aValue if aFlagIsPositive is 'false' (default) but aValue otherwise, and conversely for the outer points.

Parameters:
itbbegin iterator (on signed cells)
iteend iterator (on signed cells)
aImgthe distance image
aSetthe set of points for which the distance has been assigned
aValuedistance default value

Definition at line 152 of file FMM.ih.

References DGtal::insertAndAlwaysSetValue().

{
Value k = -1;
if (aFlagIsPositive) k = 1;
aSet.clear();
for (TIteratorOnBels it = itb; it != ite; ++it)
{
//getting incident points
typename SCellToIncidentPoints<KSpace>::Output points = func( *it );
//assignement
insertAndAlwaysSetValue( aImg, aSet, points.first, k*aValue );
insertAndAlwaysSetValue( aImg, aSet, points.second, -k*aValue );
}
}
template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
template<typename KSpace , typename TIteratorOnBels , typename TImplicitFunction >
void DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::initFromBelsRange ( const KSpace &  aK,
const TIteratorOnBels &  itb,
const TIteratorOnBels &  ite,
const TImplicitFunction &  aF,
Image aImg,
AcceptedPointSet aSet,
bool  aFlagIsPositive = false 
)
static

Initialize aImg and aSet from the points incident to the signed cells of the range [itb , ite ) Assign to the inner points a distance equal to - aValue if aFlagIsPositive is 'false' (default) but aValue otherwise, and conversely for the outer points.

Parameters:
itbbegin iterator (on signed cells)
iteend iterator (on signed cells)
aFany implicit function
aImgthe distance image
aSetthe set of points for which the distance has been assigned

types

1) store a value for each bel (== distance of the inner point to the interface)

2) for each inner/outer point computes its distance from the values of its incident bels

Definition at line 177 of file FMM.ih.

References DGtal::abs(), and DGtal::insertAndAlwaysSetValue().

{
Value k = -1;
if (aFlagIsPositive) k = 1;
typedef typename KSpace::Cell Bel;
typedef typename TImplicitFunction::Value Value;
typedef std::pair<const Bel, Value> BelValue;
typedef std::map<Bel, Value> Buffer;
typedef typename SCellToIncidentPoints<KSpace>::Output Pair;
typedef std::vector<Pair> IncidentPoints;
SCellToIncidentPoints<KSpace> getIncidentPoints( aK );
IncidentPoints incidentPoints;
Buffer buffer;
for (TIteratorOnBels it = itb; it != ite; ++it)
{
//getting incident points
Pair points = getIncidentPoints( *it );
incidentPoints.push_back( points );
//getting values
Value vin = aF( points.first );
Value vout = aF( points.second );
//computing/storing the new value
Value e = std::max(vin, vout) - std::min(vin, vout);
Value v = (std::abs(vin)/e);
ASSERT( v >= 0 );
buffer.insert( BelValue( aK.unsigns( *it ), v ) );
}
aSet.clear();
Computer4InnerPts computerIn(aK, buffer);
Computer4OuterPts computerOut(aK, buffer);
for (typename IncidentPoints::const_iterator it = incidentPoints.begin();
it != incidentPoints.end(); ++it)
{
//computing the values
Value vin = computerIn( it->first );
Value vout = computerOut( it->second );
//assignement
insertAndAlwaysSetValue( aImg, aSet, it->first, k*vin );
insertAndAlwaysSetValue( aImg, aSet, it->second, -k*vout );
}
}
template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
template<typename TIteratorOnPairs >
void DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::initFromIncidentPointsRange ( const TIteratorOnPairs &  itb,
const TIteratorOnPairs &  ite,
Image aImg,
AcceptedPointSet aSet,
const Value aValue,
bool  aFlagIsPositive = false 
)
static

Initialize aImg and aSet from the inner and outer points of the range [itb , ite ) of pairs of points. Assign to the inner points a distance equal to - aValue if aFlagIsPositive is 'false' (default) but aValue otherwise, and conversely for the outer points.

Parameters:
itbbegin iterator (on points)
iteend iterator (on points)
aImgthe distance image
aSetthe set of points for which the distance has been assigned
aValuedistance default value

Definition at line 241 of file FMM.ih.

References DGtal::insertAndAlwaysSetValue().

{
Value k = -1;
if (aFlagIsPositive) k = 1;
aSet.clear();
for (TIteratorOnPairs it = itb; it != ite; ++it)
{
insertAndAlwaysSetValue( aImg, aSet, it->first, k*aValue );
insertAndAlwaysSetValue( aImg, aSet, it->second, -k*aValue );
}
}
template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
template<typename TIteratorOnPoints >
void DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::initFromPointsRange ( const TIteratorOnPoints &  itb,
const TIteratorOnPoints &  ite,
Image aImg,
AcceptedPointSet aSet,
const Value aValue 
)
static

Initialize aImg and aSet from the points of the range [itb , ite ) Assign a distance equal to aValue

Parameters:
itbbegin iterator (on points)
iteend iterator (on points)
aImgthe distance image
aSetthe set of points for which the distance has been assigned
aValuedistance default value

Definition at line 136 of file FMM.ih.

References DGtal::insertAndAlwaysSetValue().

{
aSet.clear();
for (TIteratorOnPoints it = itb; it != ite; ++it)
{
insertAndAlwaysSetValue( aImg, aSet, *it, aValue );
}
}
template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
bool DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::isValid ( ) const
inline

Checks the validity/consistency of the object.

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

Definition at line 338 of file FMM.ih.

{
//area threshold
if ( (myAcceptedPoints.size() <= 0)
|| (myAcceptedPoints.size() >= myAreaThreshold) ) return false;
//distance threshold
if ( ( getMin() != min() ) || ( getMax() != max() ) ) return false;
if ( (std::abs(getMin()) >= myValueThreshold)
|| (getMax() >= myValueThreshold) ) return false;
//point predicate
bool flagIsOk = true;
typename AcceptedPointSet::ConstIterator it = set.begin();
typename AcceptedPointSet::ConstIterator itEnd = set.end();
for ( ; ( (it != itEnd)&&(flagIsOk == true) ); ++it)
{
if (myPointPredicate( *it ) == false) flagIsOk = false;
}
if (!flagIsOk) return false;
return true;
}
template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::Value DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::max ( ) const
inline

Maximal distance value in the set of accepted points.

Returns:
maximal distance value

Definition at line 292 of file FMM.ih.

{
return myMaxValue;
}
template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::Value DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::min ( ) const
inline

Minimal distance value in the set of accepted points.

Returns:
minimal distance value.

Definition at line 284 of file FMM.ih.

{
return myMinValue;
}
template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
FMM& DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::operator= ( const FMM< TImage, TSet, TPointPredicate, TPointFunctor > &  other)
private

Assignment.

Parameters:
otherthe object to copy.
Returns:
a reference on 'this'. Forbidden by default.
template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
void DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::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 366 of file FMM.ih.

{
out << "[FMM " << dimension << "d] ";
out << myAcceptedPoints.size() << " accepted points (< " << myAreaThreshold << ")";
out << " and " << myCandidatePoints.size() << " candidates. ";
out << "dmin: " << min() << ", dmax: " << max();
out << " (abs < " << myValueThreshold << ")";
}
template<typename TImage , typename TSet , typename TPointPredicate , typename TPointFunctor >
void DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::update ( const Point aPoint)
inlineprivate

Updates the distance values of the neighbors of aPoint belonging to the set of accepted points

Parameters:
aPointany point

Definition at line 457 of file FMM.ih.

{
//neigbors
Point neighbor = aPoint;
for (Dimension k = 0; k < dimension; ++k)
{
typename Point::Coordinate c = neighbor.at(k);
neighbor.at(k) = (c+1);
addNewCandidate(neighbor);
neighbor.at(k) = (c-1);
addNewCandidate(neighbor);
neighbor.at(k) = c;
}
}

Field Documentation

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
const Dimension DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::dimension = Point::dimension
static

Definition at line 173 of file FMM.h.

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
AcceptedPointSet& DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::myAcceptedPoints
private

Reference on the set of accepted points

Definition at line 199 of file FMM.h.

Referenced by DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::FMM().

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
Area DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::myAreaThreshold
private

Area threshold (in number of accepted points) above which the propagation stops

Definition at line 231 of file FMM.h.

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
CandidatePointSet DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::myCandidatePoints
private

Set of candidate points

Definition at line 204 of file FMM.h.

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
const bool DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::myFlagIsOwning
private

'true' if myPointFunctorPtr is an owning pointer (default case), 'false' if it is an aliasing pointer on a point functor given at construction

Definition at line 218 of file FMM.h.

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
Image& DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::myImage
private

Reference on the image

Definition at line 194 of file FMM.h.

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
Value DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::myMaxValue
private

Max value

Definition at line 246 of file FMM.h.

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
Value DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::myMinValue
private

Min value

Definition at line 241 of file FMM.h.

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
PointFunctor* DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::myPointFunctorPtr
private

Pointer on the point functor used to deduce the distance of a new point from the distance of its neighbors

Definition at line 211 of file FMM.h.

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
const PointPredicate& DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::myPointPredicate
private

Constant reference on a point predicate that returns 'true' inside the domain where the distance transform is performed

Definition at line 225 of file FMM.h.

template<typename TImage, typename TSet, typename TPointPredicate, typename TPointFunctor = L2FirstOrderLocalDistance<TImage,TSet>>
Value DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::myValueThreshold
private

Value threshold above which the propagation stops

Definition at line 236 of file FMM.h.


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