diff --git a/vcg/math/histogram.h b/vcg/math/histogram.h index bf3ac485..df849496 100644 --- a/vcg/math/histogram.h +++ b/vcg/math/histogram.h @@ -163,13 +163,13 @@ public: */ void SetRange(ScalarType _minv, ScalarType _maxv, int _n,ScalarType gamma=1.0 ); - ScalarType MinV() {return minv;} //! Minimum value. - ScalarType MaxV() {return maxv;} //! Maximum value. + ScalarType MinV() {return minv;} //! Minimum value of the range where the histogram is defined. + ScalarType MaxV() {return maxv;} //! Maximum value of the range where the histogram is defined. ScalarType Sum() {return sum;} //! Total sum of inserted values. ScalarType Cnt() {return cnt;} - ScalarType MinElem() {return minElem;} //! Minimum element added to the histogram. It could be < or > than MinV;. - ScalarType MaxElem() {return maxElem;} //! Maximum element added to the histogram. It could be < or > than MinV;.. + ScalarType MinElem() {return minElem;} //! Minimum element that has been added to the histogram. It could be < or > than MinV;. + ScalarType MaxElem() {return maxElem;} //! Maximum element that has been added to the histogram. It could be < or > than MinV;.. /** * Add a new value to the histogram. @@ -179,7 +179,8 @@ public: */ void Add(ScalarType v, ScalarType increment=ScalarType(1.0)); - ScalarType MaxCount() const; + ScalarType MaxCount() const; //! Max number of elements among all buckets (including the two infinity bounded buckets) + ScalarType MaxCountInRange() const; //! Max number of elements among all buckets between MinV and MaxV. int BinNum() const {return n;} ScalarType BinCount(ScalarType v); ScalarType BinCountInd(int index) {return H[index];} @@ -366,6 +367,12 @@ ScalarType Histogram::MaxCount() const return *(std::max_element(H.begin(),H.end())); } +template +ScalarType Histogram::MaxCountInRange() const +{ + return *(std::max_element(H.begin()+1,H.end()-1)); +} + // Return the scalar value such that there are samples <= . // E.g. Percentile(0.0) will return R[1] e.g. min value // E.g. Percentile(1.0) will return R[n+1] e.g max value