4
$\begingroup$

I am trying to use a linear transformation to straighten out the camera angle on this image:

enter image description here

In other words, I want to transform the image into a head-on view of the whiteboard.

I applied an affine transformation to that image, identifying the top left, top right, and bottom left corners, thinking that it would turn the image into a 1080x720 rectangle. However, here's what I ended up with:

enter image description here

As you can see, it is NOT a rectangle, but some sort of misshapen quadrilateral. It's close, but not exactly a head-on view of the whiteboard!

What exactly happened here? I really thought an affine transformation would work.

$\endgroup$
5
$\begingroup$

An affine transformation doesn't have enough freedom to do what you want. Affine transforms can be constructed to map any triangle to any other triangle, but they can't map any quadrilateral to any other quadrilateral.

One way to see this is that the matrix for a 2D affine transform has only 6 free coefficients. That's enough to specify what it does to 3 points, but not 4.

For this task you likely want a projective transformation. A 2D projective transformation has enough freedom to map any convex quadrilateral to any other.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.