Which Interpolator to Resample Image and its segmentation Mask

Dear community,

I have a set of CT images and their masks (segmentations). What I want to do is to rotate/resample them without losing the correspondence between the image and the mask.
Using the LinearInterpolator yields good images but bad segmentation masks, and using the NearestNeighbourInterpolator yields better masks but bad images.
Using the LinearInterpolator on the image and the NearestNeighbourInterpolator on the mask yields an image and a mask that don’t really match.
What would you suggest in this situation?

Thank you very much in advance!

I would suggest you double check this. This should work. How they don’t match? Small, one-pixel or so discrepancies, or large misalignments?

You can also try BSplineInterpolateImageFunction instead of linear for improved quality.

1 Like

Thanks for the quick reply and the suggestion.
The discrepancies are really small. When I view the image and its mask in ITK-Snap, I notice a couple of extra pixels in the mask that go over the edge of the original image; I was worrying that it would influence the sensitivity of the neural network I’m planning to feed them to.

If you rotate a binary mask and you need to minimize information loss then you can

  • resample the binary labelmap on a much finer grid than the original image (subdivide each voxel to 2x2x2 or 3x3x3 voxels), and/or
  • store resampling result in a fractional labelmap (where occupancy is not represented by a single bit but a scalar value).

There is a representation problem here that needs some thought and analysis for your particular problem and application.

Another option, is to use a distance map filter to convert the mask to a level set, where zero value is representation of the surface. This would readily resample well.