DGtal 1.3.0
|
Aim: implements an accumulator (as histograms for 1D scalars) adapted to spherical point samples. More...
#include <DGtal/geometry/tools/SphericalAccumulator.h>
Public Types | |
typedef TVector | Vector |
Vector direction types. More... | |
typedef DGtal::int32_t | Quantity |
Type to store the bin counts. More... | |
typedef size_t | Size |
Type to represent bin indexes. More... | |
typedef std::vector< Quantity >::const_iterator | ConstIterator |
Type to iterate on bin values. More... | |
typedef PointVector< 3, double > | RealVector |
Type to represent normalized vector (internal use). More... | |
Public Member Functions | |
BOOST_STATIC_ASSERT (Vector::dimension==3) | |
SphericalAccumulator (const Size aNphi) | |
~SphericalAccumulator () | |
void | addDirection (const Vector &aDir) |
void | binCoordinates (const Vector &aDir, Size &posPhi, Size &posTheta) const |
Quantity | count (const Size &posPhi, const Size &posTheta) const |
Vector | representativeDirection (const Size &posPhi, const Size &posTheta) const |
Vector | representativeDirection (ConstIterator &it) const |
Quantity | samples () const |
Quantity | binNumber () const |
void | maxCountBin (Size &posPhi, Size &posTheta) const |
void | clear () |
void | selfDisplay (std::ostream &out) const |
bool | isValid () const |
std::string | className () const |
bool | isValidBin (const Size &posPhi, const Size &posTheta) const |
void | getBinGeometry (const Size &posPhi, const Size &posTheta, RealVector &a, RealVector &b, RealVector &c, RealVector &d) const |
RealVector | getBinDirection (const Size &posPhi, const Size &posTheta) const |
ConstIterator | begin () const |
ConstIterator | end () const |
void | binCoordinates (ConstIterator &aDir, Size &posPhi, Size &posTheta) const |
SphericalAccumulator (const SphericalAccumulator &other) | |
SphericalAccumulator & | operator= (const SphericalAccumulator &other) |
Protected Member Functions | |
SphericalAccumulator () | |
Private Attributes | |
Size | myNphi |
Number of slices in the phi direction. More... | |
Size | myNtheta |
Number of bins in the theta direction. More... | |
std::vector< Quantity > | myAccumulator |
Accumulator container. More... | |
std::vector< Vector > | myAccumulatorDir |
Accumulator reprensentative directions. More... | |
Quantity | myTotal |
Number of samples. More... | |
Quantity | myBinNumber |
Number of bins. More... | |
Size | myMaxBinPhi |
Phi coordinate of the max bin. More... | |
Size | myMaxBinTheta |
Theta coordinate of the max bin. More... | |
Aim: implements an accumulator (as histograms for 1D scalars) adapted to spherical point samples.
Description of template class 'SphericalAccumulator'
Spherical accumulator is decomposed into 2D bins (i,j) such that:
Compared to exact geodesic covering, such spherical accumulator bins do not have the exact same area. However, it allows fast conversion between directions and bin coordinates.
Such accumulator have been demonstrated in: Borrmann, D., Elseberg, J., & Lingemann, K. (2011). The 3D Hough Transform for plane detection in point clouds: A review and a new accumulator design. 3D Research, 02003. Retrieved from http://www.springerlink.com/index/N1W040850782VR85.pdf
Usage example:
Once the accumulator is filled up with directions, you can get the representative direction for each bin and the bin with maximal number of samples.
Furthermore, you can send the accumulator to a Viewer3D to see the bin geometry and values:
TVector | type used to represent directions. |
Definition at line 102 of file SphericalAccumulator.h.
typedef std::vector<Quantity>::const_iterator DGtal::SphericalAccumulator< TVector >::ConstIterator |
Type to iterate on bin values.
Definition at line 117 of file SphericalAccumulator.h.
typedef DGtal::int32_t DGtal::SphericalAccumulator< TVector >::Quantity |
Type to store the bin counts.
Definition at line 111 of file SphericalAccumulator.h.
typedef PointVector<3,double> DGtal::SphericalAccumulator< TVector >::RealVector |
Type to represent normalized vector (internal use).
Definition at line 120 of file SphericalAccumulator.h.
typedef size_t DGtal::SphericalAccumulator< TVector >::Size |
Type to represent bin indexes.
Definition at line 114 of file SphericalAccumulator.h.
typedef TVector DGtal::SphericalAccumulator< TVector >::Vector |
Vector direction types.
Definition at line 108 of file SphericalAccumulator.h.
DGtal::SphericalAccumulator< TVector >::SphericalAccumulator | ( | const Size | aNphi | ) |
Constructs a spherical accumulator with aNphi slices along latitudes (phi spherial coordinate). The decomposition along the theta axis is also a function of aNphi.
aNphi | the number of slices in the longitude polar coordinates. |
DGtal::SphericalAccumulator< TVector >::~SphericalAccumulator | ( | ) |
Destructor.
|
inline |
Copy constructor.
other | the object to clone. |
Definition at line 338 of file SphericalAccumulator.h.
References DGtal::SphericalAccumulator< TVector >::myAccumulator, DGtal::SphericalAccumulator< TVector >::myAccumulatorDir, DGtal::SphericalAccumulator< TVector >::myBinNumber, DGtal::SphericalAccumulator< TVector >::myMaxBinPhi, DGtal::SphericalAccumulator< TVector >::myMaxBinTheta, DGtal::SphericalAccumulator< TVector >::myNphi, DGtal::SphericalAccumulator< TVector >::myNtheta, and DGtal::SphericalAccumulator< TVector >::myTotal.
|
protected |
Constructor. Forbidden by default (protected to avoid g++ warnings).
void DGtal::SphericalAccumulator< TVector >::addDirection | ( | const Vector & | aDir | ) |
Add a new direction into the accumulator. The accumulator updates the bin coordinates with maximum count.
aDir | a direction |
Referenced by testSphericalAccumulator(), testSphericalMore(), and testSphericalMoreIntegerDir().
|
inline |
Definition at line 308 of file SphericalAccumulator.h.
References DGtal::SphericalAccumulator< TVector >::myAccumulator.
Referenced by testSphericalAccumulator(), testSphericalMore(), and testSphericalMoreIntegerDir().
void DGtal::SphericalAccumulator< TVector >::binCoordinates | ( | const Vector & | aDir, |
Size & | posPhi, | ||
Size & | posTheta | ||
) | const |
Given a normalized direction, this method computes the bin coordinates.
aDir | a direction represented as a unit norm vector. |
posPhi | position according to the first direction. |
posTheta | position according to the second direction. |
Referenced by testSphericalAccumulator().
void DGtal::SphericalAccumulator< TVector >::binCoordinates | ( | ConstIterator & | aDir, |
Size & | posPhi, | ||
Size & | posTheta | ||
) | const |
Given an iterator on the bin container, this method computes the bin coordinates.
aDir | an iterator to the bin container. |
posPhi | position according to the first direction. |
posTheta | position according to the second direction. |
|
inline |
Definition at line 217 of file SphericalAccumulator.h.
References DGtal::SphericalAccumulator< TVector >::myBinNumber.
DGtal::SphericalAccumulator< TVector >::BOOST_STATIC_ASSERT | ( | Vector::dimension | = =3 | ) |
|
inline |
Definition at line 252 of file SphericalAccumulator.h.
void DGtal::SphericalAccumulator< TVector >::clear | ( | ) |
Clear the current accumulator.
Referenced by testSphericalAccumulator().
Quantity DGtal::SphericalAccumulator< TVector >::count | ( | const Size & | posPhi, |
const Size & | posTheta | ||
) | const |
Returns the current number of samples in the bin (posPhi,posTheta).
posPhi | position according to the first direction |
posTheta | position according to the second direction |
Referenced by testSphericalAccumulator().
|
inline |
Definition at line 316 of file SphericalAccumulator.h.
References DGtal::SphericalAccumulator< TVector >::myAccumulator.
Referenced by testSphericalAccumulator(), testSphericalMore(), and testSphericalMoreIntegerDir().
RealVector DGtal::SphericalAccumulator< TVector >::getBinDirection | ( | const Size & | posPhi, |
const Size & | posTheta | ||
) | const |
From the bin index(posPhi,posTheta), we compute the main direction (quad geometry midpoint).
posPhi | bin index along the first direction. |
posTheta | bin index along the second direction. |
void DGtal::SphericalAccumulator< TVector >::getBinGeometry | ( | const Size & | posPhi, |
const Size & | posTheta, | ||
RealVector & | a, | ||
RealVector & | b, | ||
RealVector & | c, | ||
RealVector & | d | ||
) | const |
From the bin index(posPhi,posTheta), we compute the associated spherical quad (a,b,c,d) counterclockwise on the unit sphere.
posPhi | bin index along the first direction. |
posTheta | bin index along the second direction. |
a | vertex position. |
b | vertex position. |
c | vertex position. |
d | vertex position. |
bool DGtal::SphericalAccumulator< TVector >::isValid | ( | ) | const |
Checks the validity/consistency of the object.
bool DGtal::SphericalAccumulator< TVector >::isValidBin | ( | const Size & | posPhi, |
const Size & | posTheta | ||
) | const |
Returns true if is bin (posPhi,posTheta) is valid.
posPhi | posPhi index |
posTheta | posTheta index |
void DGtal::SphericalAccumulator< TVector >::maxCountBin | ( | Size & | posPhi, |
Size & | posTheta | ||
) | const |
Returns the coordinates of the bin containing the maximum number of samples.
posPhi | coordinate along the phi axis. |
posTheta | coordinate along the theta axis. |
Referenced by testSphericalMoreIntegerDir().
|
inline |
Assignment.
other | the object to copy. |
Definition at line 356 of file SphericalAccumulator.h.
References DGtal::SphericalAccumulator< TVector >::myAccumulator, DGtal::SphericalAccumulator< TVector >::myAccumulatorDir, DGtal::SphericalAccumulator< TVector >::myBinNumber, DGtal::SphericalAccumulator< TVector >::myMaxBinPhi, DGtal::SphericalAccumulator< TVector >::myMaxBinTheta, DGtal::SphericalAccumulator< TVector >::myNphi, DGtal::SphericalAccumulator< TVector >::myNtheta, and DGtal::SphericalAccumulator< TVector >::myTotal.
Vector DGtal::SphericalAccumulator< TVector >::representativeDirection | ( | const Size & | posPhi, |
const Size & | posTheta | ||
) | const |
Returns the representative direction associated with the bin (posPhi,posTheta). If the bin does not contain any sample, a null vector is returned ( Vector::ZERO ).
Otherwise, it returns the (unnormalized) sum of directions added to the bin.
posPhi | position according to the first direction |
posTheta | position according to the second direction |
Referenced by testSphericalAccumulator(), and testSphericalMoreIntegerDir().
Vector DGtal::SphericalAccumulator< TVector >::representativeDirection | ( | ConstIterator & | it | ) | const |
Get the representative direction of a bin specified by a ConstIterator.
it | the iterator on the bin to get the direction |
Quantity DGtal::SphericalAccumulator< TVector >::samples | ( | ) | const |
Referenced by testSphericalAccumulator().
void DGtal::SphericalAccumulator< TVector >::selfDisplay | ( | std::ostream & | out | ) | const |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
|
private |
Accumulator container.
Definition at line 384 of file SphericalAccumulator.h.
Referenced by DGtal::SphericalAccumulator< TVector >::begin(), DGtal::SphericalAccumulator< TVector >::end(), DGtal::SphericalAccumulator< TVector >::operator=(), and DGtal::SphericalAccumulator< TVector >::SphericalAccumulator().
|
private |
Accumulator reprensentative directions.
Definition at line 387 of file SphericalAccumulator.h.
Referenced by DGtal::SphericalAccumulator< TVector >::operator=(), and DGtal::SphericalAccumulator< TVector >::SphericalAccumulator().
|
private |
Number of bins.
Definition at line 393 of file SphericalAccumulator.h.
Referenced by DGtal::SphericalAccumulator< TVector >::binNumber(), DGtal::SphericalAccumulator< TVector >::operator=(), and DGtal::SphericalAccumulator< TVector >::SphericalAccumulator().
|
private |
Phi coordinate of the max bin.
Definition at line 396 of file SphericalAccumulator.h.
Referenced by DGtal::SphericalAccumulator< TVector >::operator=(), and DGtal::SphericalAccumulator< TVector >::SphericalAccumulator().
|
private |
Theta coordinate of the max bin.
Definition at line 399 of file SphericalAccumulator.h.
Referenced by DGtal::SphericalAccumulator< TVector >::operator=(), and DGtal::SphericalAccumulator< TVector >::SphericalAccumulator().
|
private |
Number of slices in the phi direction.
Definition at line 378 of file SphericalAccumulator.h.
Referenced by DGtal::SphericalAccumulator< TVector >::operator=(), and DGtal::SphericalAccumulator< TVector >::SphericalAccumulator().
|
private |
Number of bins in the theta direction.
Definition at line 381 of file SphericalAccumulator.h.
Referenced by DGtal::SphericalAccumulator< TVector >::operator=(), and DGtal::SphericalAccumulator< TVector >::SphericalAccumulator().
|
private |
Number of samples.
Definition at line 390 of file SphericalAccumulator.h.
Referenced by DGtal::SphericalAccumulator< TVector >::operator=(), and DGtal::SphericalAccumulator< TVector >::SphericalAccumulator().