match_chamfer_3d — 3D match_localize op

• 数据种类:voxel × voxel → position

• 调用: import fullseye as fs; fs.ledger.match_chamfer_3d(scene, template, device='cpu', thr=0.3, edt='scipy')(要直接调用实现,import match3d; match3d.match_chamfer_3d(scene, template, device='cpu', thr=0.3, edt='scipy');从台账取用则 ops3d.get("match_chamfer_3d"))

• 经台账调用的返回值: fullseye.ledger.match_chamfer_3d(...) 只返回声明的 out 类型 position 的值(底层函数还会返回辅助信息)。需要被丢弃的部分时,使用 fullseye.ledger.match_chamfer_3d.raw(...),或直接调用 match3d.match_chamfer_3d。

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

用法

chamfer / 距离场匹配(对部分可见与遮挡稳健)。voxel × chamfer 列。

在场景边缘的 EDT(每个 voxel 到最近边缘的距离)上放置模板的边缘点, 最小化距离和。score(pos)=Σ_{template edge} DT_scene(pos+edge)/n。越低匹配越好。即使部分边缘点缺失也有效(比 NCC 更耐遮挡)。相关(conv3d)始终在 GPU 上。距离场为 edt="scipy"(CPU,默认)或 edt="jfa"(edt_jfa,全 GPU、无 CPU 往返;与 scipy 严格一致)。返回值 [chamfer 距离, d, h, w]。

步骤:在两个 volume 中把 |∇| > thr·max|∇| 的 voxel 作为边缘(thr 是相对各 volume 最大梯度的 相对比,梯度用 sobel3d)。生成 scene 边缘的距离变换 DT,以模板的边缘 2 值 volume 为核做 conv3d,再除以边缘数 n。返回值 [dist, z, y, x] 中的 dist 是“模板每 1 个边缘 voxel 到最近 scene 边缘的平均距离(voxel 单位)”,0 为完全匹配。位置是 模板中心 (T//2) 的 scene 坐标,为 整数(没有 subvoxel 细化;需要时交给 refine_translation_lk。corner 约定,因此减去 T//2)。模板不能完全容纳的位置用最大值+1 填充并排除。模板没有边缘(thr 过高等)时 score 全为 0,返回 index (0,0,0)。scene 没有边缘时距离场没有意义(降低 thr)。edt="jfa" 使用 edt_jfa,在 device 上完成,否则用 scipy(CPU)。

参考(示例数据、文献)

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

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

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

• matching_localize — py -3.11 examples_3d/matching_localize.py

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

refine_peak_newton · refine_translation_lk · refine_lm · fuse_to_voxel

同类别(match_localize)

match_shape_3d · match_curvature_3d · match_hough_3d · match_mip_2d · match_points_ncc


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

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