PCL库滤波激光雷达点云
点云滤波不同于图像滤波,它指的是将原始激光雷达点云数据分为地面点和地物点的二分类过程。由于PCL点云库具备易用、且实现了大多数点云处理算法,我们使用PCL中的渐进形态学滤波算法对点云进行滤波:
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered (new pcl::PointCloud<pcl::PointXYZ>);
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::PointXYZ> ("samp.pcd", *cloud);
2.使用PMF算法提取地面点索引,渐进形态学算法基本思想是将点云栅格化作影像处理,进而使用形态学开操作(腐蚀后膨胀)进而剔除小于结构元素S的点云完成滤波。
// Create the filtering object
pcl::ProgressiveMorphologicalFilter<pcl::PointXYZ> pmf;
pmf.setInputCloud (cloud);
pmf.setMaxWindowSize (20);
pmf.setSlope (1.0f);
pmf.setInitialDistance (0.5f);
pmf.setMaxDistance (3.0f);
pmf.extract (ground->indices);
// Create the filtering object
pcl::ExtractIndices<pcl::PointXYZ> extract;
extract.setInputCloud (cloud);
extract.setIndices (ground);
extract.filter (*cloud_filtered);
3. 将滤波得到的地面点输出
pcl::PCDWriter writer;
writer.write<pcl::PointXYZ> ("samp_ground.pcd", *cloud_filtered, false);、
滤波得到地面点
由地面点插值得到DEM