DGtal  0.9.3beta
Public Types | Public Member Functions | Protected Member Functions | Private Attributes
DGtal::SphericalAccumulator< TVector > Class Template Reference

#include <DGtal/geometry/tools/SphericalAccumulator.h>

Inheritance diagram for DGtal::SphericalAccumulator< TVector >:
[legend]
Collaboration diagram for DGtal::SphericalAccumulator< TVector >:
[legend]

Public Types

typedef TVector Vector
 
typedef DGtal::int32_t Quantity
 
typedef DGtal::uint32_t Size
 
typedef std::vector< Quantity >::const_iterator ConstIterator
 
typedef PointVector< 3, double > RealVector
 

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)
 
SphericalAccumulatoroperator= (const SphericalAccumulator &other)
 

Protected Member Functions

 SphericalAccumulator ()
 

Private Attributes

Size myNphi
 
Size myNtheta
 
std::vector< QuantitymyAccumulator
 
std::vector< VectormyAccumulatorDir
 
Quantity myTotal
 
Quantity myBinNumber
 
Size myMaxBinPhi
 
Size myMaxBinTheta
 

Detailed Description

template<typename TVector>
class DGtal::SphericalAccumulator< TVector >

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:

SphericalAccumulator<Vector> accumulator(6);
//Insert some directions
accumulator.addDirection( Vector(0,1,0));
accumulator.addDirection( Vector(1,-0.01,0));
accumulator.addDirection( Vector(1,0.01,-0.01));
accumulator.addDirection( Vector(1,-0.01,0.01));

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:

...
Viewer3D viewer;
viewer << accumulator;
...
See also
testSphericalAccumulator.cpp
Template Parameters
TVectortype used to represent directions.

Definition at line 102 of file SphericalAccumulator.h.

Member Typedef Documentation

template<typename TVector>
typedef std::vector<Quantity>::const_iterator DGtal::SphericalAccumulator< TVector >::ConstIterator

Type to iterate on bin values.

Definition at line 117 of file SphericalAccumulator.h.

template<typename TVector>
typedef DGtal::int32_t DGtal::SphericalAccumulator< TVector >::Quantity

Type to store the bin counts.

Definition at line 111 of file SphericalAccumulator.h.

template<typename TVector>
typedef PointVector<3,double> DGtal::SphericalAccumulator< TVector >::RealVector

Type to represent normalized vector (internal use).

Definition at line 120 of file SphericalAccumulator.h.

template<typename TVector>
typedef DGtal::uint32_t DGtal::SphericalAccumulator< TVector >::Size

Type to represent bin indexes.

Definition at line 114 of file SphericalAccumulator.h.

template<typename TVector>
typedef TVector DGtal::SphericalAccumulator< TVector >::Vector

Vector direction types.

Definition at line 108 of file SphericalAccumulator.h.

Constructor & Destructor Documentation

template<typename TVector>
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.

Parameters
aNphithe number of slices in the longitude polar coordinates.
template<typename TVector>
DGtal::SphericalAccumulator< TVector >::~SphericalAccumulator ( )

Destructor.

template<typename TVector>
DGtal::SphericalAccumulator< TVector >::SphericalAccumulator ( const SphericalAccumulator< TVector > &  other)
inline

Copy constructor.

Parameters
otherthe object to clone.

Definition at line 338 of file SphericalAccumulator.h.

339  {
340  myNphi = other.myNphi;
341  myNtheta = other.myNtheta;
342  myAccumulator = other.myAccumulator;
343  myAccumulatorDir = other.myAccumulatorDir;
344  myTotal = other.myTotal;
345  myBinNumber = other.myBinNumber;
346  myMaxBinPhi = other.myMaxBinPhi;
347  myMaxBinTheta = other.myMaxBinTheta;
348  }
std::vector< Vector > myAccumulatorDir
Accumulator reprensentative directions.
std::vector< Quantity > myAccumulator
Accumulator container.
Quantity myTotal
Number of samples.
Size myMaxBinPhi
Phi coordinate of the max bin.
Size myNphi
Number of slices in the phi direction.
Size myMaxBinTheta
Theta coordinate of the max bin.
Size myNtheta
Number of bins in the theta direction.
Quantity myBinNumber
Number of bins.
template<typename TVector>
DGtal::SphericalAccumulator< TVector >::SphericalAccumulator ( )
protected

Constructor. Forbidden by default (protected to avoid g++ warnings).

Member Function Documentation

template<typename TVector>
void DGtal::SphericalAccumulator< TVector >::addDirection ( const Vector aDir)

Add a new direction into the accumulator. The accumulator updates the bin coordinates with maximum count.

Parameters
aDira direction
template<typename TVector>
ConstIterator DGtal::SphericalAccumulator< TVector >::begin ( ) const
inline
Warning
Be careful, some of the iterators may be attached to un-valid bins. Once you have the iterator, convert it to bin coordinates using binCoordinates and then check if the bin is valid using isValidBin method.
Returns
an iterator on the bin value container (begin).

Definition at line 308 of file SphericalAccumulator.h.

309  {
310  return myAccumulator.begin();
311  }
std::vector< Quantity > myAccumulator
Accumulator container.
template<typename TVector>
void DGtal::SphericalAccumulator< TVector >::binCoordinates ( const Vector aDir,
Size posPhi,
Size posTheta 
) const

Given a normalized direction, this method computes the bin coordinates.

Precondition
aDir a direction.
Parameters
aDira direction represented as a unit norm vector.
posPhiposition according to the first direction.
posThetaposition according to the second direction.
template<typename TVector>
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.

Parameters
aDiran iterator to the bin container.
posPhiposition according to the first direction.
posThetaposition according to the second direction.
template<typename TVector>
Quantity DGtal::SphericalAccumulator< TVector >::binNumber ( ) const
inline
Returns
returns the number of bins in the accumulator.

Definition at line 217 of file SphericalAccumulator.h.

217 { return myBinNumber;}
Quantity myBinNumber
Number of bins.
template<typename TVector>
DGtal::SphericalAccumulator< TVector >::BOOST_STATIC_ASSERT ( Vector::dimension  = =3)
template<typename TVector>
std::string DGtal::SphericalAccumulator< TVector >::className ( ) const
inline
Returns
the class name.

Definition at line 252 of file SphericalAccumulator.h.

253  {
254  return "SphericalAccumulator";
255  }
template<typename TVector>
void DGtal::SphericalAccumulator< TVector >::clear ( )

Clear the current accumulator.

template<typename TVector>
Quantity DGtal::SphericalAccumulator< TVector >::count ( const Size posPhi,
const Size posTheta 
) const

Returns the current number of samples in the bin (posPhi,posTheta).

Parameters
posPhiposition according to the first direction
posThetaposition according to the second direction
Returns
the number of accumulated samples
template<typename TVector>
ConstIterator DGtal::SphericalAccumulator< TVector >::end ( ) const
inline
Returns
an iterator on the bin value container (end).

Definition at line 316 of file SphericalAccumulator.h.

317  {
318  return myAccumulator.end();
319  }
std::vector< Quantity > myAccumulator
Accumulator container.
template<typename TVector>
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).

Parameters
posPhibin index along the first direction.
posThetabin index along the second direction.
Returns
the main direction of a bin (quand mid-point).
template<typename TVector>
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.

Parameters
posPhibin index along the first direction.
posThetabin index along the second direction.
avertex position.
bvertex position.
cvertex position.
dvertex position.
template<typename TVector>
bool DGtal::SphericalAccumulator< TVector >::isValid ( ) const

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.
template<typename TVector>
bool DGtal::SphericalAccumulator< TVector >::isValidBin ( const Size posPhi,
const Size posTheta 
) const

Returns true if is bin (posPhi,posTheta) is valid.

Parameters
posPhiposPhi index
posThetaposTheta index
Returns
true if (posPhi,posTheta) is valid.
template<typename TVector>
void DGtal::SphericalAccumulator< TVector >::maxCountBin ( Size posPhi,
Size posTheta 
) const

Returns the coordinates of the bin containing the maximum number of samples.

Parameters
posPhicoordinate along the phi axis.
posThetacoordinate along the theta axis.
template<typename TVector>
SphericalAccumulator& DGtal::SphericalAccumulator< TVector >::operator= ( const SphericalAccumulator< TVector > &  other)
inline

Assignment.

Parameters
otherthe object to copy.
Returns
a reference on 'this'. Forbidden by default.

Definition at line 356 of file SphericalAccumulator.h.

357  {
358  if (this!=other)
359  {
360  myNphi = other.myNphi;
361  myNtheta = other.myNtheta;
362  myAccumulator = other.myAccumulator;
363  myAccumulatorDir = other.myAccumulatorDir;
364  myTotal = other.myTotal;
365  myBinNumber = other.myBinNumber;
366  myMaxBinPhi = other.myMaxBinPhi;
367  myMaxBinTheta = other.myMaxBinTheta;
368  }
369  return *this;
370  }
std::vector< Vector > myAccumulatorDir
Accumulator reprensentative directions.
std::vector< Quantity > myAccumulator
Accumulator container.
Quantity myTotal
Number of samples.
Size myMaxBinPhi
Phi coordinate of the max bin.
Size myNphi
Number of slices in the phi direction.
Size myMaxBinTheta
Theta coordinate of the max bin.
Size myNtheta
Number of bins in the theta direction.
Quantity myBinNumber
Number of bins.
template<typename TVector>
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.

Parameters
posPhiposition according to the first direction
posThetaposition according to the second direction
Returns
the representative direction.
template<typename TVector>
Vector DGtal::SphericalAccumulator< TVector >::representativeDirection ( ConstIterator it) const

Get the representative direction of a bin specified by a ConstIterator.

Parameters
itthe iterator on the bin to get the direction
Returns
the representative direction of bin it.
template<typename TVector>
Quantity DGtal::SphericalAccumulator< TVector >::samples ( ) const
Returns
returns the number of directions in the current accumulator.
template<typename TVector>
void DGtal::SphericalAccumulator< TVector >::selfDisplay ( std::ostream &  out) const

Writes/Displays the object on an output stream.

Parameters
outthe output stream where the object is written.

Field Documentation

template<typename TVector>
std::vector<Quantity> DGtal::SphericalAccumulator< TVector >::myAccumulator
private
template<typename TVector>
std::vector<Vector> DGtal::SphericalAccumulator< TVector >::myAccumulatorDir
private
template<typename TVector>
Quantity DGtal::SphericalAccumulator< TVector >::myBinNumber
private
template<typename TVector>
Size DGtal::SphericalAccumulator< TVector >::myMaxBinPhi
private
template<typename TVector>
Size DGtal::SphericalAccumulator< TVector >::myMaxBinTheta
private
template<typename TVector>
Size DGtal::SphericalAccumulator< TVector >::myNphi
private
template<typename TVector>
Size DGtal::SphericalAccumulator< TVector >::myNtheta
private
template<typename TVector>
Quantity DGtal::SphericalAccumulator< TVector >::myTotal
private

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