FlipImageFilter (in ITK Simple filters) broken?


I have a volume which I want to flip along one of the axes, and I was very happy to find the FlipImageFilter in the list of Simple Filters. However, when I apply the filter, I don’t get the expected results.

The end result looks like nothing happened; If I’m lucky and observant enough, sometimes I can see the displayed volume flip and then flip back. When I examine the original vs. the filtered image, I can see that the content of the volume was indeed flipped – as can be evidenced by the relationship between space coordinates and grid coordinates – but the directions matrix is also changed (relevant value negated), and the total result is that the represented volume is exactly identical to the original.

Is this the intended effect?

Slicer 5.4.0 on Linux.


Flipping the image contents changes their memory layout but not the physical location. You can use a transform to change the physical location of the pixels (e.g. negate a column to flip).

Yes, that’s what I described – but it’s a bit surprising after looking at things like https://examples.itk.org/src/filtering/imagegrid/flipanimageoverspecifiedaxes/documentation

Probably the ITK example code doesn’t take into account the index to physical mapping. ITK originally didn’t include orientation in the images so some of the code and examples don’t include it.