I want to generate DRR from a CT image. I want the CT image to rotate in the order of the X, Y, Z axis. However, SetComputeZYX( ) only set the order ZYX/ZXY. How can I can set the order XYZ?
You could compose two transforms, one ZXY with z angle of zero, and the another with x and y angles of zero.
Thank you for your sincere reply! And I try to compose two transformations. However, the latter transform always works and the first transform seems to be not applied. I have found one of your replies before that may also be suitable for my question. Could you please introduce “computing internal data” in detail? “@pierrectl is trying to compose two Euler3DTransform
s, if I understood correctly. Those are two transformations in the global domain. Computing internal data (matrix, center, translation) is probably easier with versor than affine. ”
If you share your code, there is a chance of receiving more help.
Hello @suzume,
What you are asking for is just a different way of specifying the rotation matrix from that supported by the ITK API. If you want the rotation order to be XYZ then you can compute the matrix yourself and then use the transforms SetMatrix
method.
Computing the XYZ matrix is easy to do, Python code below (translating to other lanaguges is pretty much a copy paste and adding some semicolons if relevant):
import numpy as np
ax = 0
ay = 0
az = np.deg2rad(90)
cx = np.cos(ax)
cy = np.cos(ay)
cz = np.cos(az)
sx = np.sin(ax)
sy = np.sin(ay)
sz = np.sin(az)
rotation = np.ndarray([3, 3])
rotation[0][0] = cz * cy
rotation[0][1] = cz * sy * sx - sz * cx
rotation[0][2] = cz * sy * cx + sz * sx
rotation[1][0] = sz * cy
rotation[1][1] = sz * sy * sx + cz * cx
rotation[1][2] = sz * sy * cx - cz * sx
rotation[2][0] = -sy
rotation[2][1] = cy * sx
rotation[2][2] = cy * cx
Thank you very much! I will try it!