Commit e43ee603 authored by Otmane Lahlou's avatar Otmane Lahlou
Browse files

ENH: contribution of the current bin in the percentile when min=max is null (avoid division by 0)

parent 2470289f
......@@ -106,9 +106,15 @@ HistogramModel
Histogram::FrequencyType frequency( histogram->GetFrequency( index ) );
// Initialize result (contribution of current bin)
double percent = frequency
* (bound == BOUND_LOWER ? (intensity - minI) : (maxI - intensity) )
/ ( maxI - minI );
const MeasurementType epsilon = 1.0E-6;
double percent = 0.;
if ( vcl_abs(maxI - minI) > epsilon )
{
percent = frequency
* (bound == BOUND_LOWER ? (intensity - minI) : (maxI - intensity) )
/ ( maxI - minI );
}
// Number of bins of histogram.
Histogram::SizeType::SizeValueType binCount = histogram->Size();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment