So the problem is that I have a 3D projection of a rectangle that I want to turn into 2D. That is I have a photo of a sheet of paper laying on a table which I want to transform into a 2D view of that sheet.
Thus, what I need is to get an un-distorted 2D image by reverting all the 3D/projection transformations and getting a plain view of the sheet from the top.
I happened to find some directions on the subject but they don’t suggest an immediate instruction on how this can be achieved. It would be really helpful to get a step-by-step instruction of what needs to be done. Or, alternatively, a link on a resource that breaks it down to little details.
8
One factor that is really important to help understanding most any method of performing this operation is that you will be taking each pixel location of your END image and then calculating the position within the source image to calculate the pixel data from (using one of numerous interpolation methods.)
Understanding that the calculation goes “in reverse” is key to groking this type of transformation.
3
What you need to convert this with is morphing/warping using for example an algorithm called Catmull-Rom cubic spline interpolation.
The “correction” is easier to achieve if you don’t look at it as a 3D rectangle, but as a distorted perspective of an image.
Using morphing techniques can help you calculate the various interpolations along the two axis (how much you need to interpolate or not on a given x/y coordinate). The morph/warp is of course with a destination as a ‘perfect’ rectangle.
You didn’t state what language you prefer, but here are some resources on the topic with source code (the first one shows a more complex mesh, but you would only need one “square” of that making it simpler):
http://davis.wpi.edu/~matt/courses/morph/2d.htm
Link
Catmull-Rom cubic spline interpolation:
http://www.ibiblio.org/e-notes/Splines/Cardinal.htm
3