Perspective transformation for binary images

I am trying to register two binary images. The fixed image is a planar shape, and the moving image comes from a camera image of the same shape but additionally has a perspective distortion due to the camera angle. Here is an example:


For this simple example, I used an affine transformation as an approximation, but it’s not perfect since any lines that are parallel before an affine transformation stay parallel afterwards, as it only does rotation, scale, shear, and translation.

I believe what I need is a projective/homography transformation that will take into account the perspective distortion.

Do you know if any image registration tool can apply projective transformations? I used SimpleElastix in this example.

Thank you very much for your help and interest.

Kind regards,