【pcl入门教程分割系列】之ProgressiveMorphologicalFilter

简介

  本篇博客介绍一种点云分割通过形态学滤波的方法,该算法来自于 A Progressive Morphological Filter for Removing Nonground Measurements from Airborne LIDAR Data论文,主要是解决航空摄影测量时候,如何有效的分割出地平面的点云。关于该算法具体流程参见该博客传送门,讲解该算法过程还是比较清晰的。下面我们就简单跑一下Demo并且对比一下Approximate的方式与原始的性能差异。

Demo代码
#include <iostream>
#include <chrono>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/filters/extract_indices.h>
#include <pcl/segmentation/progressive_morphological_filter.h>
#include <pcl/segmentation/approximate_progressive_morphological_filter.h>

int main(int argc, char** argv)
{
	pcl::PointCloud<pcl::PointXYZI>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZI>);
	pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_filtered(new pcl::PointCloud<pcl::PointXYZI>);
	pcl::PointIndicesPtr ground(new pcl::PointIndices);

	// Fill in the cloud data 
	pcl::PCDReader reader;

	// Replace the path below with the path where you saved your file 
	reader.read<pcl::PointXYZI>("apollo.pcd", *cloud);

	std::cerr << "Cloud before filtering: " << cloud->points.size() << std::endl;

	auto startTime = std::chrono::steady_clock::now();

	// Create the filtering object 
	// pcl::ProgressiveMorphologicalFilter<pcl::PointXYZI> pmf;
	pcl::ApproximateProgressiveMorphologicalFilter<pcl::PointXYZI> pmf;
	pmf.setInputCloud(cloud);
	pmf.setMaxWindowSize(20); // set window size
	pmf.setSlope(1.0f); // slope 
	pmf.setInitialDistance(0.5f);
	pmf.setMaxDistance(1.5f);
	pmf.extract(ground->indices);

	// Create the filtering object 
	pcl::ExtractIndices<pcl::PointXYZI> extract;
	extract.setInputCloud(cloud);
	extract.setIndices(ground);
	extract.filter(*cloud_filtered);

	std::cerr << "Ground cloud after filtering: " << std::endl;
	std::cerr << *cloud_filtered << std::endl;

	pcl::PCDWriter writer;
	writer.write<pcl::PointXYZI> ("apollo-utm_ground.pcd", *cloud_filtered, false);

	// Extract non-ground returns 
	extract.setNegative(true);
	extract.filter(*cloud_filtered);

	auto endTime      = std::chrono::steady_clock::now();
    auto ellapsedTime = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime);

	std::cout << "Ellapse-Time: " << ellapsedTime.count() << " milliseconds." << std::endl;
	std::cerr << "Object cloud after filtering: " << cloud_filtered->points.size() << std::endl;

	writer.write<pcl::PointXYZI>("apollo-utm_object.pcd", *cloud_filtered, false);

	return 0;
}
实验结果
上述两个激光雷达图为PMF滤波叠加效果,其中白色的为地面点,彩色的为非地面点。可以看出,PMF滤波效果还是不错的。
分割地面点
分割非地面点

算法耗时对比:

算法原始点云个数滤波后点云个数算法耗时/milliseconds
Approximate-PMF760534333891
PMF760534214739318

很好奇为什么Approximate-PMF比原始PMF耗时降低这么多,它是怎么做的呢?

  阅读pcl的ApproximateProgressiveMorphologicalFilter源码可以发现,该部分较原始的ProgressiveMorphologicalFilter增加多线程处理方式进行加速,通过使用OpenMP的并行编程思路来进行加速多核CPU处理方式。其中80%的代码几乎一致,只是在extract()函数里面使用并行加速的方式。

小结

  上述近似Approximate-PMF算法的效果与耗时要远远低于原版本的PMF算法,当然效果上面要略逊色与原版PMF算法。对于离线处理对性能指标要求更高的遥感影像来说,PMF是首选。但是,针对实时性要求较高的无人驾驶来说,这个明显就不符合实际应用。就是Approximate-PMF的算法耗时都有些吃紧,希望还能出现更多的算法来加速场景落地。

参考

https://pcl-tutorials.readthedocs.io/en/latest/progressive_morphological_filtering.html#progressive-morphological-filtering
http://users.cis.fiu.edu/~chens/PDF/TGRS.pdf
https://blog.csdn.net/ambitiousruraldog/article/details/80268920

  • 3
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
PCL区域增长分割是一种基于点云数据的分割算法。该算法通过对点云数据进行聚类分析,将相邻的点分为同一区域,从而实现对点云的分割。 在PCL区域增长分割算法中,首先需要定义种子点。种子点是用作分割起始点的点。可以根据点云数据的某些属性,比如颜色、法线等来选择种子点。然后,从种子点开始,利用邻域搜索的方法,逐步扩展分割区域。邻域搜索是指以种子点为中心,搜索周围一定范围内的点。如果周围点与种子点相似,则将其归为同一区域。 PCL区域增长分割算法的核心在于如何确定相似性。一般地,通过计算两个点之间的相似度来判断它们是否属于同一区域。相似度可以由颜色、法线或距离等属性来衡量。具体选择哪些属性作为相似性的标准,取决于具体的应用场景。 PCL区域增长分割算法的优点是简单而高效。它可以应用于各种类型的点云数据,包括室内外场景、目标检测、三维重建等。此外,该算法还具有较好的鲁棒性,即使在存在噪声和部分点缺失的情况下,也能得到较好的分割结果。 总结起来,PCL区域增长分割是一种基于点云数据的分割算法,可以用于将相邻的点分为同一区域。它通过定义种子点、邻域搜索和相似度计算来实现分割。该算法简单高效,适用于各种点云数据处理的应用场景。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值