[vtkusers] inhomogeneous image transform

David Gobbi dgobbi at irus.rri.on.ca
Fri Apr 6 16:42:32 EDT 2001


Hi Jeff,

There are some examples in contrib/examplesTcl, but probably not
specific enough.  So here is some general information that might
help you.

The vtkGridTransform takes a 'grid' of displacement vectors in the
form of a vtkImageData (or equivalently, vtkStructuredPoint) data
set.  Essentially, each 'voxel' in the grid has three components
that are the x, y, and z dispacement vectors.  You must ensure that
the Spacing and Origin of the grid are set up correctly such that
these vectors lie at the corners of voxels of your image data set.
(My preference is to have the vectors lie at the centers of the image
voxels, rather than the corners, but I'm guessing that you have your
reasons for defining the vectors at the corners).

It is probably easiest to create the grid outside of VTK, and read
it in with vtkImageReader, then feed it into the transform via
vtkGridTransform->SetDisplacementGrid(gridReader->GetOutput()).
Either that, or you can create a vtkStructuredPoints or vtkImageData
data set manually inside VTK.  You probably aren't going to want
to use vtkTransformToGrid for this.

Finally, to apply the grid to your image use

reslice->SetInput(imageData);
reslice->SetOutputSpacing(whatever the input spacing was)
reslice->SetOutputOrigin(whatever the input origin was)
reslice->SetOutputExtent(whatever input extent was)
reslice->SetResliceTransform(gridTransform->GetInverse())

Hopefully this will help you a little.  The biggest things to
look out for are:  1) ensure that the Origin and Spacing of
your image data and grid are set correctly and 2) ensure that
the transform is being applied in the correct direction.

 - David

--
  David Gobbi, MSc                    dgobbi at irus.rri.on.ca
  Advanced Imaging Research Group
  Robarts Research Institute, University of Western Ontario

On Fri, 6 Apr 2001, Jeff Weiss wrote:

> I need to apply an inhomogeneous transformation (warping) to a 3D image
> dataset.  The transformation is vector displacements of the voxel
> corners defined in the coordinate system of the image/voxels.  After
> transformation, I would like to resample the warped image back onto the
> same image voxel grid and output it.
>
> I have looked at vtkImageReslice, and vtkTransformToGrid, and I think
> that in theory there should be a way to do this in vtk, but have not
> been able to get anywhere, mainly because I can't find any relevant
> examples.  I am looking for ideas/suggestions as to how to implement
> this image processing pipeline.
>
> Thanks in advance,
>
> Jeff
>
>





More information about the vtkusers mailing list