[vtk-developers] VTK imaging and rounding

David Gobbi dgobbi at irus.rri.on.ca
Mon May 28 15:21:27 EDT 2001


This is sort of related to my earlier post RE: vtkLookupTable.
Currently nearly all float->integer scalar conversion in VTK
is done via truncation, rather than rounding.  I would like
to gradually modify at least the imaging filters to perform
rounding.

E.g. when vtkImageResample does bilinear interpolation
it performs

   v  = (T)(t00 + (y)*(t01-t00))

whereas if 'T' is an integer it should actually do

   v = (T)floor(t00 + (y)*(t01-t00) + 0.5)

Because it doesn't do this rounding, each time an image
is passed through vtkImageResample (or through many other
imaging filters) the output is approximately  one half
grey-value 'darker' than the input.  This is also true
of the window/level display operation performed in vtkImageMapper.

My plan is to add inline functions to vtkImageData.h (or maybe
vtkSetGet.h) so that

 void vtkScalarRound(float input_value, T& output_value);

will do the appropriate rounding (i.e. round for
float->int conversion, don't do anything for
float->float conversion).  I already have a full
set of such rounding functions in vtkImageReslice.cxx.

If there are no objections, I'll begin modifying the
imaging filters on-by-one (it'll probably be a few months
before they're all done).  Some regression tests images
will have to be replaced, in particular if I add rounding
to the vtkImageMapper I expect that nearly all the
the imaging baseline images would have to be updated.

Any opinions from others who use the imaging pipeline?
Is this a useful change, or are people fine with
truncation?

 - David

--
  David Gobbi, MSc                    dgobbi at irus.rri.on.ca
  Advanced Imaging Research Group
  Robarts Research Institute, University of Western Ontario





More information about the vtk-developers mailing list