[vtkusers] Help with vtkImageReslice on non-uniform volume

Kevin Teich kteich at cortechs.net
Tue Apr 9 14:14:39 EDT 2002


I have had great success with using vtkImageReslice to slice a 256^3 view
in different orientations, however I am having trouble setting up the
pipeline for a 256x256x34 volume. My pipeline looks like this:

reader -> ImageReslice -> ImageMagnify -> ImageCursor3D ->
ImageMapToColors -> ImageBlend -> ImageViewer

(The latter end of the pipeline probably isn't relevant, but I want to
include it in case it could affect the beginning of the pipeline.) Here is
my slicer set up. window_size is 256, and volume_dimension_{x,y,z} is 256,
256, and 34, respectively.

vtkImageReslice reslice
reslice SetInput [reader GetOutput]
reslice SetOutputOrigin 0 0 0
reslice SetOutputSpacing \
      [expr $window_size / $volume_dimension_x] \
      [expr $window_size / $volume_dimension_y] \
      [expr $window_size / $volume_dimension_z]
reslice SetOutputExtent \
      0 [expr $volume_dimension_x - 1] \
      0 [expr $volume_dimension_y - 1] \
      0 [expr $volume_dimension_z - 1]

vtkTransform transform
transform Identity
transform Translate 0 [expr $volume_dimension_y - 1] 0

switch $axis {
      x { reslice SetResliceAxesDirectionCosines 0 0 1 0 -1 0 1 0 0
          reslice SetResliceTransform transform }
      y { reslice SetResliceAxesDirectionCosines 1 0 0 0 0 1 0 1 0 }
      z { reslice SetResliceAxesDirectionCosines 1 0 0 0 -1 0 0 0 1
          reslice SetResliceTransform transform }
}

...

I use the reslicer not only to grab the proper slice orientation, but also
to do a y-flip. That extra transform is to translate the flip properly in
the non-y slice views.

I also call SetSize with $window_size on the image viewer. I use SetZSlice
on the viewer to grab a slice out of the reslice output. That's all pretty
standard.

I do not set extent or spacing explicitly anywhere else in the slice view
pipeline.

The visual output on the Viewer is this: In the x slice view (in which the
zslice corresponds to the x dimension in the volume), the volume is
smushed up on the left side. All the data appears to be there, it's just
not 'stretched' to fill the view. I assume this is a spacing problem. In
the y slice view, it is smushed up on the bottom. In the z view, the image
fills the entire 256x256 view, but of the 34 slices I should be able to
view, only the first six or so show up.

I figure I am doing something wrong with spacing and/or extent, and that
is something stupid and easy to fix. However, I cannot see what it is. Any
ideas? Thanks.

-- 
Kevin Teich




More information about the vtkusers mailing list