PCL使用滤波器去除异常值

本文介绍了使用PCL库去除点云数据中的异常值,主要探讨了StatisticalOutlierRemoval和RadiusOutlierRemoval两种方法。StatisticalOutlierRemoval通过计算点到邻域点的平均距离,基于高斯分布剔除异常点;RadiusOutlierRemoval则根据点的邻域内点的数量来决定是否保留该点。通过设置不同的参数,可以有效地清理点云数据,提高后续处理的准确性。
摘要由CSDN通过智能技术生成

激光扫描通常会生成不同点密度的点云数据集。此外,测量误差会导致稀疏异常值,从而进一步破坏结果。这会使局部点云特征(例如表面法线或曲率变化)的估计复杂化,从而导致错误的值,进而可能导致点云配准失败。其中一些不规则性可以通过对每个点的邻域进行统计分析并修剪不符合特定标准的那些来解决。我们的稀疏异常值去除基于输入数据集中点到邻居距离分布的计算。对于每个点,我们计算从它到所有邻居的平均距离。通过假设结果分布是具有均值和标准偏差的高斯分布。

首先,下载数据集table_scene_lms400.pcd 

一、StatisticalOutlierRemoval

创建startistical_remove.cpp文件

源码:
 

 1#include <iostream>
 2#include <pcl/io/pcd_io.h>
 3#include <pcl/point_types.h>
 4#include <pcl/filters/statistical_outlier_removal.h>
 5
 6int
 7main ()
 8{
 9  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
10  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered (new pcl::PointCloud<pcl::PointXYZ>);
11
12  // Fill in the cloud data
13  pcl::PCDReader reader;
14  // Replace the path below with the path where you saved your file
15  reader.read<pcl::PointXYZ> ("table_scene_lms400.pcd", *cloud);
16
17  std::cerr << "Cloud before filtering: " << std::endl;
18  std::cerr << *cloud << std::endl;
19
20  // Create the filtering object
21  pcl::StatisticalOutlierRemoval<pcl::PointXYZ> sor;
22  sor.setInputCloud (cloud);
23  sor.setMeanK (50);
24  sor.setStddevMulThresh (1.0);
25  sor.filter (*cloud_filtered);
26
27  std::cerr << "Cloud after filtering: " << std::endl;
28  std::cerr << *cloud_filtered << std::endl;
29
30  pcl::PCDWriter writer;
31  writer.write<pcl::PointXYZ> ("table_scene_lms400_inliers.pcd", *cloud_filtered, false);
32
33  sor.setNegative (true);
34  sor.filter (*cloud_filtered);
35  writer.write<pcl::PointXYZ> ("table_scene_lms400_outliers.pcd", *cloud_filtered, false);
36
37  return (0);
38}

说明:
1、所需要的头文件,创建点云对象

 1#include <iostream>
 2#include <pcl/io/pcd_io.h>
 3#include <pcl/point_types.h>
 4#include <pcl/filters/statistical_outlier_removal.h>
 5
 6int
 7main ()
 8{
 9  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
10  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered (new pcl::PointCloud<pcl::PointXYZ>);

2、 读取点云信息

  // Fill in the cloud data
  pcl::PCDReader reader;
  // Replace the path below with the path where you saved your file
  reader.read<pcl::PointXYZ> ("table_scene_lms400.pcd", *c
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

目标成为slam大神

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值