[vtkusers] vtkImageReslicing from every major axis problem

Andaharoo Andx_roo at live.com
Thu Jun 15 01:35:31 EDT 2017


I have a program that shows the three major axii of a volume using
vtkImageViewer2 and I want to output a single image given the x, y, or z
slice number. I've been using vtkImageReslice to accomplish this task.
Outputting the XY plane is easy, I just do:

reslicer->setResliceAxesOrigin(0, 0, slice * spacing[2]);

I don't have to transform the plane as XY is default. Then I just set the z
of the plane, which in physical space would be the slice number * spacing.

Now to do the same thing but with the YZ plane I do:

reslicer->SetResliceAxesOrigin(0, 0, slice * spacing[0]);
transform->Translate(extent[0], extent[1], extent[2]);
transform->RotateY(90);
transform->Translate(-extent[0], -extent[1], -extent[2]);
reslicer->SetResliceTransform(transform);

Note: extent[i] = dim[i] * spacing[i], not vtk's image data extent. 

So I transform to the origin, then rotate the plane on the Y axis. I've
noticed that the axes origin gets applied after transform so the slice
number that would have been on the x axis should be specified as z in
SetResliceAxesOrigin. Also to get the correct depth of the slice I need the
spacing from the corresponding axis in the image which would be x axis
spacing or spacing[0].

Now the problem is that while the transform works perfectly the slice number
isn't the correct one. In fact it's a suspicious number.

With this input image:
Dim = 240, 240, 163
Spacing = 1.0444, 1.0444, 1.0999
Dim with Spacing (size) ~ 249, 249, 179

When I try to export the middle slice, 120, I get the wrong slice. Now I
noticed if I swap the spacing with the spacing of the z axis (spacing[2])
then I get the middle slice of the z axis. Slice 81 (163/2 floored). Which
makes me think the slice is somehow in z axis scale. So I tried manually
rescaling the axesorigin by normalizing the slice. frac = slice / maxslice
or 0.5 = 120 / 240. Then frac * size[2] or 0.5 * 163 * 1.0999. But the
scaling is still off. While I get the correct slice from 120 all the others
are still off.



--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkImageReslicing-from-every-major-axis-problem-tp5743646.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list