35#ifndef AIMS_HISTOGRAM_SIMPLEHISTO_H
36#define AIMS_HISTOGRAM_SIMPLEHISTO_H
39#include <cartobase/containers/nditerator.h>
69 void rebin(
int size );
82template<
class T >
inline
90 this->
_nPoints = thing->getSizeX() * thing->getSizeY() * thing->getSizeZ()
95 thing->getStrides(),
true );
96 for( ; !it.
ended(); ++it )
107template<
class T >
inline
110 rebin( size, this->
_data.begin() , this->_data.end() );
114template<
class T >
inline
118 rebin( &*end - &*beg, beg, end );
122template<
class T >
inline
126 int i,
sum, length = &*end - &*beg;
130 int coef = (int)ceil( (
double)length / (
double)size );
136 for ( it2=res.
begin(); it2!=res.
end(); )
140 for ( i = coef; i-- && it != end; )
151 for ( it2 = res.
begin(), i=0; *it2 == 0 && it2 != res.
end(); it2++, ++i )
154 for ( ; it2 != res.
end(); it2++, ++i )
170 float minh = thing->min();
171 float maxh = thing->max();
172 float div = maxh - minh;
174 if ( ( div < (
float)size ) && ( div > 1.0f ) )
186 this->
_nPoints = thing->getSizeX() * thing->getSizeY() * thing->getSizeZ()
191 thing->getStrides(),
true );
192 for( ; !it.
ended(); ++it )
197 int x = (int)( (
float) size * ( *p - minh ) / div );
218 double minh = thing->min();
219 double maxh = thing->max();
220 double div = maxh - minh;
222 if ( ( div < (
float)size ) && ( div > 1.0f ) )
234 this->
_nPoints = thing->getSizeX() * thing->getSizeY() * thing->getSizeZ()
237 const double *p, *pp;
239 thing->getStrides(),
true );
240 for( ; !it.
ended(); ++it )
244 res.
at( (
int)( (
double)size * ( *p - minh ) / div ) )++;
carto::VolumeRef< int32_t > _data
histogram datas
int _minValid
minimum used value
int _nPoints
total number of points
int _maxValid
maximum used value
SimpleHistogram()
constructor. Does nothing.
SimpleHistogram(const SimpleHistogram< T > &other)
copy constructor.
void doit(const carto::rc_ptr< carto::Volume< T > > &thing)
classical histogram computation function.
virtual ~SimpleHistogram()
destructor.
void rebin(int size)
rebinning to a specific result vector size.
const T & at(long x, long y=0, long z=0, long t=0) const
std::ptrdiff_t line_length() const
void inc_line_ptr(const T *&p) const
DataTypeTraits< T >::LongType sum(const Volume< T > &vol)