[Insight-developers] Image to histogram filter bug

Peter Cech pcech at vision.ee.ethz.ch
Tue May 10 14:07:59 EDT 2005


Hi,

I was investigating why OtsuMultipleThresholdImageFilter
(OtsuMultipleThresholdImageFilter example, CVS as of April, 29) gives me
all thresholds zero on some images. As it turned out, it is because the
histogram was empty (no samples were taken).

I traced the strangeness down to
ListSampleToHistogramGenerator::GenerateData, where bounds for histogram
are computed from image data (look inside if(m_AutoMinMax) block). Here,
the upper bound is defined as upper+margin (if THistogramMeasurement is
not an integer) or upper+1 (if THistogramMeasurement is an integer),
where upper is maximum of image data elements.

Now imagine having an image with elements of type unsigned char and
containing value 255. The upper bound will be 255+1 = 0 (as the bounds have
the same type as image) and we get all the samples rejected as being out
of bounds.

Histogram::GetIndex(const MeasurementVectorType & measurement,IndexType
& index ) rejects all the samples >= upper bound, so the above
computation is correct except not checking for overflow.

If somebody has an idea how to fix it, please do.

Regards,

Peter Cech


More information about the Insight-developers mailing list