PIXELBANKv9.1.0
Menu

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:

  1. Randomly sampling the minimum number of points needed to fit a model
  2. Fitting the model to these points
  3. Counting inliers (points that agree with the model)
  4. 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:

Input:
correspondences = [
  ((0,0), (1,1)),
  ((1,0), (2,1)),
  ((0,1), (1,2)),
  ((1,1), (2,2)),
  ((2,2), (3,3))
]
seed = 42
Output:
[((0, 1), (1, 2)), ((2, 2), (3, 3)), ((0, 0), (1, 1)), ((1, 0), (2, 1))]
Reasoning:
  1. Set random seed to 42 for reproducibility
  2. Use random.sample to select 4 unique correspondences
  3. With seed 42, the random selection returns indices 2, 4, 0, 1
  4. 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
๐Ÿ”’

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.

solution.py

Test Results

0/0
Run code to see test results.