[vtkusers] How to use vtkImageReslice to get oblique slice with arbitrarily position and direction

Alessandro Volz alessandro.volz at gmail.com
Thu Jan 5 05:18:54 EST 2017


I just spent a few days figuring out how to do just that :)

In my case, the input is a three-dimensional floats blob (a 3D volume) and the output is a two-dimensional floats blob (a 2D slice that I later draw).

1- map your input data to VTK: I'm using an instance of vtkImageImport, but there are many alternatives depending on your input data
2- set up a vtkImageReslice
3- Update() the vtkImageReslice and get the output vtkImageData through GetOutput()

The tricky part is setting up the vtkImageReslice:

2a- connect the vtkImageImport output to the vtkImageReslice input
2b- set up the output (scalar type, dimensionality, extent, origin, interpolation mode)
2c- define the reslice axes and origin

Your question was mainly on how to define the position and direction of the reslice, so more details on 2c: I ended up setting these on my reslices is by using the vtkImageReslice SetResliceAxes method, basically through an array of 16 values: { xdir.x, ydir.x, zdir.x, origin.x, xdir.y, ydir.y, zdir.y, origin.y, xdir.z, ydir.z, zdir.z, origin.z, 0, 0, 0, 1 }

My Obj-C++ code could be useful: https://github.com/spalte/Natural-Image-Building-Blocks/blob/master/NIBuildingBlocks/NIVTKObliqueSliceOperation.mm


Alessandro Volz

> On Jan 5, 2017, at 10:55 AM, wangtaoiz <wangtao_ at sjtu.edu.cn> wrote:
> Dear all
> Dose any body know how to use vtkImageReslice to get oblique slice with
> arbitrarily position and direction? I need to set the position and direction
> for reslice, and get the slice data, any good idea?
> Tao Wang
> Thanks all
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/How-to-use-vtkImageReslice-to-get-oblique-slice-with-arbitrarily-position-and-direction-tp5741711.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Search the list archives at: http://markmail.org/search/?q=vtkusers
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers

More information about the vtkusers mailing list