I have recently began to use SimpleITK for image registration. For my current project I need to register an X-Ray image and a CT image, and then apply the inverse matrix on a ROI mask traced on the X-Ray image.
I got the inverse matrix with this line:
inverse_transform = final_transform.GetInverse()
How can I apply the transform to the ROI mask?
Welcome to SimpleITK!
Assuming your X-ray is the fixed image in the registration (CT is the moving) then the result of the registration is a transformation mapping points from the X-ray to the CT. All you need to do is re-sample your ROI mask image onto the CT using the inverse transformation.
transformed_labels = sitk.Resample(xray_roi_mask,
ct_image,
inverse_transform,
sitk.sitkNearestNeighbor,
0.0, #out of bounds pixel color
xray_roi_mask.GetPixelID())
The last cell of this Jupyter notebook does this.
Two additional comments: