Rectify image from congruent planar shape objects

I will assume that the two depicted bright polygons are congruent in the world plane. If they are not, then I guess you won't have enough information to reconstruct anything.

The first step is finding a projective transformation which maps one of the polygons onto the other. That transformation is uniquely defined using four points and their images, and I've described this computation in detail in another post. So choosing any four pairs of matching corners will give you that matrix. Originally I had assumed that this is the transformation you were interested in, but I had not read the question carefully enough. The transformation you just found describes the rotation of one polygon onto the other in the image plane.

Next, you look for fixed points of the transformation. You find these as eigenvectors of the transformation matrix. In $\mathbb C\mathrm P^2$ you should get three fixed points, one of them real and two complex and conjugate to one another. The real one is your center of rotation. The complex fixed points correspond to the ideal circle points $I=(1,i,0)^T$ and $J=(1,-i,0)^T$, which remain fixed under every similarity transformation.

By the way: The join of the two complex points corresponds to the vanishing line. Which in your image is way outside the picture area. But knowing the vanishing line is less useful than knowing the locations of $I$ and $J$ as we do, since these points can be used to define angles, so they will help you avoid skewing.

Now you can again choose four points and their images to define a projective transformation. This time, you map the complex fixed points to $I$ and $J$, and you map the center of rotation to wherever you want it to lie in your reconstructed image, e.g. the origin. You still have one point which you can choose arbitrarily. Its image will fix the scale and orientation of the reconstructed image. Strictly speaking, you don't have to take the center of rotation as one preimage point either: as long as you correctly map $I$ and $J$ from image coordinates to world coordinates, you can choose any two pairs of real points to uniquely define the projective transformation.

Counting degrees of freedom, the two arbitrarily chosen points above amount to four real degrees of freedom, matching the four degrees of freedom of a similarity transformation. Everything else is fixed. In particular, not only parallel lines but also angles are reconstructed.


I've just implemented the above description as a proof of concept using Cinderella. The center of rotation, drawn in green, appears to coincide with the upper boundary of your picture. The points P1, P2 and R2 were chosen arbitrarily.

Original and reconstructed image