DGtal 1.4.0
|
Aim: Implementation of the linear in time Voronoi map construction. More...
#include <DGtal/geometry/volumes/distance/VoronoiMap.h>
Public Types | |
typedef TSpace | Space |
Copy of the space type. | |
typedef TPointPredicate | PointPredicate |
Copy of the point predicate type. | |
typedef TImageContainer::Domain | Domain |
Definition of the underlying domain type. | |
typedef TSeparableMetric | SeparableMetric |
Definition of the separable metric type. | |
typedef DGtal::int64_t | IntegerLong |
Large integer type for SeparableMetricHelper construction. | |
typedef Space::Vector | Vector |
typedef Space::Point | Point |
typedef Space::Dimension | Dimension |
typedef Space::Size | Size |
typedef Space::Point::Coordinate | Abscissa |
typedef TImageContainer | OutputImage |
Type of resulting image. | |
typedef Vector | Value |
Definition of the image value type. | |
typedef OutputImage::ConstRange | ConstRange |
Definition of the image value type. | |
typedef VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer > | Self |
Self type. | |
typedef std::array< bool, Space::dimension > | PeriodicitySpec |
Periodicity specification type. | |
Public Member Functions | |
BOOST_CONCEPT_ASSERT ((concepts::CSpace< TSpace >)) | |
BOOST_CONCEPT_ASSERT ((concepts::CPointPredicate< TPointPredicate >)) | |
BOOST_CONCEPT_ASSERT ((concepts::CSeparableMetric< TSeparableMetric >)) | |
BOOST_CONCEPT_ASSERT ((concepts::CImage< TImageContainer >)) | |
BOOST_STATIC_ASSERT ((boost::is_same< typename TSpace::Point, typename TPointPredicate::Point >::value)) | |
Both Space points and PointPredicate points must be the same. | |
BOOST_STATIC_ASSERT ((boost::is_same< TSpace, typename TImageContainer::Domain::Space >::value)) | |
BOOST_STATIC_ASSERT ((boost::is_same< typename TSpace::Vector, typename TImageContainer::Value >::value)) | |
BOOST_STATIC_ASSERT ((boost::is_same< HyperRectDomain< TSpace >, typename TImageContainer::Domain >::value)) | |
VoronoiMap (ConstAlias< Domain > aDomain, ConstAlias< PointPredicate > predicate, ConstAlias< SeparableMetric > aMetric) | |
VoronoiMap (ConstAlias< Domain > aDomain, ConstAlias< PointPredicate > predicate, ConstAlias< SeparableMetric > aMetric, PeriodicitySpec const &aPeriodicitySpec) | |
~VoronoiMap ()=default | |
VoronoiMap ()=delete | |
Self & | operator= (const Self &aOtherVoronoiMap)=default |
const Domain & | domain () const |
ConstRange | constRange () const |
Value | operator() (const Point &aPoint) const |
const SeparableMetric * | metric () const |
PeriodicitySpec const & | getPeriodicitySpec () const |
bool | isPeriodic (const Dimension n) const |
Point | projectPoint (Point aPoint) const |
void | selfDisplay (std::ostream &out) const |
Protected Attributes | |
const SeparableMetric * | myMetricPtr |
Pointer to the separable metric instance. | |
CountedPtr< OutputImage > | myImagePtr |
Voronoi map image. | |
PeriodicitySpec | myPeriodicitySpec |
Periodicity along each dimension. | |
Private Member Functions | |
void | compute () |
void | computeOtherSteps (const Dimension dim) const |
void | computeOtherStep1D (const Point &row, const Dimension dim) const |
Point::Coordinate | projectCoordinate (typename Point::Coordinate aCoordinate, const Dimension aDim) const |
Private Attributes | |
const Domain * | myDomainPtr |
Pointer to the computation domain. | |
const PointPredicate * | myPointPredicatePtr |
Pointer to the point predicate. | |
Point | myLowerBoundCopy |
Copy of the image lower bound. | |
Point | myUpperBoundCopy |
Copy of the image lower bound. | |
Point | myInfinity |
Value to act as a +infinity value. | |
std::vector< Dimension > | myPeriodicityIndex |
Index of the periodic dimensions. | |
Point | myDomainExtent |
Domain extent. | |
Aim: Implementation of the linear in time Voronoi map construction.
Description of template class 'VoronoiMap'
The algorithm uses a seperable process to construct Voronoi maps which has been described in [85] [33]. Along periodic dimensions, the algorithm is adapted following [34].
Given a domain and a point predicate, an instance returns, for each point in the domain, the closest point for which the predicate is false. Following Computational Geometry terminology, points for which the predicate is false are "sites" for the Voronoi map construction. If a point is equi-distant to two sites (e.g. if the digital point belong to a Voronoi cell boundary in the Euclidean space), this Voronoi map construction will only keep one of them.
By default, the domain is considered non-periodic but per-dimension periodicity can be specified in the constructor. When the domain has periodic dimensions, the closest point coordinates B
to a given point A
may not be between the lower and upper bounds of the domain, in such a way that the non-periodic distance between A
and B
is equal to their distance considering the periodicity.
The metric is specified by a model of concepts::CSeparableMetric (for instance, any instance of ExactPredicateLpSeparableMetric or InexactPredicateLpSeparableMetric). If the separable metric has a complexity of O(h) for its "hiddenBy" predicate, the overall Voronoi construction algorithm is in \( O(h.d.n^d)\) for \( n^d\) domains (see class constructor). For Euclidean the \( l_2\) metric, the overall computation is in \( O(d.n^d)\), which is optimal.
If DGtal has been built with OpenMP support (WITH_OPENMP flag set to "true"), the computation is done in parallel (multithreaded) in an optimal way: on p processors, expected runtime is in \( O(h.d.n^d / p)\).
This class is a model of concepts::CConstImage.
TSpace | type of Digital Space (model of concepts::CSpace). |
TPointPredicate | point predicate returning true for points from which we compute the distance (model of concepts::CPointPredicate) |
TSeparableMetric | a model of concepts::CSeparableMetric |
TImageContainer | any model of concepts::CImage to store the VoronoiMap (default: ImageContainerBySTLVector). The space of the image container and the TSpace should match. Furthermore the container value type must be TSpace::Vector. Lastly, the domain of the container must be HyperRectDomain. |
Definition at line 126 of file VoronoiMap.h.
typedef Space::Point::Coordinate DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Abscissa |
Definition at line 170 of file VoronoiMap.h.
typedef OutputImage::ConstRange DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::ConstRange |
Definition of the image value type.
Definition at line 179 of file VoronoiMap.h.
typedef Space::Dimension DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Dimension |
Definition at line 168 of file VoronoiMap.h.
typedef TImageContainer::Domain DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Domain |
Definition of the underlying domain type.
Definition at line 158 of file VoronoiMap.h.
typedef DGtal::int64_t DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::IntegerLong |
Large integer type for SeparableMetricHelper construction.
Definition at line 164 of file VoronoiMap.h.
typedef TImageContainer DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::OutputImage |
Type of resulting image.
Definition at line 173 of file VoronoiMap.h.
typedef std::array< bool, Space::dimension > DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::PeriodicitySpec |
Periodicity specification type.
Definition at line 187 of file VoronoiMap.h.
typedef Space::Point DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Point |
Definition at line 167 of file VoronoiMap.h.
typedef TPointPredicate DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::PointPredicate |
Copy of the point predicate type.
Definition at line 155 of file VoronoiMap.h.
typedef VoronoiMap< TSpace, TPointPredicate, TSeparableMetric,TImageContainer > DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Self |
Self type.
Definition at line 183 of file VoronoiMap.h.
typedef TSeparableMetric DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::SeparableMetric |
Definition of the separable metric type.
Definition at line 161 of file VoronoiMap.h.
typedef Space::Size DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Size |
Definition at line 169 of file VoronoiMap.h.
typedef TSpace DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Space |
Copy of the space type.
Definition at line 152 of file VoronoiMap.h.
typedef Vector DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Value |
Definition of the image value type.
Definition at line 176 of file VoronoiMap.h.
typedef Space::Vector DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::Vector |
Definition at line 166 of file VoronoiMap.h.
DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::VoronoiMap | ( | ConstAlias< Domain > | aDomain, |
ConstAlias< PointPredicate > | predicate, | ||
ConstAlias< SeparableMetric > | aMetric ) |
Constructor in the non-periodic case.
This constructor computes the Voronoi Map of a set of point sites using a SeparableMetric metric, on a non-periodic domain.
The method associates to each point satisfying the foreground predicate, the closest site for which the predicate is false. This algorithm is \( O(h.d.|domain size|)\) if the separable metric "hiddenBy" predicate is in \( O(h)\).
aDomain | a pointer to the (hyper-rectangular) domain on which the computation is performed. |
predicate | a pointer to the point predicate to define the Voronoi sites (false points). |
aMetric | a pointer to the separable metric instance. |
DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::VoronoiMap | ( | ConstAlias< Domain > | aDomain, |
ConstAlias< PointPredicate > | predicate, | ||
ConstAlias< SeparableMetric > | aMetric, | ||
PeriodicitySpec const & | aPeriodicitySpec ) |
Constructor with periodicity specification.
This constructor computes the Voronoi Map of a set of point sites using a SeparableMetric metric, on a domain with specified periodicity.
The method associates to each point satisfying the foreground predicate, the closest site for which the predicate is false. This algorithm is \( O(h.d.|domain size|)\) if the separable metric "hiddenBy" predicate is in \( O(h)\).
aDomain | a pointer to the (hyper-rectangular) domain on which the computation is performed. |
predicate | a pointer to the point predicate to define the Voronoi sites (false points). |
aMetric | a pointer to the separable metric instance. |
aPeriodicitySpec | an array of size equal to the space dimension where the i-th value is true if the i-th dimension of the space is periodic, false otherwise. |
|
default |
Default destructor
|
delete |
Disabling default constructor.
DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::BOOST_CONCEPT_ASSERT | ( | (concepts::CImage< TImageContainer >) | ) |
DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::BOOST_CONCEPT_ASSERT | ( | (concepts::CPointPredicate< TPointPredicate >) | ) |
DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::BOOST_CONCEPT_ASSERT | ( | (concepts::CSeparableMetric< TSeparableMetric >) | ) |
DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::BOOST_CONCEPT_ASSERT | ( | (concepts::CSpace< TSpace >) | ) |
DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::BOOST_STATIC_ASSERT | ( | (boost::is_same< HyperRectDomain< TSpace >, typename TImageContainer::Domain >::value) | ) |
DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::BOOST_STATIC_ASSERT | ( | (boost::is_same< TSpace, typename TImageContainer::Domain::Space >::value) | ) |
DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::BOOST_STATIC_ASSERT | ( | (boost::is_same< typename TSpace::Point, typename TPointPredicate::Point >::value) | ) |
Both Space points and PointPredicate points must be the same.
DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::BOOST_STATIC_ASSERT | ( | (boost::is_same< typename TSpace::Vector, typename TImageContainer::Value >::value) | ) |
|
private |
Compute the Voronoi Map of a set of point sites using a SeparableMetric metric. The method associates to each point satisfying the foreground predicate, the closest site for which the predicate is false. This algorithm is O(h.d.|domain size|).
|
private |
Given a voronoi map valid at dimension dim-1, this method updates the map to make it consistent at dimension dim along the 1D span starting at row along the dimension dim.
[in] | row | starting point of the 1D process. |
[in] | dim | dimension of the update. |
|
private |
Compute the other steps of the separable Voronoi map.
[in] | dim | the dimension to process |
|
inline |
Returns a const range on the Voronoi map values.
Definition at line 274 of file VoronoiMap.h.
References DGtal::ImageContainerBySTLVector< TDomain, TValue >::constRange(), and DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::myImagePtr.
|
inline |
Returns a reference (const) to the Voronoi map domain.
Definition at line 265 of file VoronoiMap.h.
References DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::myDomainPtr.
Referenced by DGtal::DistanceTransformation< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::domain().
|
inline |
Periodicity specification.
Definition at line 302 of file VoronoiMap.h.
References DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::myPeriodicitySpec.
|
inline |
Periodicity specification along one dimensions.
[in] | n | the dimension index. |
true
if the n-th dimension is periodic, false
otherwise. Definition at line 312 of file VoronoiMap.h.
References DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::myPeriodicitySpec.
|
inline |
Definition at line 293 of file VoronoiMap.h.
References DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::myMetricPtr.
Referenced by DGtal::DistanceTransformation< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::metric().
|
inline |
Access to a Voronoi value (a.k.a. vector to the closest site) at a point.
aPoint | the point to probe. |
Definition at line 285 of file VoronoiMap.h.
References aPoint(), and DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::myImagePtr.
|
default |
Assignment operator from another Voronoi map.
aOtherVoronoiMap | another instance of Self |
|
private |
Project a coordinate into the domain, taking into account the periodicity.
aCoordinate | the coordinate. |
aDim | dimension of the coordinate. |
Point DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::projectPoint | ( | Point | aPoint | ) | const |
Project point coordinates into the domain, taking into account the periodicity.
aPoint | the point to project |
void DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::selfDisplay | ( | std::ostream & | out | ) | const |
Self Display method.
out | output stream |
Referenced by DGtal::DistanceTransformation< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::selfDisplay().
|
private |
Domain extent.
Definition at line 401 of file VoronoiMap.h.
|
private |
Pointer to the computation domain.
Definition at line 383 of file VoronoiMap.h.
Referenced by DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::domain().
|
protected |
Voronoi map image.
Definition at line 409 of file VoronoiMap.h.
Referenced by DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::constRange(), DGtal::DistanceTransformation< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::getVoronoiSite(), DGtal::DistanceTransformation< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::operator()(), and DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::operator()().
|
private |
Value to act as a +infinity value.
Definition at line 395 of file VoronoiMap.h.
|
private |
Copy of the image lower bound.
Definition at line 389 of file VoronoiMap.h.
|
protected |
Pointer to the separable metric instance.
Definition at line 406 of file VoronoiMap.h.
Referenced by DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::metric(), and DGtal::DistanceTransformation< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::operator()().
|
private |
Index of the periodic dimensions.
Definition at line 398 of file VoronoiMap.h.
|
protected |
Periodicity along each dimension.
Definition at line 412 of file VoronoiMap.h.
Referenced by DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::getPeriodicitySpec(), and DGtal::VoronoiMap< TSpace, TPointPredicate, TSeparableMetric, TImageContainer >::isPeriodic().
|
private |
Pointer to the point predicate.
Definition at line 386 of file VoronoiMap.h.
|
private |
Copy of the image lower bound.
Definition at line 392 of file VoronoiMap.h.