[vtkusers] orthogonal slices through a volume
dgobbi at atamai.com
Mon Aug 21 14:05:24 EDT 2006
It is possible to use vtkImageReslice to do what you want, but the trick
You need to set up vtkImageReslice so that it will extract just 1 slice
If you use vtkImageReslice to reslice the whole volume, and then use
vtkImageViewer2 or vtkImageClip to extract one slice from the resliced
volume, then you will have a very hard time getting the result you want.
So, I'm sure you are wondering how to get vtkImageReslice to select just
one slice for you, and how to make sure that it selects the correct slice.
The easiest way to output just one slice is to use
The easiest way to select which slice to output is to use
slicer->SetResliceAxesOrigin(x,y,z) where (x,y,z) is the point where
your three orthogonal planes will intersect.
There is still one tricky part left! When you use
SetOutputDimensionality(2), the output of vtkImageReslice will always be
in a 2D (x,y) coordinate system with z=0. This is no problem if you are
using vtkImageViewer, since it works in the 2D display coordinate
system, but you will get into trouble with vtkImageViewer2.
The best way to display the result is to use vtkImageActor (or actually
3 separate vtkImageActors). You will have to set the UserMatrix of the
vtkImageActor to match the ResliceAxes matrix that was applied to the
image by the slicer:
This will place the imageActor in exactly the same position as the slice
that the slicer cut from the volume.
So as you can see, this is all fairly complicated. But when it is all
done, you can slice in all three directions by changing the (x,y,z) that
you send to slicer->ResliceAxesOrigin(x,y,z). Send the same (x,y,z) to
all three slicers.
Let me know how it works for you.
Anja Ende wrote:
> Hi everyone,
> I know this question has been asked before but I could not find an
> answer that could have helped me, so I am asking again.
> Well... I am trying to get the classic 3 orthogonal slices through a
> volume. I know the vtkImageViewer2 provides this functionality but I
> cannot use that component unfortunately.
> I was trying to use the vtkImageReslicer to get the XZ plane through
> the volume.
> So, I tried setting up the matrix as follows:
> vtkImageReslice * slicer = vtkImageReslice::New();
> slicer->SetResliceAxesDirectionCosines(1, 0, 0, 0, 0, 1, 0, -1, 0);
> Is this matrix correct if I want to get the XZ plane out of the
> volume? I ask because some of the slices in the beginning and end seem
> bogus. The vtkImageViewer2 does not show them when I set the
> orientation to XZ in the vtk viewer.
> Also, I noticed that the vtkImageViewer2 displays the volume nicely
> with correct aspect ratio and all that... So, I tried using:
> slicer->SetOutputSpacing(1.0, 1.0, 1.0);
> This was shown in the example. However, this changes my extents and
> the number of Z slices reduces.
> I was wondering if someone can help me determine the correct matrix
> for extracting these planes.
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
More information about the vtkusers