import image axis reorder and flipping

i need to work with itk images and numpy arrays, but the operations itk.GetImageFromArray and itk.GetArrayFromImage

e.g.:
img = itk.GetImageFromArray(input_img)

res_img = itk.GetArrayFromImage(img)

are flipping and are changing the axes of my image. How can I revert the res_img to the input_img orientation and disposition?

Is your array in Fortran order or C order? I think that ITK’s conversion might not fully support one (Fortran, I think). Can you try changing that using numpy, before converting to ITK image?

Thanks a lot for the feedback.
I solved my problem with: res_img.CopyInformation(input_img) method.

1 Like