HOMOGRAPHY
The perspective transformation that takes four or more positions to four or more others.
Syntax
HOMOGRAPHY(from,to)
| Argument | Meaning |
|---|---|
| from | A list of four or more positions: {P1,P2,P3,P4}. No three of them on one line. |
| to | A list of as many positions: where each position of from goes, in the same order. |
Result
A transformation (a MATRIX with nine numbers): a position times it is where the perspective takes it. With four positions each goes exactly where it is told; with more, the transformation is the best fit to them all (least squares), so a position measured a little wrong pulls the result only a little.
Examples
In the example drawing:
| Expression | Gives |
|---|---|
[50,100]*HOMOGRAPHY({[0,0],[100,0],[100,100],[0,100]},{[0,0],[200,0],[150,100],[50,100]}) |
[100,100] |
[50,50]*HOMOGRAPHY({[0,0],[100,0],[100,100],[0,100]},{[0,0],[200,0],[150,100],[50,100]}) |
[100,66.666667] |
[3,4]*HOMOGRAPHY({[0,0],[10,0],[10,10],[0,10]},{[5,5],[5,15],[-5,15],[-5,5]}) |
[1,8] |
The first two take a square to a trapezium, as a square photographed at an angle looks: the middle of the square goes to [100,66.666667], not to the middle of the trapezium. The third is only a quarter turn and a move, and gives that ordinary transformation.
Notes
A homography is the most general transformation that keeps straight lines straight. It is what a photograph or scan taken at an angle does to a drawing, and so it is what corrects one: measure four or more marks in the photograph (from) and give where they really are (to), then multiply positions by it. Lines stay lines; circles and arcs become ellipses (or, near the transformation's vanishing line, parts of hyperbolas).
It works like any other transformation: INVERSE undoes it, it can be multiplied by others,
and a position on the line it sends to infinity is an error. TRANSFORM moves points by it
(TRANSFORM [P1..P8],H), and lines and polylines on those points follow, staying straight. Where elements themselves
are transformed by it, a curve becomes its exact image, a NURBS curve: a Bézier or NURBS curve on
its own points transformed, a circle, arc or ellipse fixed where it is now.
Camera registration fits a homography like this to each frame of a cutting job.