users > RE: Affine transformation order?
May 14, 2015  04:05 PM | Torsten Rohlfing
RE: Affine transformation order?
Hi Gerry -

What you really want to do is to use CMTK's "dof2mat" tool to convert the parametric representation to a matrix, which you can then multiply with the spatial coordinates. (There is also a "mat2dof" tool, should you ever need to go the other way).

The matrix you get from dof2mat applies to, and produces, actual spatial coordinates, i.e., in microns or whatever have you.

Note that all coordinates are assumed to be in "standard image space", which is "RAS". That is, when reading an image with an anatomy-based coordinate system, CMTK will internally reorient the image such that the fastest-varying index of the pixel array goes from subject Left to Right, the second-fastest varying index is subject Posterior to Anterior, and the third-fastest is Inferior to Superior. In terms of pixel coordinates that means that the space in which the transformations operate potentially differs from the natural space defined by the pixel order by a permutation of the coordinate axes and reflection of some (or none, or all) axes.

If your data have no such coordinate system (which is likely if you're dealing with, say, microscopy data), then your image should remain in its original pixel order and your transformations should basically operate in the image space that you expect, i.e., spatial coordinate is pixel index coordinate-wise multiplied with pixel size.

And just for the record, here are the answers to your detailed questions:

1) center is the center point of rotation, scale, and shear. Mathematically, this vector is subtracted from a coordinate before applying the transformation matrix, and re-added after. So if your translation is zero, then the center coordinate remains invariant.

2) Units of center and xlate are spatial coordinates, i.e., mm or microns or whatever you have in your images.

3) Units of rotation are degrees. The order of angles is: rotation around x, y, and z axes. Note that for historical reasons, the order in which these rotations are applied is different, unusual, and not something I actually remember myself.

Best,
  Torsten

Threaded View

TitleAuthorDate
Gerry Sun May 13, 2015
Greg Jefferis May 14, 2015
Gerry Sun May 14, 2015
Torsten Rohlfing May 15, 2015
RE: Affine transformation order?
Torsten Rohlfing May 14, 2015