[vtkusers] how to use vtkImageReslice with vtkImageCheckerboard

Mark Roden mmroden at gmail.com
Thu May 3 23:35:16 EDT 2012


Hi all,

I'm trying to make a vtk-based registration tool for 3D medical image
data.  Namely, I'll have CT to CT registration, and CT to MR
registration.

I've developed a vtkDualImageViewer2 class based off of the
vtkImageViewer2 class that combined the convenience of the
imageviewer2 into a single place with a checkerboard widget.

The only problem is that it appears that the vtkImageReslice I'm using
appears to be obviating the need for a transform entirely.

How I do this:
Fixed image-> same pathway as in vtkImageViewer2, to a
vtkImageMapToWindowLevelColors object.
Moving image-> has a vtkTransform, then a vtkImageReslice that gets
piped to a vtkImageMapToWindowLevelColors object.
Both of these vtkImageMapToWindowLevelColors objects are then fed to
the checkerboard, and then the checkerboard to the image actor.

This approach does allow me to change planes pretty easily.

However, in order to use the checkerboard, it seems that I have to
execute these lines of code:

  MovingReslice->SetOutputExtent(theFixedImage->GetExtent());
  MovingReslice->SetOutputOrigin(theFixedImage->GetOrigin());
  MovingReslice->SetOutputSpacing(theFixedImage->GetSpacing());

The problem is, I want to scale and place the image not according to
what the fixed image is doing, but according to the transform I have
set up:


  MovingTransform->Identity();
  MovingTransform->PostMultiply();
  MovingTransform->Scale(scaleChange[0], scaleChange[1], scaleChange[2]);
  MovingTransform->Translate(originChange[0], originChange[1], originChange[2]);

And then have the MovingReslice pad with zeros.  The idea is, the user
will interact with the transform to change the scaling, translation,
rotation, etc, and then the transform updates, causing the pipeline to
update.  Right now, I have to use the SetOutputExtent, Origin, and
Spacing to match the fixed image, otherwise I get crashes as the image
isn't correctly shaped.

How can I get ImageReslice to pad with zero and to require ONLY the
transformation matrix?

Or am I going about this all wrong?

Thanks,
Mark



More information about the vtkusers mailing list