#5065·kornia

conv_quad_interp3d / iterative_quad_interp3d reject any fit with |det H| <= 1e-7 (an absolute floor on a cubic quantity), so ScaleSpaceDetector leaves 97.6% of its keypoints unrefined on a [0, 1] image

Author: ducha-aikiCreated Sep 28, 2026Updated Sep 28, 2026

conv_quad_interp3d and iterative_quad_interp3d accept a quadratic fit only when |det H| > 1e-7, where H is the 3×3 Hessian of the response (_solve_cramer_sym3x3, kornia/geometry/subpix/spatial_soft_argmax.py, solved = det.abs() > eps with eps = 1e-7; the CUDA path passes the same eps). The floor is absolute, but det H is cubic in the response amplitude. A well-conditioned fit on a response scaled by 1e-3 has det H = -6e-9 and is rejected as singular, so the maximum keeps its integer coordinates. The detector responses of a [0, 1] image sit far below that floor, so ScaleSpaceDetector returns almost every keypoint unrefined.

Reproduction

python
import functools

import torch

import kornia
import kornia.geometry.subpix.spatial_soft_argmax as ssa
from kornia.geometry.subpix import conv_quad_interp3d, iterative_quad_interp3d
from kornia.io import ImageLoadType, load_image

# One maximum with a 0.5 neighbour to its right: the fit is the same parabola at every amplitude, x = 5 + 1/6.
for scale in (1.0, 1e-2, 1e-3):
    v = torch.zeros(1, 1, 4, 6, 9, dtype=torch.float64)
    v[0, 0, 1, 2, 5] = 1.0 * scale
    v[0, 0, 1, 2, 6] = 0.5 * scale
    for fn in (conv_quad_interp3d, iterative_quad_interp3d):
        coords, _ = fn(v)
        print(f"{fn.__name__:24s} amplitude {scale:g}: x = {coords[0, 0, 1, 1, 2, 5].item():.4f}")

# ScaleSpaceDetector on a natural image in [0, 1] (any photo; this one ships with the docs).
img = load_image("docs/source/_static/img/DISK.png", ImageLoadType.GRAY32)[None]


def integer_fraction() -> float:
    lafs, _ = kornia.feature.ScaleSpaceDetector(1000)(img)
    xy = kornia.feature.get_laf_center(lafs)[0]
    return ((xy - xy.round()).abs().amax(-1) < 1e-4).float().mean().item()


print(f"ScaleSpaceDetector, keypoints left at integer (x, y): {integer_fraction():.3f}")
orig = ssa._solve_cramer_sym3x3
ssa._solve_cramer_sym3x3 = functools.partial(orig, eps=0.0)
print(f"same, determinant floor removed:                     {integer_fraction():.3f}")
conv_quad_interp3d       amplitude 1: x = 5.1667
iterative_quad_interp3d  amplitude 1: x = 5.1667
conv_quad_interp3d       amplitude 0.01: x = 5.1667
iterative_quad_interp3d  amplitude 0.01: x = 5.1667
conv_quad_interp3d       amplitude 0.001: x = 5.0000
iterative_quad_interp3d  amplitude 0.001: x = 5.0000
ScaleSpaceDetector, keypoints left at integer (x, y): 0.976
same, determinant floor removed:                     0.019

kornia main 78cd06c35, torch 2.14.0 and 2.5.1 (same output), CPU, macOS arm64.

Measured on the same image with IterativeQuadInterp3d as the sub-pixel module, at the NMS maxima of every octave: with BlobHessian (the default response) 99.1% of the maxima have |det H| <= 1e-7, with median |det H| = 5.7e-12; with CornerGFTT the figure is 95.1%. The CenterCrop.png docs image gives 94.6% and 72.7%.

Expected

A fit with a well-conditioned Hessian refines the maximum whatever the amplitude of the response: x = 5.1667 in every row of the first block, and ScaleSpaceDetector keypoints at sub-pixel positions. The comment in _solve_cramer_sym3x3 expects the determinant of a [0, 1] response to "land around 1e-4". The measured median is seven to eight orders of magnitude lower.

Classification

Silent loss of accuracy: sub-pixel refinement is skipped with no error or warning, and the detector returns integer keypoints. It was introduced with the Cramer solver in #3616 and has shipped since v0.8.3. The earlier solve (safe_solve_with_mask) rejected only a failed LU factorisation.

Disposition

The batch-10 Convention block of conv_quad_interp3d states the rule as it is ("the determinant of its fit's Hessian is at most 1e-7 in magnitude"). A Known-defects line links this issue once it is filed. Fix direction: make the test scale-invariant. Options are a relative threshold such as |det H| <= eps · max(|H_ii|)³, or accepting every finite solve and letting the existing |shift| <= 1.5 bound reject the ill-conditioned ones. The CPU and CUDA solvers share the threshold, so both change together.

Related

  • #5038 (last-iteration stale shift) is the other open quad-interp defect; it is independent of this one.
  • #4257 / #4305 moved the float16 solve to float32 and did not touch the threshold.

Posted on behalf of @ducha-aiki by Claude (Opus 5.5).