35 #ifndef AIMS_HISTOGRAM_SIMPLEHISTO_H
36 #define AIMS_HISTOGRAM_SIMPLEHISTO_H
69 void rebin(
int size );
82 template<
class T >
inline
87 this->_minValid = (int)thing->min();
88 this->_maxValid = (int)thing->max();
90 this->_nPoints = thing->getSizeX() * thing->getSizeY() * thing->getSizeZ()
95 thing->getStrides(),
true );
96 for( ; !it.
ended(); ++it )
100 res->
at( (
int)*p - this->_minValid )++;
107 template<
class T >
inline
110 rebin( size, this->_data.begin() , this->_data.end() );
114 template<
class T >
inline
118 rebin( &*end - &*beg, beg, end );
122 template<
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; )
144 this->_nPoints +=
sum;
147 int tmpMin = this->_minValid;
149 this->_minValid = this->_maxValid = tmpMin /coef;
151 for ( it2 = res.
begin(), i=0; *it2 == 0 && it2 != res.
end(); it2++, ++i )
152 this->_minValid = i + tmpMin / coef;
154 for ( ; it2 != res.
end(); it2++, ++i )
156 this->_maxValid = i + tmpMin / coef;
170 float minh = thing->min();
171 float maxh = thing->max();
172 float div = maxh - minh;
174 if ( ( div < (
float)size ) && ( div > 1.0f ) )
177 this->_minValid = (int)minh;
178 this->_maxValid = (int)maxh;
183 this->_maxValid = size - 1;
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 ) )
225 this->_minValid = (int)minh;
226 this->_maxValid = (int)maxh;
231 this->_maxValid = size - 1;
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 ) )++;
Base class of histogram container class.
Classical histogram container class.
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
blitz::Array< T, Volume< T >::DIM_MAX >::iterator iterator
void inc_line_ptr(const T *&p) const
DataTypeTraits< T >::LongType sum(const Volume< T > &vol)