Sample Minimal Set
You are given a list of point correspondences and need to randomly sample a minimal set for model estimation.
RANSAC (Random Sample Consensus) works by:
- Randomly sampling the minimum number of points needed to fit a model
- Fitting the model to these points
- Counting inliers (points that agree with the model)
- Repeating and keeping the best model
For different transformations:
- Translation: 1 correspondence
- Similarity (rotation + scale): 2 correspondences
- Affine: 3 correspondences
- Homography: 4 correspondences
This function samples 4 correspondences for homography estimation.
Example
correspondences = [ ((0,0), (1,1)), ((1,0), (2,1)), ((0,1), (1,2)), ((1,1), (2,2)), ((2,2), (3,3)) ] seed = 42
[((0, 1), (1, 2)), ((2, 2), (3, 3)), ((0, 0), (1, 1)), ((1, 0), (2, 1))]
- Set random seed to 42 for reproducibility
- Use random.sample to select 4 unique correspondences
- With seed 42, the random selection returns indices 2, 4, 0, 1
- Return the correspondences at these indices
The sample is used to compute a homography hypothesis.
Constraints
- correspondences is a list of ((x1,y1), (x2,y2)) pairs
- seed is used for reproducible random sampling
- Return exactly 4 randomly sampled correspondences