Compute Inlier Mask
You are given point correspondences and a translation model, and need to determine which correspondences are inliers.
A correspondence ((x1, y1), (x2, y2)) is an inlier if the predicted point matches the actual target point within a threshold:
error=(x1​+tx​−x2​)2+(y1​+ty​−y2​)2​
If error < threshold, the correspondence is an inlier.
The inlier mask is used to:
- Count support for a model hypothesis
- Refine the model using only inliers
- Identify and remove outlier correspondences
Example:
correspondences = [((0,0), (1,1)), ((0,0), (5,5))] transform = (1, 1) threshold = 0.5
[True, False]
Testing each correspondence against the translation (1, 1):
Correspondence 1: (0,0) → (1,1)
- Predicted: (0+1, 0+1) = (1, 1)
- Actual: (1, 1)
- Error = √((1-1)² + (1-1)²) = 0.0
- 0.0 < 0.5 → INLIER
Correspondence 2: (0,0) → (5,5)
- Predicted: (0+1, 0+1) = (1, 1)
- Actual: (5, 5)
- Error = √((1-5)² + (1-5)²) = √32 ≈ 5.66
- 5.66 >= 0.5 → OUTLIER
Result: [True, False]
Constraints:
- correspondences: list of ((x1,y1), (x2,y2)) pairs
- transform: (tx, ty) translation vector
- threshold: maximum Euclidean distance for inlier classification
- Return list of boolean values (True for inliers)
More from CV: Image Alignment and Stitching
You are checking, for each point correspondence, whether a given translation explains that match within some distance threshold, and then encoding the result as an inlier mask (e.g., a boolean array).
1. Background Knowledge
In RANSAC (Random Sample Consensus) for image alignment, you repeatedly hypothesize a transformation (here, a simple 2D translation (tx​,ty​)) from a minimal set of correspondences, then evaluate how many other correspondences agree with this hypothesis. A correspondence (x1​,y1​)→(x2​,y2​) agrees with a translation if translating the source point by (tx​,ty​) lands very close to the target point.
To measure agreement, you compute a geometric error, typically the Euclidean distance between the predicted target point and the actual target point. For a translation model, the predicted point is (x1​+tx​,y1​+ty​). The error is:
error=(x1​+tx​−x2​)2+(y1​+ty​−y2​)2​.If this error is below a user-chosen threshold, the correspondence is labeled an inlier; otherwise, it is an outlier. The vector of inlier flags is called the inlier mask and is central to RANSAC: it tells you which points support the model and which should be ignored when refining it.
2. Algorithm / General Approach
For a given translation hypothesis (tx​,ty​):
- For each correspondence:
- Compute the predicted target location using the translation.
- Compute the distance between the predicted and actual target location.
- Compare each distance to the threshold.
- Mark each correspondence as inlier if its error is less than the threshold, else outlier.
- Return these decisions as an inlier mask (e.g., an array of booleans or 0/1s).
Pattern-wise, this is a vectorized distance-thresholding problem over all correspondences.
3. Step-by-Step Strategy
Assume you have:
- Arrays of source points: xs1, ys1
- Arrays of target points: xs2, ys2
- Translation parameters: tx, ty
- Scalar threshold
Steps:
- Apply translation to source points For each correspondence i:
- \hat{x}2(i)​=x1(i)​+tx​
- \hat{y}2(i)​=y1(i)​+ty​
Continue the full explanation
You're reading the free preview. Unlock the complete walkthrough, the code editor, test runner and reference solution with Premium.
Editor locked
The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.