# AffineTransform Rotate3D in Y-Axis

Hi:

I don’t know if I am so stupid or what, but anybodu knows how to rotate a 3D DICOM 180º in the y-axis? I used AffineTransform with Rotate3D and ResampleImageFilter. I even was able to rotate 180º in the z-axis but I can’t get it work for x or y ones.

I translate the image to the origin before rotation and re-translate to it’s original origin but always get weird visualization when try to rotate y or x axis…

Thank you in advance.

1 Like

Hello @Equis,

It seems that your are trying to just do a flip of your image. If so, you could juste use the dedicated filter : FlipImageFilter
If you want to go through resampling, you have to be careful about the origin of your image during the transform to be able to extract the right region.

HTH,

Tim

2 Likes

Hi @Equis,

There is no difference between rotating your image along y or z from the point of view of the implementation in ITK. As @tim-evain mentioned, the problem you are most likely having is that once transformed, your image is outside of your image space. You can try to compute what would be the correct output image space (I wrote this small tool that implement this functionality a while ago, you can take a look at the source code or use it). Otherwise you can use the filter that @tim-evain mentioned, but be careful that you will need two flips to get the same result as a rotation.

2 Likes

If I am rotating image at the origin point, how changes the origin of my image with a Y-Axis or X-Axis rotation, and how can I get it back?

Origin is defined as the coordinates of the first voxel (~ of lowest values) of your image in your reference space.
So you have to calculate which voxel of your image will become the one of lowest coordinates after rotation.
Let’s say for example that your image origin is {0,0,0} (same for region index) and its dimensions are {50,75,100} along X,Y and Z where directions are units along axes for simplicity (i.e. identity matrix).
You can calculate new origin based on the rotation matrix of the transform.
If you make a rotation of 180° around X, then the new origin is {0,-75,-100}. Around Y it will become {-50,0,-100}.

HTH,

Tim

EDIT : completing with @fbudin remarks

1 Like

@tim-evain Your answer is accurate if you do not take into account the image orientation (or if it is the identity matrix) or the index of your region that may not start at [0,0,0].

1 Like