[vtkusers] Integer overflow in vtkImageAccumulate

David Gobbi david.gobbi at gmail.com
Tue Oct 7 08:23:38 EDT 2014

Hi Gib,

For VTK 5.10 and later, I added a new class called vtkImageHistogram
that uses vtkIdType for the histogram, and another class called
vtkImageHistogramStatistics that can automatically compute
window/level.  These new classes should work fine on large images.

Perhaps vtkImageAccumulate should also use vtkIdType (or should
have a selectable output type.)

 - David

On Tue, Oct 7, 2014 at 1:30 AM, Gib Bogle <g.bogle at auckland.ac.nz> wrote:
> Hi all,
> I encountered a problem in 3DSlicer with the auto calculation of
> window/level.  This may be a well-known issue.  For some big 3D tiffs, the
> algorithm gives bad w/l values, i.e. < 0.  I have tracked this to
> vtkImageAccumulate() in vtkImageAccumulate.cxx, where the histogram is
> computed.  The problem is that the voxel counts are stored in an int array
> (outPtr), and it's possible to have more than 2^31 voxels with the same
> value (e.g. 0).  I admit that these are unusual tiffs - they are binary and
> big - so it's a rather extreme case, but it seems that this is going to bite
> others as image sizes increase.
> Cheers
> Gib

More information about the vtkusers mailing list