[vtkusers] vtkimagereslicemapper to get exact slice

David Gobbi david.gobbi at gmail.com
Thu Mar 13 19:46:54 EDT 2014


On Thu, Mar 13, 2014 at 1:02 PM, chasank <chasank at gmail.com> wrote:
>
> If I understand your point correctly, the code above causes the
> interpolation between slices. Am I right? If so, how can I make sure that
> the origin of slice plane lies exactly on the slices in the data set?

You can do it by using integer slice numbers, and count slices from the
image origin.

So instead of using the plane's origin as you did in your code, you can use
the image origin:

origin <- get from image
// get the distance from the plane to the image origin
double distance = plane->DistanceToPlane(origin);
// convert the distance into a slice number
double slice_number = floor(distance/spacing[2] + 0.5);
slice_number += 1; // or subtract one
plane->Push(distance - slice_number*spacing[2]);
// or maybe it should be this, I'm not 100% sure about the sign:
plane->Push(slice_number*spacing[2] - distance);

The floor() operation is what ensures that you are an integral
number of slice spacings away from the first image slice.

  David


More information about the vtkusers mailing list