[vtkusers] Simple Reslicer Question

David Gobbi dgobbi at imaging.robarts.ca
Thu Nov 14 10:42:56 EST 2002


Hi Scott,

To understand how vtkImageReslice transformations work, it is best
to understand the data representation in the same way that 'VTK'
does, i.e. an image volume is a set of (x,y,z) points each of
which carries a scalar value I.  In a vtkImageData, these points
lie on a regular grid.

If you understand how vtkProbeFilter works, then you can consider
vtkImageReslice to be a vtkProbeFilter that is specifically designed
to probe a vtkImageData and produce a vtkImageData.  The first thing
you have to do is set the OutputSpacing, OutputOrigin and OutputExtent
to define desired grid of output (x,y,z) points.  Next, you set
the ResliceTransform to define a transformation that will take
each (x,y,z) point on the output grid, and produce an (x,y,z)
coordinate that lies within the input point grid.  The value I of this
point is interpolated from the input and used in the output.  If you
also set a second transformation using the ResliceAxes then that
transformation is applied after the ResliceTransform but before the
interpolation.  But remember that the transformations are use to
convert output (x,y,z) coordinates to input (x,y,z) coordinates,
not vice-versa.

And as a warning for other vtkImageReslice users: if you don't set the
OutputOrigin, OutputSpacing and OutputExtent. then vtkImageReslice
will 'guess' what it thinks are suitable values, i.e. vtkImageReslice
will decide for itself what set of (x,y,z) points to use to probe
the input data.  Whenever you are doing something more sophisticated
than a simple permutation or resizing of the volume, you should
either use SetInformationInput to define your (x,y,z) point grid,
or you should set it manually using the OutputOrigin, OutputSpacing
and OutputExtent.

Finally, to answer your questions, if you have an output point
(x,y,z) and then translate it you will be interpolating from
the input image at (x+100,y,z).  The image should shift left,
are you certain that it was shifting to the right?

Also, if rather than using
  reslice->SetOutputSpacing( reader->GetDataSpacing() );
  reslice->SetOutputOrigin( reader->GetDataOrigin() );
  reslice->SetOutputExtent( reader->GetDataExtent() );
you use
  reslice->SetInformationInput( reader->GetOutput() );
then the spacing etc. will be reset appropriately each time
the file for the reader changes.

I hope this helps.

Cheers,
  David

-- 
  David Gobbi, MSc                dgobbi at imaging.robarts.ca
  Advanced Imaging Research Group
  Robarts Research Institute, University of Western Ontario

On Thu, 14 Nov 2002, Stiving, Scott O. wrote:

> I am trying to take one MR volume that is an axial series and reslice it to correspond to an oblique series but I cannot get the volumes to line up correctly. I have stepped back to the basics and still cannot figure out the results from reslicer. In the snippet of code below all I am trying to do is translate the volume by a positive X and then "reslice" it using it's own information as output information. Everything seems to work but the image is shifted to the left, (I was expecting it to be shifted to the right). When I look at the transformation matrix everything looks right:
>
> 1 0 0 100
> 0 1 0 0
> 0 0 1 0
> 0 0 0 1
>
> Here are the results of other simple transformations:
> positive X translate ==> the image shifts right ???
> positive Y translate ==> the image shifts down ???
> positive Z translate ==> the volume shifts towards the viewer. (acts like a right handed coordinate system).
>
> translate to origin -> positive Z Rotation -> translate back ==> the image rotates clockwise (does not act like a right handed coordinate system).
>
> Could someone please tell me if these actions are correct, and if so why?
>
> // VTK Class to set transformation matrix
> vtkTransform *AxisTransform = vtkTransform::New();
> AxisTransform->PostMultiply();
> AxisTransform->Translate( 100.0, 0.0, 0.0 );
>
> vtkImageReslice *reslice = vtkImageReslice::New();
> reslice->SetInterpolationModeToLinear(); // For Linear
> reslice->SetInput(reader->GetOutput());
> reslice->SetResliceTransform(AxisTransform); // Applying transformation to volume
> reslice->SetOutputSpacing( reader->GetDataSpacing() );
> reslice->SetOutputOrigin( reader->GetDataOrigin() );
> reslice->SetOutputExtent( reader->GetDataExtent() );
>
> // Print out the matrixes
> vtkIndent indent;
> AxisTransform->PrintSelf( std::cout, indent );
> reslice->PrintSelf( std::cout, indent );
>
>
>
>
> **************************
> Scott O. Stiving M.S.
> Mayo Clinic
> MR Programming Support
> Mayo Image Studio Team
> (507) 266-0808
> Stiving at Mayo.edu <mailto:Stiving at Mayo.edu>
> ***************************
>
>





More information about the vtkusers mailing list