[vtkusers] Transformation of image data

Pelt, R.F.P. van R.F.P.v.Pelt at tue.nl
Sun Nov 2 09:00:32 EST 2008


Dear all,

 

I've been searching through the mailing list. Although there are several
questions about transformations, 
I could not really find an answer that really clarifies transformations
in VTK.

 

Currently I have a vtkImageData structure, containing a pointDataSet
with data arrays containing scalars and vectors.

 

I know that originally the data is flipped on the y and z axis, and that
the whole dataset needs to be rotated.

I prefer not to resample that data, because this may add interpolation
artefacts early on in my visualization pipeline.

 

So I've found vtkMatrix4x4 to hold my transformation matrix, and
vtkTransform to carry out the transformation.

However, I think that for the vtkImageData I'd need to use the
vtkTransformFilter. 
(am I right? can I apply transformations on the level of image data?)

 

So an initial attempt looks like this (just with an identity matrix so
far):

 

  vtkMatrix4x4 *mat = vtkMatrix4x4::New();

  mat->SetElement(0,0, 1.0);

  mat->SetElement(0,1, 0.0);

  mat->SetElement(0,2, 0.0);

  mat->SetElement(0,3, 0.0);

  mat->SetElement(1,0, 0.0);

  mat->SetElement(1,1, 1.0);

  mat->SetElement(1,2, 0.0);

  mat->SetElement(1,3, 0.0);

  mat->SetElement(2,0, 0.0);

  mat->SetElement(2,1, 0.0);

  mat->SetElement(2,2, 1.0);

  mat->SetElement(2,3, 0.0);

  mat->SetElement(3,0, 0.0);

  mat->SetElement(3,1, 0.0);

  mat->SetElement(3,2, 0.0);

  mat->SetElement(3,3, 1.0);

 

  vtkTransform *trans = vtkTransform::New();

  trans->SetMatrix(mat);

 

  vtkTransformFilter *filter = vtkTransformFilter::New();

  filter->SetInput(imageData);

  filter->SetTransform(trans);

  filter->Update();

 

The problem now is the get an output image data that I can pass on to
the next stage of the pipeline.

 

Can anyone help me to get this right?

 

Thanks in advance!

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081102/ee0fc972/attachment.htm>


More information about the vtkusers mailing list