[vtkusers] get an arbitary oblique slice through volume with vtkImageReslice

David Feng dfeng at cs.unc.edu
Mon Oct 12 15:44:13 EDT 2009


Sorry, I got vtkImageReslice and vtkProbeFilter merged together in my head.

To clarify/correct, you need to supply the orientation of the plane 
(ResliceAxesDirectionCosines) and a point that passes through the plane 
(ResliceAxesOrigin).  Also, as the documentation says, make sure you set 
the output dimensionality to 2.  The orientation is a 3x3 rotation 
matrix.  That matrix looks like this:

x1 y1 n1
x2 y2 n2
x3 y3 n3

n is the plane's normal, x and y are vectors orthogonal to n that lie on 
the plane.  You can make one of these yourself by creating a 
vtkTransform, applying any rotations you want, and computing the new basis:

M * [1; 0; 0; 1] = x
M * [0; 1; 0; 1] = y
M * [0; 0; 1; 1] = z

For example:

vtkTransform* t = vtkTransform::New();
t.RotateX(90);
double x[4] = {1,0,0,1};
M.MultiplyPoint(x,x);

This will store in x the new x vector in the rotated space, in this 
instance rotate 90 degrees about the x axis. 

Why doesn't the vtkImagePlaneWidget do what you want?  It is an 
interactive, arbitrarily orientable, scalable, and window/level-able 
slice plane.  It even uses vtkImageReslice internally, if I'm not 
mistaken, so unless I'm missing something there's no need to rewrite it 
yourself.

David

Martin Schmitz wrote:
> hallo David,
>
> thank you for the answer,
>
> in the doucumentation of the class vtkImageReslice says :" /Extraction 
> of slices from an image volume. The most convenient way to do this is 
> to use SetResliceAxesDirectionCosines() to specify the orientation of 
> the slice. The direction cosines give the x, y, and z axes for the 
> output volume./"
> So i have to use the right transformation matrix to rotate or move the 
> plane, i don't know if i need the class vtkPlane, what i need is a 
> class of vtkTransform. I tried with the class  vtkImagePlaneWidget but 
> it was not that what i need.
>
> thank you
>
>
> 2009/10/12 David Feng <dfeng at cs.unc.edu <mailto:dfeng at cs.unc.edu>>
>
>     The vtkImagePlaneWidget class will let you interactively
>     rotate/scale/etc a slice plane through a volume and show you the
>     results as you go.  I think you just need to click on the
>     boundaries of the image to start the different manipulations.  You
>     can get the sliced values out from the widget via
>     GetResliceOutput(), or something similar.  I think you can set the
>     position of the plane programmatically as well.
>     If you want to get dirty with vtkImageReslice, I believe what
>     you'll need to do is make a vtkPlane and connect it via
>     SetInputInformation().  The ResliceAxesDirectionCosines allow you
>     transform the plane (or whatever reslice structure you use) into a
>     different coordinate space (patient space to world space, for
>     example).  In your case, it's probably easier to manipulate the
>     vtkPlane directly.
>
>     David
>
>
>     Orlinn wrote:
>
>         Hallo everybody,
>
>         i want to get an arbitary oblique slice through my volume
>         data. I found
>         example which show how to get the axial, coronar and sagittal
>         slice. I know
>         that i can use the methode "SetResliceAxesDirectionCosines"
>         but i don't know
>         how to set the parameters to get an arbitary oblique slice
>         throught the
>         volume.  can anybody help please? i have no idea how to solve
>         my problem
>
>         sorry for my english
>
>         thank you
>            
>
>
>




More information about the vtkusers mailing list