Estimate Translation
Implement a function to estimate the optimal translation that aligns two point sets with known correspondences. This problem is rooted in Least Squares Alignment, a fundamental concept in Image Alignment and Stitching, where the goal is to find the best transformation that minimizes the distance between two sets of points.
The translation vector that achieves this alignment can be found by considering the centroids of the source and target point sets, which are the average positions of all points in each set. The optimal translation is the vector that moves the centroid of the source to the centroid of the target.
Here are the steps to estimate the translation:
- Compute the centroid of the source point set.
- Compute the centroid of the target point set.
- Calculate the translation vector as the difference between the target and source centroids.
This technique is widely used in computer vision applications, such as image registration and object tracking.
Example
source = [(0, 0), (1, 0)] target = [(5, 5), (6, 5)]
(5.0, 5.0)
- Inputs:
sourceholds points , , andtargetholds their partners , . Point of one list corresponds to point of the other. - Source centroid: .
- Target centroid: .
- Translation: , rounded to 4 decimal places, giving
(5.0, 5.0)as a pair . - Check: adding to each source point gives and , exactly the targets, so the squared alignment error is .
- Notice: with noisy points no single shift fits every pair, yet the centroid difference still minimises that sum of squared errors. Each pair "votes" for and the result is the average vote.
Constraints
- source and target are lists of corresponding (x, y) points
- Return translation as (tx, ty) tuple
- Round to 4 decimal places