Overview
RANSACScoringDoneRight is the scoring package of the paper RANSAC Scoring Done Right: the scale-free marginal score and its sort-and-sweep, Student-t posterior weighting, the threshold-based baselines it is compared against, and CPU/GPU grid evaluators that score a stored hypothesis pool at every value of a hyperparameter grid. It is problem-agnostic: a consumer supplies residuals, or a problem implementing VisualGeometryToolkitCore's AbstractConstraintProblem.
It sits in a stack of Julia packages:
| package | role |
|---|---|
| VisualGeometryToolkitCore | geometric types, Uncertain/whiten, the robust-loss shapes, the contracts (problem protocol, scoring, local optimization, pool selection), the Student-t posterior toolkit, the MSAC/RANSAC baseline scorers, and the benchmark pool record PoolPair |
| RANSACScoringDoneRight | scoring: the marginal score and the paper baselines on the scoring contract, their grid evaluators on the pool-selection contract; depends on VisualGeometryToolkitCore, and on VisualGeometryToolkitEstimation for SIMFIT++ |
| VisualGeometryToolkitEstimation | the RANSAC loop, the concrete problems (homography, fundamental and essential matrix, …), the core local optimizations and SIMFIT++ |
| LocalOptimizationDoneRight | the state-of-the-art local-optimization strategies |
| VisualGeometryToolkitEval | pool IO, statistics, tuning (including the scale-prior fits), the evaluation engine, rendering |
A caller composes them: VisualGeometryToolkitEstimation's find_* take a scorer from this package and a strategy from LocalOptimizationDoneRight as scoring = …, local_optimization_strategy = ….
Scoring versus selection
A RANSAC score assigns a value to one model hypothesis from its residuals; selection keeps the hypothesis with the best score. This package does both, at two granularities:
- one hypothesis:
score_residuals!(from residuals) orscore_sq_residuals!(from a problem and a model) returns the score and the inlier count of the best partition; - a pool of hypotheses: VisualGeometryToolkitCore's
best_pool_modelselects the best stored model of one benchmark pair, andgrid_evaluatedoes so for every pair of a staged pool at every width of a grid, which is what tuning and the paper's evaluation consume.
The scale-free marginal score also selects an inlier partition: the sweep returns the inlier count k it maximized over, and the scale of that partition (VisualGeometryToolkitCore's consensus_s2) follows in closed form. That partition and scale seed local optimization through the scoring contract (consensus_order, inlier_count, decision_boundary) and VisualGeometryToolkitCore's posterior-weighting layer (PosteriorWeightState).
The contracts this package implements
Both contracts are VisualGeometryToolkitCore's; this package implements them for its own types.
- Scoring.
StudentTUniformScoringimplementsscoring_workspace(aScoringWorkspace),score!,inlier_count,consensus_order,decision_boundary,scale_prior,outlier_halfwidth,check_workspaceandwith_width/width_axis; its{Predictive}form addsis_predictiveandscored_model. Any RANSAC written against the contract, VisualGeometryToolkitEstimation's among them, runs it unchanged. The loss-width families at a loss width implementscore!(withwith_width/width_axis), what pool selection reads. - Pool selection. Every grid family here declares one staging (
selection_staging,stage_selection:stage_ig_shared_from_pairsshared by all of them) and implementsselect_on_grid!with its device kernels. VisualGeometryToolkitCore's genericselect_on_grid!andbest_pool_modelserve any scorer at its width.
What the weights mean
A robust result carries per-point weights, and what they mean is a trait of the scorer's type, VisualGeometryToolkitCore's weight_kind; its inlier_mask cuts them by that kind.
- Binary. Every loss-width family here (MLESAC, MAGSAC++, the Welsch, smooth-TLS and Geman–McClure costs) is an
AbstractThresholdScoring, as RANSAC and MSAC are, so its kind isBinaryWeights: a weight is the 0/1 consensus membership, and the inlier mask isw > 0. None of them has anoutlier_halfwidth(it isnothing), so the weights stay that membership. - Posterior.
StudentTUniformScoring, at a fixed outlier half-width or with one of this package's outlier models (OutlierTerm,GeneralizedParetoOutliers,ExtremeValueHalfwidth), isPosteriorWeights: posterior inlier probabilities, cut by the MAP ruleis_map_inlier(posterior > ½).
using RANSACScoringDoneRightusing VisualGeometryToolkitCore: weight_kindweight_kind(typeof(MagsacScoring(2))) # BinaryWeights()weight_kind(typeof(loss_width_scoring("welsch_cost", 1))) # BinaryWeights()test/weight_kind_tests.jl holds these claims for every scorer the package defines.
The scorers
The scale-free marginal score. For a fixed inlier partition the Gaussian inlier scale is integrated out under a conjugate inverse-gamma prior, leaving a closed form in the residual sum of squares, the inlier count and the outlier half-width a of the uniform outlier component. Sorting the residuals once lets one sweep score every partition, so a hypothesis costs O(N log N). StudentTUniformScoring is the spec (VisualGeometryToolkitCore's; its scale and label priors required keywords, the stack's defaults a configuration's: VisualGeometryToolkitEstimation's [scoring.student_t_uniform]), ScoringWorkspace the sweep buffers. StudentTUniformScoring{Predictive} adds the model's estimation covariance to every point's residual covariance; it is an option, not the default (see Conventions).
The threshold-based family. RANSAC, MSAC, MLESAC (the paper's GaU) and MAGSAC++ are singleton types (VisualGeometryToolkitCore's RansacScoring and MsacScoring, MlesacScoring, MagsacScoring), together with three robust costs (Welsch, smooth TLS, Geman–McClure). They form the LossWidthScoring union: each takes a loss width, and each scores through one per-residual scalar, residual_quality. Every scoring carries its constraint codimension DG, because a loss width means a different multiple of the scale at each codimension.
The mixture's decision boundary. GauInlier is the Gaussian-uniform mixture; decision_boundary and its inverse decision_width are the one map between an outlier half-width and the residual at which the MAP inlier/outlier decision flips, so a grid of outlier half-widths is never confused with a grid of thresholds.
Scale priors
VisualGeometryToolkitCore's IGPrior(α₀, β₀) is the inverse-gamma prior on σ²; IGPrior() (also spelled JeffreysPrior()) is its α₀ = β₀ = 0 limit, the non-informative Jeffreys prior, which needs no validation data. In the conjugate update the prior acts as 2α₀ pseudo-residuals carrying 2β₀ of pseudo-RSS, so where a pair has many inliers the data dominate and the informative priors approach the Jeffreys limit.
The paper's empirical-Bayes variants fit the prior from per-pair noise-variance estimates on a validation set (VisualGeometryToolkitEval's Tuning.PriorSpec and Tuning.fit_prior):
| variant | prior | fit |
|---|---|---|
| Jeffreys | IGPrior(0, 0) | none (JeffreysPriorSpec) |
| IG-MLE | IG(α₀, β₀) | type-II maximum likelihood: a Gamma fit to 1/σ̂² |
| IG-Robust | IG(1, median(σ̂²)) | fixed α₀ = 1, median-anchored β₀ (IGRobustSpec) |
IG-Robust trades the dispersion information of IG-MLE for robustness to the heavy σ̂² tails of pairs with few inliers, the regime where the prior matters.
Widths and native units
Every scorer has one hyperparameter, a width, and each family's width lives on its own axis: the outlier half-width for the marginal scores, the loss width for the threshold-based family. VisualGeometryToolkitCore's width_axis(scoring) names a scorer's axis (OutlierHalfwidth or LossWidth); its to_native maps an efficiency constant (a width as a plain multiple of the noise scale) onto it and native_map is that map curried, so that grids for different families can be laid out over comparable neighbourhoods of the same noise scale. The vocabulary is fixed: efficiency_constant is that multiple, loss_width is a loss's scale parameter, outlier_halfwidth the half-width of the uniform outlier support, decision_boundary the residual at which the MAP rule flips, s2 a variance and ŝ/s_hat_sq the scale estimate and its square.
The pool frame
The benchmark pool — VisualGeometryToolkitCore's PoolPair record together with its num_points × num_models Float32 residual matrix — stores correspondences, models and residuals in NormalizedImageFrame: the image centre at the origin, scaled by half the image diagonal so the corners lie at unit radius. It is the one declared exception to the stack's rule that a public function returns results in the frame its inputs came in. Every width applied to pool data (outlier half-width, loss width, IG prior, every grid_evaluate grid) is in that frame's unit, and VisualGeometryToolkitCore's Pools.pixel_residuals is the one exit to pixels. Conventions states the rule and what it demands of this package.
Where the paper's experiments live
This repository holds the package and, in neurips2026/, the paper's research project: the manuscript, the drivers that draw its Profile and Sensitivity figures, their configs of record and the asset index neurips2026/REPRODUCE.md, plus the write-ups of the retired scoring studies (Experiments). The figures regenerate byte for byte from the six stored evaluation runs of record; the evaluation that produced those runs (pools, coarse probes, the per-pair grid evaluation and the bootstrap) predates the current stack and is documented in REPRODUCE.md but not yet ported. The bootstrap evaluation harness that once lived in this package moved to VisualGeometryToolkitEval.