refine_lm — 3D refine op

• 数据种类:voxel × voxel × position → table

• 调用: import fullseye as fs; fs.ledger.refine_lm(scene, template, init_pos, device='cpu', iters=50, scale=True, gain=False, lam0=0.001, tol=1e-08)(要直接调用实现,import match3d; match3d.refine_lm(scene, template, init_pos, device='cpu', iters=50, scale=True, gain=False, lam0=0.001, tol=1e-08);从台账取用则 ops3d.get("refine_lm"))

• GPU:该算子有 GPU 路径(device="cuda")

用法

用 Levenberg-Marquardt 做平移(+各向同性缩放/亮度增益)的亚体素精化。

以粗匹配位置 init_pos(模板中心在 scene 内的坐标 [z,y,x])为起点, 用带阻尼的 Gauss-Newton(LM)求解 forward-additive Lucas-Kanade,使 SSD

E(p) = Σ_x [ I(W(x;p)) - g·T(x) ]²

最小化。将整数 NCC / Fourier-Mellin / Hough 的粗估计收敛到连续坐标的后段。

变形 W(x;p) = t + s·(x - c_T) (c_T=模板中心, t=平移, s=各向同性缩放)

雅可比 ∂I(W)/∂p 通过让 grid_sample 经过自动微分精确获得(三线性插值的解析梯度。

不动点与真正的 SSD 最小值一致 → 避免 sobel 常数倍的偏差,精度高)。

LM Δp = -(H + λ·diag(H))⁻¹ b,成功(代价下降)时 λ×0.4 衰减、失败时 λ×5 增大。

参数:

scene : 场景 volume (D,H,W)。

template : 模板 volume (Td,Th,Tw)。比 scene 小。

init_pos : 粗略的模板中心位置 [z,y,x] (voxel。NCC locate 的 [d,h,w] 等)。

device : "cpu" / "cuda"。与 device 无关。

iters : 最大迭代次数(通常 4-6 次收敛)。

scale : True 时同时优化各向同性缩放 s(4 个参数)。False 则仅平移。

gain : True 时追加优化亮度增益 g(残差 I(W)-g·T)。对亮度差/噪声稳健。

lam0, tol : 初始阻尼系数 / 收敛阈值(步长范数、相对代价下降)。

返回值(dict):

pos : 精细化后的模板中心 [z,y,x] (连续坐标)

scale : 各向同性缩放(scale=False 时为 1.0)

gain : 亮度增益(gain=False 时为 1.0)

cost : 最终 SSD,rms:每 1 voxel 的残差 RMS,iters:实际迭代次数

参考(示例数据、文献)

• 示例数据目录(下载 URL / 许可证) —— 2-D 用 skimage.data(BSD/公有领域)加合成图,3-D 给出真实数据源(Stanford/PDS 等)的下载 URL。

• 算子来历与参考文献 —— 该算子族所依据的研究/方法出处。

可运行的示例(实际调用该算子并已验证的样例)

• refinement — py -3.11 examples_3d/refinement.py

类型可衔接的下一个算子(可接受 table 作为输入)

fuse_to_voxel · mesh_select_lod

同类别(refine)

refine_peak_newton · refine_translation_lk · refine_rotation_z · icp_point2point_3d · icp_point2plane


*Provenance: match3d.py — 3D 算子登记表。本条目由 tools/opdocs.py md 自动生成(请勿手工编辑)。*

© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.