[vtk-developers] vtkImageReslice performance questions/improvemnts

David Gobbi david.gobbi at gmail.com
Fri Sep 24 16:28:14 EDT 2010


On Fri, Sep 24, 2010 at 1:46 PM, Bill Lorensen <bill.lorensen at gmail.com> wrote:
> We went through this rounding mess in ITK about a year ago.  We have
> two rounding functions:
> RoundHalfIntegerUp with is also called Round
>  Round towards nearest integer

My favorite.  I call it "round just like we were taught in grade school".

> and
> RoundHalfIntegerToEven
>  halfway cases are rounded towards the nearest even  integer, e.g.
>  *          RoundHalfIntegerToEven( 1.5) ==  2
>  *          RoundHalfIntegerToEven(-1.5) == -2
>  *          RoundHalfIntegerToEven( 2.5) ==  2
>  *          RoundHalfIntegerToEven( 3.5) ==  4
>
> They are implemented in what I thin is a complex way, but it seems to
> work cross platform.
>
> The code is in ITK/Code/Common/itkMath.h
>
> The implementation are in itkMathDetail. It supports various hardware
> accelerations.

I think it would be great if VTK inherited a version of this that was
trimmed down to "double" and "int".  These efficient rounding
computations are the one thing that you just can't do without inline
assembler instructions.  The pure "c++" implementations look decent,
too.

  David



More information about the vtk-developers mailing list