VTKImageReslice: Slow performance

Hello Group, I am having performance issues while extracting SAGGITAL/CORONAL planes using VTKImageReslice. Each call to VTKImageReslice->GetOutput() takes 5-7 ms.

The volume used has the following properties:

  1. Dimensions: 512x512x297
  2. Pixel spacing: 0.4x0.4x0.7
  3. Scalar type: Unsigned Int16
  4. Number of components: 1 (Monochrome).

System & Build environment:

  1. Windows 7, 12GB RAM, i3 processor.
  2. Visual studio 2013
  3. VTK 7.1.1
  4. WPF for UI

Are there any known considerations for making VTKImageReslice fast?

@Adrien_Boucaud and @Michael already experienced some slowness with this same filter.

Thank you, Mathieu.
How do I get in touch with Adrien or Michael?


Well, we managed without using the vtkImageReslice and they have been notified when I tagged them.

It was more a note to confirm that vtkImageReslice is slow and may need some investigation to uderstand why.

Can you please guide me on how were you able to manage without using vtkImageReslice?


Abhishek Gupta.


It is not related to your issue sadly.

There are two common causes for vtkImageReslice to be slower than it should be:

  1. Some people only need to extract a single slice from the volume, but write their pipeline such that the OutputExtent of vtkImageReslice is a 3D extent. Then, after vtkImageReslice has produced a full 3D volume, they display just one slice of that output volume. All the extra work of reslicing the full volume instead of just extracting one slice will cause the filter to take e.g. 100x longer than it should. I don’t know if this fits your situation, you would have to show me your code.

  2. If you let the VTK pipeline automatically update filter or reader that precedes vtkImageReslice, instead of calling Update() manually on that read/filter, then a special feature of the pipeline called “streaming” can automatically be engaged. This can cause the upstream pipeline to be executed every time that vtkImageReslice itself is updated, resulting in a slowdown.

A further consideration is the way that the CPU cache handles different memory access patterns. This doesn’t impact performance as much as the two items described above, but if you benchmark sagittal and coronal separately it is normal to see that sagittal slicing is 2 or 3 times slower than coronal. You should check to see if this is the case with your code. Note that speed issues related to the cache are expected and there isn’t much to be done about them unless you want to do cache-specific profiling and optimization.

Finally, note that vtkImageReslice is multithreaded but it only uses the CPU, so it cannot be expected to come anywhere close to the performance of GPU interpolation. Actually, 5ms to extract a 512x297 sagittal slice from a 512x512x297 volume seems to be in the right ballpark for an i3 CPU.

I am also having the same problem, i need to make an average operation so to do it in 2d does not help in my case. Is there any other option to reslice a volume?