DGtal 1.4.2
|
Aim: Fast Marching Method (FMM) for nd distance transforms. More...
#include <DGtal/geometry/volumes/distance/FMM.h>
Public Types | |
typedef TImage | Image |
typedef TSet | AcceptedPointSet |
typedef TPointPredicate | PointPredicate |
typedef Image::Point | Point |
typedef Point::Dimension | Dimension |
typedef TPointFunctor | PointFunctor |
typedef PointFunctor::Value | Value |
Public Member Functions | |
BOOST_CONCEPT_ASSERT ((concepts::CImage< TImage >)) | |
BOOST_CONCEPT_ASSERT ((concepts::CDigitalSet< TSet >)) | |
BOOST_CONCEPT_ASSERT ((concepts::CPointPredicate< TPointPredicate >)) | |
BOOST_CONCEPT_ASSERT ((concepts::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, ConstAlias< PointPredicate > aPointPredicate) | |
FMM (Image &aImg, AcceptedPointSet &aSet, ConstAlias< PointPredicate > aPointPredicate, const Area &aAreaThreshold, const Value &aValueThreshold) | |
FMM (Image &aImg, AcceptedPointSet &aSet, ConstAlias< PointPredicate > aPointPredicate, PointFunctor &aPointFunctor) | |
FMM (Image &aImg, AcceptedPointSet &aSet, ConstAlias< 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=true) |
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=true) |
template<typename TIteratorOnPairs > | |
static void | initFromIncidentPointsRange (const TIteratorOnPairs &itb, const TIteratorOnPairs &ite, Image &aImg, AcceptedPointSet &aSet, const Value &aValue, bool aFlagIsPositive=true) |
Static Public Attributes | |
static const Dimension | dimension |
Private Types | |
typedef std::pair< Point, Value > | PointValue |
typedef std::set< PointValue, detail::PointValueCompare< PointValue > > | CandidatePointSet |
typedef DGtal::uint64_t | Area |
Private Member Functions | |
FMM (const FMM &other) | |
FMM & | operator= (const FMM &other) |
void | init () |
bool | addNewAcceptedPoint (Point &aPoint, Value &aValue) |
void | update (const Point &aPoint) |
bool | addNewCandidate (const Point &aPoint) |
Private Attributes | |
Image & | myImage |
AcceptedPointSet & | myAcceptedPoints |
CandidatePointSet | myCandidatePoints |
PointFunctor * | myPointFunctorPtr |
const bool | myFlagIsOwning |
const PointPredicate & | myPointPredicate |
Area | myAreaThreshold |
Value | myValueThreshold |
Value | myMinValue |
Value | myMaxValue |
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.
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).
TImage | any model of CImage |
TSet | any model of CDigitalSet |
TPointPredicate | any model of concepts::CPointPredicate, used to bound the computation within a domain |
TPointFunctor | any model of CPointFunctor, used to compute the new distance value |
You can define the FMM type as follows:
You can construct and initialize the external data structures as follows:
Then, the algorithm is ran as follows:
TSet DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::AcceptedPointSet |
|
private |
|
private |
Point::Dimension DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::Dimension |
TImage DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::Image |
Image::Point DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::Point |
TPointFunctor DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::PointFunctor |
TPointPredicate DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::PointPredicate |
|
private |
PointFunctor::Value DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::Value |
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::FMM | ( | Image & | aImg, |
AcceptedPointSet & | aSet, | ||
ConstAlias< PointPredicate > | aPointPredicate ) |
Constructor.
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::FMM | ( | Image & | aImg, |
AcceptedPointSet & | aSet, | ||
ConstAlias< PointPredicate > | aPointPredicate, | ||
const Area & | aAreaThreshold, | ||
const Value & | aValueThreshold ) |
Constructor.
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::FMM | ( | Image & | aImg, |
AcceptedPointSet & | aSet, | ||
ConstAlias< PointPredicate > | aPointPredicate, | ||
PointFunctor & | aPointFunctor ) |
Constructor.
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::FMM | ( | Image & | aImg, |
AcceptedPointSet & | aSet, | ||
ConstAlias< PointPredicate > | aPointPredicate, | ||
const Area & | aAreaThreshold, | ||
const Value & | aValueThreshold, | ||
PointFunctor & | aPointFunctor ) |
Constructor.
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::~FMM | ( | ) |
Destructor.
|
private |
Copy constructor.
other | the object to clone. Forbidden by default. |
|
private |
Inserts the candidate of min distance into the set of accepted points and updates the distance values of the candidate points.
aPoint | inserted point (if true) |
aValue | distance value of the inserted point (if true) |
|
private |
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.
aPoint | any point |
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::BOOST_CONCEPT_ASSERT | ( | (concepts::CDigitalSet< TSet >) | ) |
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::BOOST_CONCEPT_ASSERT | ( | (concepts::CImage< TImage >) | ) |
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::BOOST_CONCEPT_ASSERT | ( | (concepts::CPointFunctor< TPointFunctor >) | ) |
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::BOOST_CONCEPT_ASSERT | ( | (concepts::CPointPredicate< TPointPredicate >) | ) |
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::BOOST_STATIC_ASSERT | ( | (boost::is_same< Point, typename AcceptedPointSet::Point >::value) | ) |
DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::BOOST_STATIC_ASSERT | ( | (boost::is_same< Point, typename PointPredicate::Point >::value) | ) |
void DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::compute | ( | ) |
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.
Referenced by accuracyTest(), example(), main(), testComparison(), testDisplayDT2d(), testDisplayDT3d(), and testDisplayDTFromCircle().
bool DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::computeOneStep | ( | Point & | aPoint, |
Value & | aValue ) |
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.
aPoint | inserted point (if inserted) |
aValue | its distance value (if inserted) |
Value DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::getMax | ( | ) | const |
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
Referenced by testDisplayDTFromCircle().
Value DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::getMin | ( | ) | const |
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
Referenced by testDisplayDTFromCircle().
|
private |
Initialize the set of candidate points
|
static |
Initialize aImg and aSet from the points incident to the signed cells of the range [itb , ite ). If aFlagIsPositive is 'true' (default), assign to the inner points a negative distance interpolated from the distance values of the neighbors given by the function aF and assign to the outer points a positive distance interpolated from the distance values of the neighbors given by the function aF. Swap the signs if aFlagIsPositive is 'false'.
aK | a Khalimsky space in which the signed cells live. |
itb | begin iterator (on signed cells) |
ite | end iterator (on signed cells) |
aF | any implicit function |
aImg | the distance image |
aSet | the set of points for which the distance has been assigned |
aFlagIsPositive | The flag controlling the aValue sign assigned to inner points. |
|
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 'true' (default) but aValue otherwise, and conversely for the outer points.
aK | a Khalimsky space in which the signed cells live. |
itb | begin iterator (on signed cells) |
ite | end iterator (on signed cells) |
aImg | the distance image |
aSet | the set of points for which the distance has been assigned |
aValue | distance default value |
aFlagIsPositive | The flag controlling the aValue sign assigned to inner points. |
Referenced by accuracyTest(), and main().
|
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 'true' (default) but aValue otherwise, and conversely for the outer points.
itb | begin iterator (on points) |
ite | end iterator (on points) |
aImg | the distance image |
aSet | the set of points for which the distance has been assigned |
aValue | distance default value |
aFlagIsPositive | The flag controlling the aValue sign assigned to inner points. |
Referenced by testDisplayDTFromCircle().
|
static |
Initialize aImg and aSet from the points of the range [itb , ite ) Assign a distance equal to aValue
itb | begin iterator (on points) |
ite | end iterator (on points) |
aImg | the distance image |
aSet | the set of points for which the distance has been assigned |
aValue | distance default value |
Referenced by testDisplayDTFromCircle().
bool DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::isValid | ( | ) | const |
Checks the validity/consistency of the object.
Referenced by testDisplayDT2d(), testDisplayDT3d(), and testDisplayDTFromCircle().
Value DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::max | ( | ) | const |
Maximal distance value in the set of accepted points.
Referenced by accuracyTest(), and example().
Value DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::min | ( | ) | const |
Minimal distance value in the set of accepted points.
Referenced by accuracyTest().
|
private |
Assignment.
other | the object to copy. |
void DGtal::FMM< TImage, TSet, TPointPredicate, TPointFunctor >::selfDisplay | ( | std::ostream & | out | ) | const |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
|
private |
Updates the distance values of the neighbors of aPoint belonging to the set of accepted points
aPoint | any point |
|
static |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |