DGtal 1.4.2
Loading...
Searching...
No Matches
DGtal::SphericalAccumulator< TVector > Class Template Reference

Aim: implements an accumulator (as histograms for 1D scalars) adapted to spherical point samples. More...

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

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

Public Types

typedef TVector Vector
 Vector direction types.
 
typedef DGtal::int32_t Quantity
 Type to store the bin counts.
 
typedef size_t Size
 Type to represent bin indexes.
 
typedef std::vector< Quantity >::const_iterator ConstIterator
 Type to iterate on bin values.
 
typedef PointVector< 3, double > RealVector
 Type to represent normalized vector (internal use).
 

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
 Number of slices in the phi direction.
 
Size myNtheta
 Number of bins in the theta direction.
 
std::vector< QuantitymyAccumulator
 Accumulator container.
 
std::vector< VectormyAccumulatorDir
 Accumulator reprensentative directions.
 
Quantity myTotal
 Number of samples.
 
Quantity myBinNumber
 Number of bins.
 
Size myMaxBinPhi
 Phi coordinate of the max bin.
 
Size myMaxBinTheta
 Theta coordinate of the max bin.
 

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:

  • each direction/point on the unit sphere falls in a single bin
  • each bin almost cover the same area on the unit sphere
  • each bin have a geometrical support which can be represented as a quad except for its two poles

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:

typedef Z3i::RealVector Vector;
//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

◆ ConstIterator

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

Type to iterate on bin values.

Definition at line 117 of file SphericalAccumulator.h.

◆ Quantity

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

Type to store the bin counts.

Definition at line 111 of file SphericalAccumulator.h.

◆ RealVector

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

Type to represent normalized vector (internal use).

Definition at line 120 of file SphericalAccumulator.h.

◆ Size

template<typename TVector >
size_t DGtal::SphericalAccumulator< TVector >::Size

Type to represent bin indexes.

Definition at line 114 of file SphericalAccumulator.h.

◆ Vector

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

Vector direction types.

Definition at line 108 of file SphericalAccumulator.h.

Constructor & Destructor Documentation

◆ SphericalAccumulator() [1/3]

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.

◆ ~SphericalAccumulator()

template<typename TVector >
DGtal::SphericalAccumulator< TVector >::~SphericalAccumulator ( )

Destructor.

◆ SphericalAccumulator() [2/3]

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 }
Quantity myBinNumber
Number of bins.
std::vector< Vector > myAccumulatorDir
Accumulator reprensentative directions.
Size myMaxBinTheta
Theta coordinate of the max bin.
Size myNphi
Number of slices in the phi direction.
Quantity myTotal
Number of samples.
Size myNtheta
Number of bins in the theta direction.
std::vector< Quantity > myAccumulator
Accumulator container.
Size myMaxBinPhi
Phi coordinate of the max bin.

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.

◆ SphericalAccumulator() [3/3]

template<typename TVector >
DGtal::SphericalAccumulator< TVector >::SphericalAccumulator ( )
protected

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

Member Function Documentation

◆ addDirection()

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

Referenced by testSphericalAccumulator(), testSphericalMore(), and testSphericalMoreIntegerDir().

◆ begin()

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 }

References DGtal::SphericalAccumulator< TVector >::myAccumulator.

Referenced by testSphericalAccumulator(), testSphericalMore(), and testSphericalMoreIntegerDir().

◆ binCoordinates() [1/2]

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.

Referenced by testSphericalAccumulator().

◆ binCoordinates() [2/2]

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.

◆ binNumber()

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;}

References DGtal::SphericalAccumulator< TVector >::myBinNumber.

◆ BOOST_STATIC_ASSERT()

template<typename TVector >
DGtal::SphericalAccumulator< TVector >::BOOST_STATIC_ASSERT ( Vector::dimension = =3)

◆ className()

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 }

◆ clear()

template<typename TVector >
void DGtal::SphericalAccumulator< TVector >::clear ( )

Clear the current accumulator.

Referenced by testSphericalAccumulator().

◆ count()

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

Referenced by testSphericalAccumulator().

◆ end()

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 }

References DGtal::SphericalAccumulator< TVector >::myAccumulator.

Referenced by testSphericalAccumulator(), testSphericalMore(), and testSphericalMoreIntegerDir().

◆ getBinDirection()

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).

◆ getBinGeometry()

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.

◆ isValid()

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.

◆ isValidBin()

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.

◆ maxCountBin()

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.

Referenced by testSphericalMoreIntegerDir().

◆ operator=()

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 }

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.

◆ representativeDirection() [1/2]

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.

Referenced by testSphericalAccumulator(), and testSphericalMoreIntegerDir().

◆ representativeDirection() [2/2]

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.

◆ samples()

template<typename TVector >
Quantity DGtal::SphericalAccumulator< TVector >::samples ( ) const
Returns
returns the number of directions in the current accumulator.

Referenced by testSphericalAccumulator().

◆ selfDisplay()

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

◆ myAccumulator

◆ myAccumulatorDir

template<typename TVector >
std::vector<Vector> DGtal::SphericalAccumulator< TVector >::myAccumulatorDir
private

Accumulator reprensentative directions.

Definition at line 387 of file SphericalAccumulator.h.

Referenced by DGtal::SphericalAccumulator< TVector >::operator=(), and DGtal::SphericalAccumulator< TVector >::SphericalAccumulator().

◆ myBinNumber

◆ myMaxBinPhi

template<typename TVector >
Size DGtal::SphericalAccumulator< TVector >::myMaxBinPhi
private

◆ myMaxBinTheta

template<typename TVector >
Size DGtal::SphericalAccumulator< TVector >::myMaxBinTheta
private

◆ myNphi

template<typename TVector >
Size DGtal::SphericalAccumulator< TVector >::myNphi
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().

◆ myNtheta

template<typename TVector >
Size DGtal::SphericalAccumulator< TVector >::myNtheta
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().

◆ myTotal

template<typename TVector >
Quantity DGtal::SphericalAccumulator< TVector >::myTotal
private

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