[vtkusers] vtkTransform question

Anja Ende anja.ende at googlemail.com
Tue Sep 19 16:54:46 EDT 2006


ahhhhhhhhh great!

I had misunderstood it. I thought that the vtkTransformation somehow would
take the spacing into account...of course it cannot as it knows nothing
about the input data...

Thanks again. cannot wait to try it tomorrow.

Best wishes,

Anja


On 19/09/06, David Gobbi <dgobbi at atamai.com> wrote:
>
> Anja Ende wrote:
> > Hi David,
> >
> > Thanks for the explanation. I totally missed the postmultiply order.
> > So basically, this affects the order in which the transformations are
> > put on the stack, right?
>
> Basically yes, if you are thinking about the way glMultMatrix() works.
> But vtk transforms don't use a stack the same way that OpenGL does, so
> "stack" isn't quite the right word.
>
> > Also, back to the original question... It should be then enough to
> > provide the actual pixel values as translation values.
>
> No, that is the opposite of what I meant in my previous email.  The
> transformation must take the pixel spacing into account.  So if your
> pixel spacing is measured in millimeters, then you must give a
> translation in millimeters.
>
> > So, if you imagine that I have a volume that has the dimensions: 256 X
> > 256 X 120 and I want to traslate to 100, 100,  50... and then rotate
> > 30 degrees...
> >
> > I should have:
> >
> > myTransform->PostMultiply();
> > myTransform->Translate(100, 100, 50);
> > myTransform->RotateX(30);
> > myTransform->Translate(-100, -100, -50);
>
> First you have to translate the image so that voxel (100, 100, 50) ends
> up at the origin, which means that the translation must be in the
> negative direction.  Taking the Origin and Spacing of the image into
> account, you need this transformation if you want to rotate by 30
> degrees around that voxel:
>
> myTransform->postMultiply();
> myTransform->Translate(-(Origin[0] + Spacing[0]*100), -(Origin[1] +
> Spacing[1]*100), -(Origin[2] + Spacing[2]*50));
> myTransform->RotateX(30);
>   etcetera
>
> In VTK, transformations work in terms of physical coordinates, not in
> terms of voxels.
>
> - David
>
>
>
> >
> > Cheers and many thanks,
> > Anja
> >
> >
> > On 19/09/06, * David Gobbi* <dgobbi at atamai.com
> > <mailto:dgobbi at atamai.com>> wrote:
> >
> >     Hi Anja,
> >
> >     When you use vtkTransform with vtk image data, it takes the
> >     Spacing and
> >     Origin of the data into account.
> >
> >     You have to be careful about the PreMultiply(), PostMultiply()
> >     state of
> >     the transform, though.  These are two vtkTransform methods that
> >     you use
> >     to control whether the rotation, translations, etc. that you apply
> >     to a
> >     vtkTransform should occur before, or after the transformation
> already
> >     represented by the vtkTransform.
> >
> >     For example: let's say that you have a vtkTransform whose matrix
> >     is M.
> >
> >     If you do transform->PostMultiply(), and then perform a rotation R
> >     (where R is a 4x4 matrix), then the new matrix value M for the
> >     transform
> >     will be given by the following equation:
> >
> >     M = R M  (the new M is the product of matrices R and the old value
> >     of M)
> >
> >     If you do transform->PreMultiply() (or if you do nothing, since
> >     PreMultiply is the default):
> >
> >     M = M R (the transforms are applied in the opposite order)
> >
> >
> >     The way to think about this is that in PostMultiply mode, any new
> >     rotation, translations etc. that you do occur after any rotations,
> >     translations, etc. that you have already done.
> >
> >
> >     So if you want to translate and then rotate, make sure you are in
> >     PostMultiply() or you will end up with a vtkTransform that
> >     performs the
> >     rotation first and the translation second...
> >
> >     - David
> >
> >
> >
> >     Anja Ende wrote:
> >     > Hi everyone,
> >     >
> >     > Another qustion... I am really having a bad day...
> >     >
> >     > Been trying to play with the vtkTransform object and want to do
> the
> >     > following operations...
> >     >
> >     > Translate->Rotate->Translate back...
> >     >
> >     > I am getting a bit hairy results... Are the translate parameters
> >     > expressed in actual physical units... i.e . taking the spacing
> into
> >     > account...
> >     >
> >     > For example, I have an image data set that is centered using
> >     > vtkImageChangeInformation and I want to move to pixel (x, y) on a
> >     > particular slice (n) and then rotate 30 degrees around the X
> >     axes. How
> >     > does one go about doing these operations?
> >     >
> >     > Any small code/pseudo code would be awesome!
> >     >
> >     > Thanks,
> >     > Anja
> >     >
> >
> ------------------------------------------------------------------------
> >
> >     >
> >     > _______________________________________________
> >     > This is the private VTK discussion list.
> >     > Please keep messages on-topic. Check the FAQ at:
> >     http://www.vtk.org/Wiki/VTK_FAQ <http://www.vtk.org/Wiki/VTK_FAQ>
> >     > Follow this link to subscribe/unsubscribe:
> >     > http://www.vtk.org/mailman/listinfo/vtkusers
> >     >
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060919/75dc616c/attachment.htm>


More information about the vtkusers mailing list