[vtkusers] Coordinates of VTKImagereslice

David Gobbi dgobbi at imaging.robarts.ca
Thu May 27 11:28:29 EDT 2004


Hi Neilson,

I'll try to answer your questions.  See below.

On Thu, 27 May 2004, N.E. Mackenzie Mackay wrote:

> Hi,
>
> 	I am trying to cut through a 3D volume along a certain 2D plane. I am
> having a problem defining the cosines and origin for vtkImageReslice.
>
> Right now I have a origin, normal and two points on the plane in world
> cordinates.  I almost positive these points are correct.  When I use
> these values for image reslice I do not end up with the correct slice:
>
> 	vtkImageReslice *slicer = vtkImageReslice::New();
> 	slicer->SetInput(v16->GetOutput());					// volume
> 	slicer->setResliceAxesDirectionCosines(point1, point2, normal);
> 	slicer->SetResliceAxesOrigin(origin);
> 	slicer->SetOutputDimensionality(2);

The direction cosines are vectors, so you should define v1, v2 as follows:
v1[0] = point1[0] - origin[0];  etc. for v1[1], v1[2]
v2[0] = point2[0] - origin[0];  etc. for v2[1], v2[2]
vtkMath::Normalize(v1);
vtkMath::Normalize(v2);

slicer->setResliceAxesDirectionCosines(v1, v2, normal);

This assumes that origin, point1, and point2 correspond to the same
values you would use to set up a vtkPlaneSource that represents your
plane.

> I tried multiplying point1, point2, normal and origin by the spacing
> for the volume to try and put them in the same space but still no
> positive results.  I Guess my question is:
>
> 	1. What is the coordinate frame vtkImageReslice works in?

In VTK terms, it works in the "data" coordinate system according
to the Origin and Spacing of the data.  It does not work in the i,j,k
voxel-index coordinate system, which is often referred to as
"structured" coords.

> 	2. How does the direction cosines effect the slice that is being cut?
> 		Eg.  I am taking a 2d slice of a volume.  If I provided
> the identity
> matrix for the cosines and origin to vtkImageReslice what axis would
> the resulting reslice plane lie on( XY, YZ, XZ ect.)  I assume it's the
> XY plane but I am not sure.

The XY plane.

> 	3. Does anyone have some sample code for setting a reslice of a
> specific 2d plane ( defined by a normal, 2 points and a origin)
> through a 3d volume?

You can take a look at the source code for vtkImagePlaneWidget in the
Hybrid directory.

 - David

> If anyone who has some insight on this could please help me out I would
> be in there debt.  This problem has stupped me for quite some time and
> is a big road block.
>
> Thanks you so much in advance,
> Neilson
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>




More information about the vtkusers mailing list