Homography Point Transformation
Implement a perspective transformation using a given 3x3 homography matrix on a list of 2D points. This process is crucial in Computer Vision for transforming images or points between different coordinate systems.
The concept of homography is based on the idea that two images of the same planar scene are related by a perspective transformation, which can be represented by a matrix . To apply this transformation to a point , we first convert it to homogeneous coordinates.
Here are the steps to apply the transformation:
- Convert the point to homogeneous coordinates:
- Apply the homography matrix:
- Normalize the result: ,
This technique is widely used in image processing and Computer Vision applications.
Example
H = [[1, 0, 0], [0, 1, 0], [0, 0, 1]] points = [[1, 2], [3, 4]]
[[1.0, 2.0], [3.0, 4.0]]
His a matrix describing a planar perspective mapping;pointsholds two 2D points, and , in pixel-style coordinates.- Here is the identity: ones on the diagonal, zeros elsewhere. The top-left block (no rotation or scaling), the last column (zero translation) and the bottom row (no perspective) all say "change nothing".
- Lifting to homogeneous form gives . Each output row is a dot product with that vector: , then , and the third component is .
- Dividing by leaves ; the same arithmetic sends to itself, giving
[[1.0, 2.0], [3.0, 4.0]]. - Notice the values print as
1.0, not1: the perspective divide always produces real numbers, even when . With a non-zero bottom row, would vary per point and points with larger would be pulled closer to the origin, which is exactly the perspective effect.
Constraints
- H is a 3x3 matrix
- points is a list of [x, y] pairs
- The third coordinate after multiplication will not be zero
- Return list of [x', y'] rounded to 4 decimal places