AI Glossary / Computer vision and multimodal AI / Intermediate

Ratio test

Definition

The ratio test is a feature-matching rule that compares the distance to a descriptor's nearest candidate with the distance to its second-nearest candidate. A match is retained when the nearest candidate is sufficiently better, helping reject ambiguous correspondences.

What it means

The closest descriptor is not necessarily a reliable match. In a repeated pattern, several candidates may be almost equally similar. The ratio test asks whether the best candidate stands apart from its nearest competitor. For distances d₁ ≤ d₂, a common rule accepts when d₁/d₂ is below a chosen threshold. The idea is strongly associated with Lowe's SIFT matching method. It is a distinctiveness check, not a calibrated probability that a match is correct, and it normally precedes additional geometric validation.

How it works

For each query descriptor, retrieve at least two candidate neighbors under the selected distance metric. Compare the smallest distance with the second-smallest. A smaller ratio indicates a clearer separation. The threshold determines how selective the filter is: lowering it usually rejects more ambiguous matches, potentially losing valid matches too.
The distance convention matters. If an implementation returns squared Euclidean distances, a threshold intended for ordinary Euclidean distances must be squared for an equivalent comparison. Duplicate descriptors, a zero second-neighbor distance and approximate-neighbor errors require explicit handling. Candidate retrieval quality affects the test, because an incorrect second neighbor can make a match appear more distinctive than it really is.

Three practical examples

  • A panorama application filters tentative feature matches before estimating a homography.
  • An object-matching system rejects descriptors that fit several repeated structures almost equally well.
  • A visual-localization experiment compares ratio thresholds to balance retained correspondences against false matches.

Think of it this way

Think of choosing a candidate only when the best option has a meaningful lead over the runner-up. A tiny lead suggests ambiguity even if the best option is technically first. The analogy does not provide a universal confidence score, and two poor candidates can still have a large relative gap, so absolute fit and other evidence may remain important.

Worked example

Suppose the nearest descriptor distance is 30 and the second-nearest is 50. The ratio is 30/50 = 0.6, which passes an illustrative threshold of 0.75. Another query has distances 30 and 32, giving 0.9375, so it fails because the alternatives are too similar.
If the matcher reports squared distances, the first pair becomes 900 and 2,500. Their ratio is 0.36. To reproduce the ordinary-distance rule with threshold 0.75, compare squared-distance ratios with 0.75² = 0.5625. Applying 0.75 directly to squared distances would be a different, more permissive rule. The chosen threshold should be validated for the actual descriptors and task.

Illustrative case study

In a fictional building-recognition project, a team observes many feature matches on identical windows. The nearest-neighbor matcher supplies a match for almost every query, but several are spatially wrong. Adding a ratio test removes many ambiguous candidates, while a subsequent geometric check still rejects some distinctive-looking mistakes. The team evaluates the full pipeline rather than assuming either stage is sufficient alone. This case illustrates complementary checks without claiming a particular accuracy gain or universally correct threshold.

Common misconceptions and mistakes

The ratio is not a probability of correctness. A commonly cited threshold from one experiment is not a universal optimum for every descriptor or dataset. The test is also different from a mutual-nearest-neighbor check, which asks whether matching is reciprocal. Passing the ratio test does not prove geometric consistency or scene identity. Another mistake is ignoring whether distances are squared, approximate or calculated under a metric appropriate to the descriptor type.

Business use

For matching-based products, evaluate retained-match quality, geometric estimation success and failure cases across representative scenes. Include repeated textures, low-texture images and changes in viewpoint or illumination. Record the descriptor, distance metric, neighbor-search method and threshold. Avoid tuning only for the number of surviving matches: a smaller, well-distributed set can be more useful than a large cluster of unreliable ones. The final decision should consider downstream alignment or recognition performance.

People also ask

Why compare with the second-nearest candidate?

It gives a local measure of ambiguity: a close competitor weakens evidence that the nearest match is distinctive.

Does lowering the threshold keep more matches?

Usually it keeps fewer, because the best candidate must have a larger relative advantage.

Can the test replace RANSAC?

No. Descriptor distinctiveness and geometric consistency are different checks, and many pipelines use both.

Check your understanding

Distances 10 and 11 produce a closer best match than distances 20 and 40. Which pair has the stronger ratio-test separation?

Answer: The second pair, with ratio 0.5 rather than about 0.909. That does not by itself prove the second match is correct.

Related terms

  • Feature descriptor
  • Nearest neighbor
  • Ambiguity
  • SIFT
  • descriptor distance
  • mutual matching
  • approximate nearest neighbor
  • RANSAC
  • geometric verification

Learn next

Learn descriptor metrics and geometric verification next. Compare ratio filtering with reciprocal matching on a small set of descriptors, then inspect how each affects a fitted image transformation.

More in Computer vision and multimodal AI

  • Quantization error - Quantization error is the difference between an original value and the discrete value used to represent it after quantization.
  • Radon transform - The Radon transform represents a function through its integrals over lines.
  • Random sample consensus - Random sample consensus, usually called RANSAC, is a robust model-fitting method that repeatedly fits candidate models to small random subsets and evaluates...
  • Re-detection - Re-detection is the process of locating a previously tracked target again after tracking has failed, become uncertain or been interrupted.
  • Read noise - Read noise is random uncertainty introduced by the electronic process of measuring and reading a sensor's signal.
  • RED (Regularization by Denoising) - Regularization by Denoising, or RED, is an image-reconstruction framework that uses a denoiser to supply a preference for plausible images while fitting...

Sources

David Lowe, Distinctive Image Features from Scale-Invariant Keypoints: https://www.cs.ubc.ca/~lowe/papers/ijcv04.pdf University of British Columbia, feature-matching exercise describing the ratio criterion: https://www.cs.ubc.ca/~lowe/425/hw5/hw5.html Primary author-paper and teaching-source search excerpts consulted; full source and editorial review remain pending.

Previous: Ratio scale Next: Rational agent

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer