序:本节介绍PCL里的双边滤波,双边滤波主要作用是具有保边的功能,即在滤波的过程中不会连带边界一起都平滑掉,这样有利于计算准确的法线。这里我们主要介绍其实现过程,算法会在后续补充上。
1. 代码如下:
void Filters::bilateralFilter(pcl::PCLPointCloud2::ConstPtr input, pcl::PCLPointCloud2& output, float sigma_s, float sigma_r) { // Convert data to PointCloud<T> pcl::PointCloud<pcl::PointXYZ>::Ptr xyz (new pcl::PointCloud<pcl::PointXYZ>); fromPCLPointCloud2 (*input, *xyz); // Apply the filter pcl::FastBilateralFilter<pcl::PointXYZ> fbf; fbf.setInputCloud (xyz); fbf.setSigmaS (sigma_s); fbf.setSigmaR (sigma_r); pcl::PointCloud<pcl::PointXYZ> xyz_filtered; fbf.filter (xyz_filtered); // Convert data back pcl::PCLPointCloud2 output_xyz; toPCLPointCloud2 (xyz_filtered, output_xyz); pcl::concatenateFields (*input, output_xyz, output); }
2. 运行结果
直接观察运行的结果是很难区分出有什么差别的,所以这里我们分别计算了运行前后点云的法线,可以通过法线的分布清楚的分出效果来。
(1)采用默认参数滤波
(2)滤波前的法线分布
(3)滤波后的法线分布