Flip image along an axis

Hi Mark,

Thanks for sending this python snippet but I don’t know how to implement this code. I did read the discussion titled Running python file in Slicer on Mac from July 2022 and that made it clear that this is way beyond my skill level. Hopefully others will be able to benefit from your expertise.


First of all, make sure that your image is really flipped and not rotated. If it is indeed flipped then it may be also incorrect in other ways, such as its spacing, position, or orientation may be corrupted, too. How did you get a flipped image? Can you fix the process of obtaining the image? It would be safer than applying some arbitrary fix later.

If you want to mirror an image along one or more axes then you can do that using the graphical user interface:

  • create a new transform in Transforms module
  • change diagonal value in the matrix from 1 to -1 for the axes you want to flip around
  • apply and harden the transform on the image

Would the ‘Filtering / Simple filters / FlipImageFilter’ be an option too? Its main advantage would be using a single tool.

1 Like

There are many ways to do it. There may be differences between the options in how flipping is done, for example if image voxels are reordered or only the IJK to RAS matrix is modified.

Hi Andras,

This solved my problem. Thanks.

We don’t know how the orientation of the microCT images became reversed in the first place as they came from another source. There is no question of the reversal, however, as we produced a segmented version the mandible and compared it with a photograph of the specimen. We will definitely contact the folks who made the original scan regarding this issue. It certainly would be best to fix the problem at its source but in this case we had many segmenting hours invested in this project that we did not want to abandon.

Thanks for your support,


1 Like