[vtkusers] Help with vtkImageReslice on non-uniform volume

David Gobbi dgobbi at irus.rri.ca
Tue Apr 9 16:57:30 EDT 2002


Hi Kevin,

On Tue, 9 Apr 2002, Kevin Teich wrote:

> 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

You should cut out the 'ImageMagnify' and include the magnification as
part of the ImageReslice.

To do this, use (where $mag_factor is the desired magnification)

reslice SetOutputExtent 0 [expr $window_size - 1]  \
                        0 [expr $window_size - 1]  \
                        0 [expr $window_size - 1]
reslice SetOutputSpacing [expr 1.0 / $mag_factor] \
                         [expr 1.0 / $mag_factor] \
                         [expr 1.0 / $mag_factor]

You will also have to make sure that the 'Spacing' of the input
to vtkImageReslice is set correctly, e.g. if you use vtkImageReader
then use

reader SetDataSpacing 1.0 1.0 8.0

or whatever the actual data spacing is.  If the 'Spacing' of the
input to vtkImageReslice is not set correctly, then nothing will
work properly.  The vtkImageChangeInformation filter can also be
used to change the Spacing associated with a vtkImageData.

 - David


> (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.
>
>





More information about the vtkusers mailing list