经典点云去噪算法总结 您所在的位置:网站首页 点云滤波方法 经典点云去噪算法总结

经典点云去噪算法总结

#经典点云去噪算法总结| 来源: 网络整理| 查看: 265

以下列出方法均有运行成功的代码,所有工程文件我都会放在如下链接:

https://github.com/gx-sun/classic-point-cloud-denoising-methods

欢迎star

持续补充中,目前最新为2021.12月。

1.移动最小二乘MLS

基于PCL

#include "stdafx.h" #include #include #include #include int main(int argc, char** argv) {// 将一个适当类型的输入文件加载到对象PointCloud中 pcl::PointCloud::Ptr cloud(new pcl::PointCloud()); // 加载bun0.pcd文件,加载的文件在 PCL的测试数据中是存在的 pcl::io::loadPCDFile("bunny_hi_noise.pcd", *cloud); // 创建一个KD树 pcl::search::KdTree::Ptr tree(new pcl::search::KdTree); // 输出文件中有PointNormal类型,用来存储移动最小二乘法算出的法线 pcl::PointCloud mls_points; // 定义对象 (第二种定义类型是为了存储法线, 即使用不到也需要定义出来) pcl::MovingLeastSquares mls; mls.setComputeNormals(true); //设置参数 mls.setInputCloud(cloud); mls.setPolynomialFit(true); mls.setSearchMethod(tree); mls.setSearchRadius(0.06); // 曲面重建 mls.process(mls_points); // 保存结果 pcl::io::savePCDFile("bunny_hi_noise_mls.pcd", mls_points); }

2.双边滤波

2.1基于PCL

实验编译成功了,但是因为其需要intensity分量,一般都没有,故无法运行 

#include "stdafx.h" #include #include #include #include typedef pcl::PointXYZI PointT; int main(int argc, char *argv[]) { std::string incloudfile = "block_noise.pcd"; std::string outcloudfile = "block_bf.pcd"; float sigma_s = 0.1; float sigma_r = 0.2; // Load cloud pcl::PointCloud::Ptr cloud(new pcl::PointCloud); pcl::io::loadPCDFile(incloudfile.c_str(), *cloud); pcl::PointCloud outcloud; // Set up KDTree //pcl::KdTreeFLANN::Ptr tree(new pcl::KdTreeFLANN); pcl::search::KdTree::Ptr tree1(new pcl::search::KdTree); pcl::BilateralFilter bf; bf.setInputCloud(cloud); bf.setSearchMethod(tree1); bf.setHalfSize(sigma_s); bf.setStdDev(sigma_r); bf.filter(outcloud); // Save filtered output pcl::io::savePCDFile(outcloudfile.c_str(), outcloud); return (0); }

2.2 基于CGAL

官方example代码,无需强度分类,只需点位置和法线信息,运行成功版本:

#include #include #include #include #include #include #include // defines std::pair #include // Types typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_3 Point; typedef Kernel::Vector_3 Vector; // Point with normal vector stored in a std::pair. typedef std::pair PointVectorPair; // Concurrency typedef CGAL::Parallel_if_available_tag Concurrency_tag; int main(int argc, char*argv[]) { const char* input_filename = (argc>1)?argv[1]:"data/fin90_with_PCA_normals.xyz"; const char* output_filename = (argc>2)?argv[2]:"data/fin90_with_PCA_normals_bilateral_smoothed.xyz"; // Reads a .xyz point set file in points[] * with normals *. std::vector points; std::ifstream stream(input_filename); if (!stream || !CGAL::read_xyz_points(stream, std::back_inserter(points), CGAL::parameters::point_map(CGAL::First_of_pair_property_map()). normal_map(CGAL::Second_of_pair_property_map()))) { std::cerr


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有