[vtkusers] vtkImageAccumulate

Odet Christophe christophe.odet at creatis.insa-lyon.fr
Tue Jun 19 09:35:23 EDT 2001


 Hi,

when using vtkImageAccumulate to build histogram, I found a problem(bugs) when the image data has
positive and negative values (signed short for example). In this case values between -1 and 1
(after division by spacing) are grouped together in bin number 0 
due to the way "int" does its rounding in the following line (vtkImageAccumulate.cxx):

  outIdx = (int)(((float)*inPtrC - origin[idxC]) / spacing[idxC]);

In this case the number of values in bin 0 is approx. twice the expected number. This create a spurious
pulse in the output histogram.

I apparently solve the problem using the floor function.

  outIdx = (int)floor(((float)*inPtrC - origin[idxC]) / spacing[idxC]);

It can also be solved using origin and the input extent but not so easily.

Am I rigth ? If yes, this is a bug and could be corrected in a next release.

Thanks

--
********************************************************************
ODET Christophe
CREATIS, INSA 502, F-69621 Villeurbanne cedex (France)
tel 04 72 43 85 62
Fax 04 72 43 85 26
Email: christophe.odet at creatis.insa-lyon.fr
URL    :http://www.creatis.insa-lyon.fr
********************************************************************






More information about the vtkusers mailing list