近邻点云下采样/抽取

问题描述 投票:0回答:1

我正在寻找一种根据点与其邻居的接近程度对点云进行下采样的方法(据我所知,这与“抽取”同义)。虽然我目前使用 PyVista 作为我的主要库,但我没有看到任何类/方法似乎可以实现我正在寻找的目标,因为属于

PolyDataFilter
类的 decimate 方法仅适用于具有已网格化(并且我想在网格化之前减少我的点云)。

如果不从头开始开发自己的方法,我怎样才能实现这种抽取?

python nearest-neighbor downsampling pyvista decimation
1个回答
0
投票

PyVista 开发者在这里;)

我认为您可能想尝试 PyVista 中的

clean()
过滤器(有点仅适用于
PolyData
类型——您的点云将是)。实际上,我们在 glyph() 过滤器内部有一个
代码片段
,当需要以这种方式对点进行下采样以将许多几何图形表示为大矢量场的代表性样本时,它演示了这一点。 我们文档中的示例使用玩具数据集演示了这一点。但你不是在刻字!因此,下面是一个希望适用于您的用例的片段。这里的关键是确定邻近度的
merge_tol
参数。请参阅我们的有效文档以了解如何使用它。

import pyvista as pv
import numpy as np

source_points = np.random.rand(10_000, 3)
dense = pv.PolyData(source_points)

# Recomend reading PyVista's docs on how to use this parameter
# the gist: tolerance is in terms of fraction of bounding box diagonal length (0-1)
tolerance = 0.05

# This can take some time for large point clouds
small = dense.clean(
    point_merging=True,
    merge_tol=tolerance,
    lines_to_points=False,
    polys_to_lines=False,
    strips_to_polys=False,
    inplace=False,
    absolute=False,
    progress_bar=True,  # eh, not sure why its non-interactive
)

然后当然是绘制它,因为这是 PyVista!

pl = pv.Plotter(shape=(1, 2))
pl.add_mesh(dense, render_points_as_spheres=True)
pl.subplot(0, 1)
pl.add_mesh(small, render_points_as_spheres=True)
pl.link_views()
pl.view_isometric()
pl.show()

据我所知,这与“抽取”同义

嗯,这里的术语绝对令人困惑。在 PyVista 中,抽取目前保留用于减少网格中三角形的数量。我认为“下采样”是对此的最佳术语,并且同意“干净”过滤器并不明显是您所需要的(始终欢迎改进我们文档的 PR)

© www.soinside.com 2019 - 2024. All rights reserved.