Legacy and tensor remove_radius_outlier(s) count nb_points differently (> vs >=)

未关闭
#7,635 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
52/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
cpp, python

调研方向

Read the two implementations named in the issue: cpp/open3d/geometry/PointCloud.cpp around line 606 and cpp/open3d/t/geometry/PointCloud.cpp around line 673, then run the two-line repro to see the divergence. The existing tensor test RemoveRadiusOutliers in cpp/tests/t/geometry/PointCloud.cpp is the natural place to add a case. Done means both APIs agree on nb_points and the header (PointCloud.h:284) and pybind docstring (pybind/geometry/pointcloud.cpp:139) state whether the point itself counts — but the > vs >= choice is a maintainer decision, so ask before changing behavior.

由索引模型根据 Issue 内容生成。

描述

Checklist
  • I have searched for similar issues.
  • For Python issues, I have tested with the latest development wheel. (Tested with the 0.20.0 release wheel; the two comparisons below are unchanged on main at 2ce4f7e.)
  • I have checked the release documentation and the latest documentation (for main branch).
Describe the issue

geometry.PointCloud.remove_radius_outlier and t.geometry.PointCloud.remove_radius_outliers give different results for the same nb_points and radius. In both, the neighbor count includes the point itself, but the comparisons differ:

  • legacy, cpp/open3d/geometry/PointCloud.cpp:606: mask[i] = (nb_neighbors > nb_points); (keeps a point with at least nb_points other points; this is also PCL's RadiusOutlierRemoval rule, where k includes the query point and points with k <= min_pts are removed)
  • tensor, cpp/open3d/t/geometry/PointCloud.cpp:673: num_neighbors.Ge(static_cast<int64_t>(nb_points)) (keeps a point with at least nb_points - 1 other points)

The documentation can be read either way:

  • C++ header (PointCloud.h:284): "Function to remove points that have less than \p nb_points in a sphere of a given radius."
  • Python docstring (pybind/geometry/pointcloud.cpp:139): "Removes points that have neighbors less than nb_points in a sphere of a given radius"
  • Tutorial (pointcloud_outlier_removal.ipynb): "nb_points, which lets you pick the minimum amount of points that the sphere should contain."

nb_points < 1 is rejected by input validation. With >=, nb_points=1 would keep every point; with >, it removes isolated points (as used in #2830).

Which counting is intended?

Steps to reproduce the bug
import numpy as np, open3d as o3d, open3d.core as o3c

def both(P, n, r):
    P = np.asarray(P, dtype=np.float64)
    legacy = o3d.geometry.PointCloud(o3d.utility.Vector3dVector(P)).remove_radius_outlier(n, r)[1]
    mask = o3d.t.geometry.PointCloud(o3c.Tensor(P.astype(np.float32))).remove_radius_outliers(n, r)[1].numpy()
    return [int(i) for i in legacy], [int(i) for i in np.nonzero(mask)[0]]

print(both([[0, 0, 0], [0.1, 0, 0], [0, 0.1, 0], [9, 9, 9]], 3, 0.5))  # ([], [0, 1, 2])
print(both([[0, 0, 0], [9, 9, 9]], 1, 0.5))                           # ([], [0, 1])
Error message

No error. The kept indices differ (shown in the comments above).

Expected behavior

The two APIs keep the same points for the same nb_points and radius, and the docstrings say whether the point itself is counted.

Open3D, Python and System information
- Operating system: macOS 26.6.2 (arm64)
- Python version: 3.12.11
- Open3D version: 0.20.0 (pip wheel)
- System architecture: arm64
- Is this a remote workstation?: no
- How did you install Open3D?: pip
Additional information

The same difference shows on the data of the tensor unit test RemoveRadiusOutliers in cpp/tests/t/geometry/PointCloud.cpp (nb_points=3, radius 0.5): the tensor path keeps 4 points, the legacy path keeps 2.

Either direction is a one-line change: legacy > to >=, or tensor Ge to Gt. I can open a PR for the one you prefer, with a test, a docstring note on whether the point itself is counted, and a CHANGELOG line.

The analysis and repro were prepared with AI assistance.

主要语言
C++
星标
14.3k
派生
2.7k
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

isl-org/Open3D 的其他 Issue

查看 isl-org/Open3D 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。