Affine Transformation of Points
Implement an affine transformation to map a list of 2D points using a given 2x3 transformation matrix. This process involves applying a linear transformation followed by a translation to each point.
The affine transformation is a fundamental concept in Computer Vision and Geometric Transformations, as it preserves straight lines and ratios of distances between points lying on a straight line. The transformation can be represented by the equation , where is the 2x3 transformation matrix and is the point in homogeneous coordinates.
Here are the steps to apply the transformation:
- Convert each point to homogeneous coordinates by appending 1 to the coordinates.
- Multiply the resulting vector by the 2x3 transformation matrix. The main equation for this process is:
This technique is widely used in image processing and computer vision applications.
Example
M = [[1, 0, 5], [0, 1, 10]] points = [[0, 0], [1, 1]]
[[5.0, 10.0], [6.0, 11.0]]
- We apply the affine transformation to the first point (0, 0) using the given matrix : .
- Then, we apply the same transformation to the second point (1, 1): .
- The transformed points are then rounded to 4 decimal places, but since the results are already integers, they remain the same.
- The final output is a list of the transformed points: .
Constraints
- M is a 2x3 matrix (list of 2 rows, each with 3 elements)
- points is a list of [x, y] pairs
- Return list of [x', y'] rounded to 4 decimal places