[vtk-developers] vtkImageReslice performance questions/improvemnts

David Gobbi david.gobbi at gmail.com
Tue Sep 14 13:43:54 EDT 2010


On Tue, Sep 14, 2010 at 10:33 AM, Sean McBride <sean at rogue-research.com> wrote:
>
> Ah!  Does vtkImageReslice care about other edge cases, like inf, nan, or
> doubles outside the range of the 'int' type?

It's only picky about values below zero or close to zero.  Any inf,
nan, etc. is likely to make the code misbehave badly.

> BTW, no test seems to catch this.  Before and after I changed the floor
> to a simple cast, the same tests pass/fail.  (Alas, many tests fail on
> my config, hopefully none of these failures are masking a test that
> would have caught this.)

Yeah, it is a big problem that the tests only cover the non-positive
range.  The Extent is a signed integer, so the WholeExtent of any
image can cover any combination of negative/positive values.   But
AFAIK all VTK image tests are only testing non-negative extents.
There is a similar problem with Spacing: a person can set the Spacing
to a negative value, but VTK classes are not tested to make sure they
work with negative spacing.

I'll see what I can do about adding a couple more tests for ImageReslice.

>>Also, even casting to int can be notoriously slow on
>>the x86 CPU.  A summary is provided here:
>>http://www.stereopsis.com/FPU.html
>
> Interesting.  Well, there have been so many x86 CPUs... :)  For me, the
> compiler seems to use CVTTSD2SI, which seems pretty fast.  But is
> doesn't round as desired.

That ImageReslice float-to-int code is old, and compilers only started
generating SSE instructions from vanilla C++ code fairly recently.
Find something that works fast with your compiler/CPU, make sure that
it does round-to-negative-infinity, and send it along.

   David



More information about the vtk-developers mailing list