当我们从扫描设备获取点云数据时,数据会包含人想除去的噪声和伪影。这篇教程将会介绍如何使用Open3d除去离群点。
使用 voxel_downsample 去采样得到点云。
print("Load a ply point cloud, print it, and render it")
pcd = o3d.io.read_point_cloud("../../TestData/ICP/cloud_bin_2.pcd")
o3d.visualization.draw_geometries([pcd])
print("Downsample the point cloud with a voxel of 0.02")
voxel_down_pcd = pcd.voxel_down_sample(voxel_size=0.02)
o3d.visualization.draw_geometries([voxel_down_pcd])
Load a ply point cloud, print it, and render it
Downsample the point cloud with a voxel of 0.02
为了比较,uniform_down_sample 通过每n个点来降采样点云。
select_down_sample 函数通过二进制mask去只输出被选中的点。选中的点和未选中的点被可视化。
def display_inlier_outlier(cloud, ind):
inlier_cloud = cloud.select_by_index(ind)
outlier_cloud = cloud.select_by_index(ind, invert=True)
print("Showing outliers (red) and inliers (gray): ")
outlier_cloud.paint_uniform_color([1, 0, 0])
inlier_cloud.paint_uniform_color([0.8, 0.8, 0.8])
o3d.visualization.draw_geometries([inlier_cloud, outlier_cloud])
statistical_outlier_removal函数删除与点云的距离比起其他邻域的平均距离远的点,他有两个输入参数:
print("Statistical oulier removal")
cl, ind = voxel_down_pcd.remove_statistical_outlier(nb_neighbors=20,
std_ratio=2.0)
display_inlier_outlier(voxel_down_pcd, ind)
Statistical oulier removal
Showing outliers (red) and inliers (gray):
radius_outlier_removal 会删除在给定半径的球体周围几乎没有邻域点的点。他也有两个输入参数:
print("Radius oulier removal")
cl, ind = voxel_down_pcd.remove_radius_outlier(nb_points=16, radius=0.05)
display_inlier_outlier(voxel_down_pcd, ind)
Radius oulier removal
Showing outliers (red) and inliers (gray):