DGtal 1.3.0
|
Aim: implements a model of CSeparableMetric for Chamfer and path based norms. More...
#include <DGtal/geometry/volumes/distance/ChamferNorm2D.h>
Data Structures | |
struct | LessOrEqThanAngular |
struct | LessThanAngular |
Public Types | |
typedef TSpace | Space |
Underlying Space. More... | |
typedef Space::Vector | Vector |
Type for vectors. More... | |
typedef Space::Point | Point |
Type for points. More... | |
typedef std::vector< Vector > | Directions |
Container for set of directions. More... | |
typedef Directions::const_iterator | ConstIterator |
typedef double | Value |
Value type for embedded distance evaluation. More... | |
typedef Space::Integer | RawValue |
Value type for exact distance evaluation. More... | |
typedef Vector::Component | Abscissa |
Vector components type. More... | |
Public Member Functions | |
BOOST_CONCEPT_ASSERT ((concepts::CSpace< TSpace >)) | |
BOOST_STATIC_ASSERT (TSpace::dimension==2) | |
ChamferNorm2D (const unsigned int aN) | |
ChamferNorm2D (const Directions &aDirectionSet, const Directions &aNormalDirectionSet, const Value norm=1.0) | |
~ChamferNorm2D () | |
ConstIterator | getCone (const Vector &aDirection, ConstIterator aBegin, ConstIterator aEnd) const |
ConstIterator | getCone (const Vector &aDirection) const |
Vector | getNormalFromCone (ConstIterator aCone) const |
Vector | canonicalRay (const Vector &aRay) const |
Value | operator() (const Point &P, const Point &Q) const |
RawValue | rawDistance (const Point &P, const Point &Q) const |
DGtal::Closest | closest (const Point &origin, const Point &first, const Point &second) const |
ChamferNorm2D (const ChamferNorm2D &other) | |
ChamferNorm2D< Space > & | operator= (const ChamferNorm2D< Space > &other) |
Abscissa | getLowerRayIntersection (const Vector &aP, const Vector &aQ, const Point &Lmin, const Point &Lmax, const Dimension aDimension) const |
Abscissa | getUpperRayIntersection (const Vector &aP, const Vector &aQ, const Point &Lmin, const Point &Lmax, const Dimension aDimension) const |
ConstIterator | shrinkPSubMask (ConstIterator aBegin, ConstIterator aEnd, const Point &aP, const Point &aQ, const Point &Lmin, const Point &Lmax, const Dimension aDimension, Point &midPoint, Point &nextMidPoint) const |
ConstIterator | shrinkP (ConstIterator aBegin, ConstIterator aEnd, const Point &aP, const Point &aQ, const Point &Lmin, const Point &Lmax, const Dimension aDimension, Point &midPoint, Point &nextMidPoint) const |
Abscissa | getLowerVoronoiEdgeAbscissa (const Point &u, const Point &v, const Point &startingPoint, const Point &endPoint, const Dimension dim) const |
bool | hiddenBy (const Point &u, const Point &v, const Point &w, const Point &startingPoint, const Point &endPoint, const Dimension dim) const |
ConstIterator | begin () |
ConstIterator | end () |
unsigned int | size () const |
void | selfDisplay (std::ostream &out) const |
bool | isValid () const |
Protected Member Functions | |
ChamferNorm2D () | |
Private Member Functions | |
BOOST_STATIC_CONSTANT (Abscissa, myInfinity=32562) | |
Static constant. More... | |
Private Attributes | |
Directions | myDirections |
Mask container. More... | |
Directions | myNormals |
Normal to cone container. More... | |
LessThanAngular | myLessThanAngular |
Instance of comparator functor. More... | |
Value | myNorm |
Normalization factor. More... | |
Aim: implements a model of CSeparableMetric for Chamfer and path based norms.
Description of template class 'ChamferNorm2D'
This is a proof-of-concept which implements a path-based norm (here chamfer mask) in a separable way in dimension 2. Hence, this metric can be used in all separable volumetric tools like DistanceTransformation or VoronoiMap.
The metric is constructed from a set of directions that defines a set of cones, and weights associated with each cone. Alternatively, to check the computational efficiency of the methods, user can specify a number of cones and a fake chamfer mask will be constructed.
Note that the mask must satisfy norm conditions with axis symmetric unit ball.
As discussed in [34] and in nD Volumetric Analysis using Separable Processes, we have the following properties:
TSpace | a model CSpace of dimension 2. |
Definition at line 86 of file ChamferNorm2D.h.
typedef Vector::Component DGtal::experimental::ChamferNorm2D< TSpace >::Abscissa |
Vector components type.
Definition at line 112 of file ChamferNorm2D.h.
typedef Directions::const_iterator DGtal::experimental::ChamferNorm2D< TSpace >::ConstIterator |
Definition at line 104 of file ChamferNorm2D.h.
typedef std::vector< Vector > DGtal::experimental::ChamferNorm2D< TSpace >::Directions |
Container for set of directions.
Definition at line 103 of file ChamferNorm2D.h.
typedef Space::Point DGtal::experimental::ChamferNorm2D< TSpace >::Point |
Type for points.
Definition at line 100 of file ChamferNorm2D.h.
typedef Space::Integer DGtal::experimental::ChamferNorm2D< TSpace >::RawValue |
Value type for exact distance evaluation.
Definition at line 109 of file ChamferNorm2D.h.
typedef TSpace DGtal::experimental::ChamferNorm2D< TSpace >::Space |
Underlying Space.
Definition at line 95 of file ChamferNorm2D.h.
typedef double DGtal::experimental::ChamferNorm2D< TSpace >::Value |
Value type for embedded distance evaluation.
Definition at line 107 of file ChamferNorm2D.h.
typedef Space::Vector DGtal::experimental::ChamferNorm2D< TSpace >::Vector |
Type for vectors.
Definition at line 98 of file ChamferNorm2D.h.
DGtal::experimental::ChamferNorm2D< TSpace >::ChamferNorm2D | ( | const unsigned int | aN | ) |
Constructor from a number N. Will generate a partial mask with aN directions (from Farey fractions). Weights are set to satisfy the norm condition using the 3-4-mask weights. Hence, increasing aN does not improve the metric. This constructor is just used to compute efficiency statistics when aN increases.
DGtal::experimental::ChamferNorm2D< TSpace >::ChamferNorm2D | ( | const Directions & | aDirectionSet, |
const Directions & | aNormalDirectionSet, | ||
const Value | norm = 1.0 |
||
) |
Constructor from direction and noraml vector sets.
aDirectionSet | the set of vectors of the chamfer norm mask. This set should correspond to the vectors of the chamfer mask with positive abscissa. Internally, this set will be symmetrized w.r.t. y-axis to make it complete. | |
aNormalDirectionSet | for each cone, the associated normal vector. | |
[in] | norm | the normalization factor associated with th mask (default is 1.0) |
DGtal::experimental::ChamferNorm2D< TSpace >::~ChamferNorm2D | ( | ) |
Destructor.
|
inline |
Copy constructor.
other | the object to clone. |
Definition at line 290 of file ChamferNorm2D.h.
References DGtal::experimental::ChamferNorm2D< TSpace >::myDirections, and DGtal::experimental::ChamferNorm2D< TSpace >::myNormals.
|
protected |
Constructor. Forbidden by default (protected to avoid g++ warnings).
|
inline |
Definition at line 466 of file ChamferNorm2D.h.
References DGtal::experimental::ChamferNorm2D< TSpace >::myDirections.
Referenced by testChamferSimple().
DGtal::experimental::ChamferNorm2D< TSpace >::BOOST_CONCEPT_ASSERT | ( | (concepts::CSpace< TSpace >) | ) |
DGtal::experimental::ChamferNorm2D< TSpace >::BOOST_STATIC_ASSERT | ( | TSpace::dimension | = =2 | ) |
|
private |
Static constant.
Vector DGtal::experimental::ChamferNorm2D< TSpace >::canonicalRay | ( | const Vector & | aRay | ) | const |
Return the canonical ray for a given ray.
This method construct a vector in the first quadrant corresponding to aRay.
Referenced by testChamferSimple().
|
inline |
Given an origin and two points, this method decides which one is closest to the origin. This method should be faster than comparing distance values.
origin | the origin |
first | the first point |
second | the second point |
Definition at line 271 of file ChamferNorm2D.h.
References DGtal::ClosestBOTH, DGtal::ClosestFIRST, DGtal::ClosestSECOND, and DGtal::experimental::ChamferNorm2D< TSpace >::operator()().
|
inline |
Definition at line 474 of file ChamferNorm2D.h.
References DGtal::experimental::ChamferNorm2D< TSpace >::myDirections.
Referenced by testChamferSimple().
|
inline |
Returns the cone associated to a direction (iterator it) in the whole mask.
The cone is given by [it, it+1):
(*it) <= aDirection < (*(it+1)) (For the angular comparator).
aDirection | the direction to probe |
Definition at line 213 of file ChamferNorm2D.h.
References DGtal::experimental::ChamferNorm2D< TSpace >::getCone(), and DGtal::experimental::ChamferNorm2D< TSpace >::myDirections.
ConstIterator DGtal::experimental::ChamferNorm2D< TSpace >::getCone | ( | const Vector & | aDirection, |
ConstIterator | aBegin, | ||
ConstIterator | aEnd | ||
) | const |
Returns the cone associated to a direction (iterator it) in the range [aBegin, eEnd).
The cone is given by [it, it+1):
(*it) <= aDirection < (*(it+1)) (For the angular comparator).
[in] | aDirection | the direction to probe |
[in] | aBegin | the begin of the range in which the search is performed. |
[in] | aEnd | the end of the range in which the search is performed. |
Referenced by DGtal::experimental::ChamferNorm2D< TSpace >::getCone(), testBasicMasks(), and testChamferSimple().
Abscissa DGtal::experimental::ChamferNorm2D< TSpace >::getLowerRayIntersection | ( | const Vector & | aP, |
const Vector & | aQ, | ||
const Point & | Lmin, | ||
const Point & | Lmax, | ||
const Dimension | aDimension | ||
) | const |
Compute the intersection between (aP,aQ) and (Lmin, Lmax). More precisely, if we suppose that
this method returns the lower rounding abscissa of the rational intersection point.
aP | first extremity point |
aQ | second extremity point |
Lmin | first extremity point of the L segment |
Lmax | second extremity point of the L segment |
aDimension | a dimension |
Abscissa DGtal::experimental::ChamferNorm2D< TSpace >::getLowerVoronoiEdgeAbscissa | ( | const Point & | u, |
const Point & | v, | ||
const Point & | startingPoint, | ||
const Point & | endPoint, | ||
const Dimension | dim | ||
) | const |
Returns the lower abscissa of the Voronoi edge between u and v along the span (startingPoint,endPoint).
u | a site |
v | a site |
startingPoint | starting point of the segment |
endPoint | end point of the segment |
dim | direction of the straight line |
Vector DGtal::experimental::ChamferNorm2D< TSpace >::getNormalFromCone | ( | ConstIterator | aCone | ) | const |
aCone | the input cone |
Referenced by testChamferSimple().
Abscissa DGtal::experimental::ChamferNorm2D< TSpace >::getUpperRayIntersection | ( | const Vector & | aP, |
const Vector & | aQ, | ||
const Point & | Lmin, | ||
const Point & | Lmax, | ||
const Dimension | aDimension | ||
) | const |
Compute the intersection between (aP,aQ) and (Lmin, Lmax). More precisely, if we suppose that
this method returns the upper rounding abscissa of the rational intersection point.
aP | first extremity point |
aQ | second extremity point |
Lmin | first extremity point of the L segment |
Lmax | second extremity point of the L segment |
aDimension | a dimension |
bool DGtal::experimental::ChamferNorm2D< TSpace >::hiddenBy | ( | const Point & | u, |
const Point & | v, | ||
const Point & | w, | ||
const Point & | startingPoint, | ||
const Point & | endPoint, | ||
const Dimension | dim | ||
) | const |
The main hiddenBy predicate. (in \( O(log^2(n))\)).
u | a site |
v | a site |
w | a site |
startingPoint | starting point of the segment |
endPoint | end point of the segment |
dim | direction of the straight line |
bool DGtal::experimental::ChamferNorm2D< TSpace >::isValid | ( | ) | const |
Checks the validity/consistency of the object.
Value DGtal::experimental::ChamferNorm2D< TSpace >::operator() | ( | const Point & | P, |
const Point & | Q | ||
) | const |
Returns the distance for the chamfer norm between P and Q.
P | a point |
Q | a point |
Referenced by DGtal::experimental::ChamferNorm2D< TSpace >::closest().
|
inline |
Assignment.
other | the object to copy. |
Definition at line 302 of file ChamferNorm2D.h.
References DGtal::experimental::ChamferNorm2D< TSpace >::myDirections, and DGtal::experimental::ChamferNorm2D< TSpace >::myNormals.
RawValue DGtal::experimental::ChamferNorm2D< TSpace >::rawDistance | ( | const Point & | P, |
const Point & | Q | ||
) | const |
Returns the raw distance for the chamfer norm between P and Q. For chamfer norm, it corresponds to un-normalized distance value.
P | a point |
Q | a point |
void DGtal::experimental::ChamferNorm2D< TSpace >::selfDisplay | ( | std::ostream & | out | ) | const |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
ConstIterator DGtal::experimental::ChamferNorm2D< TSpace >::shrinkP | ( | ConstIterator | aBegin, |
ConstIterator | aEnd, | ||
const Point & | aP, | ||
const Point & | aQ, | ||
const Point & | Lmin, | ||
const Point & | Lmax, | ||
const Dimension | aDimension, | ||
Point & | midPoint, | ||
Point & | nextMidPoint | ||
) | const |
This method returns the cone (ConstIterator, ConstIterator+1) at P which contains
[in] | aBegin | begin iterator on the current set of directions at P |
[in] | aEnd | end iterator on the current set of directions at P |
[in] | aP | center of the ball we are shrinking |
[in] | aQ | center of the second ball |
[in] | Lmin | first extremity point of the L segment |
[in] | Lmax | first extremity point of the L segment |
[in] | aDimension | direction of the (Lmin,LMax segment) |
[out] | midPoint | the point, on the segment, corresponding to the intersection of the the first cone direction and the segment |
[out] | nextMidPoint | the point, on the segment, corresponding to the intersection of the second cone direction and the segment |
ConstIterator DGtal::experimental::ChamferNorm2D< TSpace >::shrinkPSubMask | ( | ConstIterator | aBegin, |
ConstIterator | aEnd, | ||
const Point & | aP, | ||
const Point & | aQ, | ||
const Point & | Lmin, | ||
const Point & | Lmax, | ||
const Dimension | aDimension, | ||
Point & | midPoint, | ||
Point & | nextMidPoint | ||
) | const |
Considering a vertical configuration (aDimension == 1, P[!dimension]<= Lmin[!dimension]), This method returns the cone (ConstIterator, ConstIterator+1) at P which contains the Voronoi Edge of P and Q.
This method runs in O(log^2(n)), n being the number of directions in the mask.
[in] | aBegin | begin iterator on the current set of directions at P |
[in] | aEnd | end iterator on the current set of directions at P |
[in] | aP | center of the ball we are shrinking |
[in] | aQ | center of the second ball |
[in] | Lmin | first extremity point of the L segment |
[in] | Lmax | first extremity point of the L segment |
[in] | aDimension | direction of the (Lmin,LMax segment) |
[out] | midPoint | the point, on the segment, corresponding to the intersection of the the first cone direction and the segment |
[out] | nextMidPoint | the point, on the segment, corresponding to the intersection of the second cone direction and the segment |
|
inline |
Definition at line 483 of file ChamferNorm2D.h.
References DGtal::experimental::ChamferNorm2D< TSpace >::myDirections.
|
private |
Mask container.
Definition at line 515 of file ChamferNorm2D.h.
Referenced by DGtal::experimental::ChamferNorm2D< TSpace >::begin(), DGtal::experimental::ChamferNorm2D< TSpace >::ChamferNorm2D(), DGtal::experimental::ChamferNorm2D< TSpace >::end(), DGtal::experimental::ChamferNorm2D< TSpace >::getCone(), DGtal::experimental::ChamferNorm2D< TSpace >::operator=(), and DGtal::experimental::ChamferNorm2D< TSpace >::size().
|
private |
Instance of comparator functor.
Definition at line 521 of file ChamferNorm2D.h.
|
private |
Normalization factor.
Definition at line 527 of file ChamferNorm2D.h.
|
private |
Normal to cone container.
Definition at line 518 of file ChamferNorm2D.h.
Referenced by DGtal::experimental::ChamferNorm2D< TSpace >::ChamferNorm2D(), and DGtal::experimental::ChamferNorm2D< TSpace >::operator=().