经典点云去噪算法总结

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

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

欢迎star

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

1.移动最小二乘MLS

基于PCL


   
   
  1. #include "stdafx.h"
  2. #include <pcl /point_types.h >
  3. #include <pcl /io /pcd_io.h >
  4. #include <pcl /kdtree /kdtree_flann.h >
  5. #include <pcl /surface /mls.h >
  6. int main(int argc, char ** argv)
  7. { / / 将一个适当类型的输入文件加载到对象PointCloud中
  8. pcl ::PointCloud <pcl ::PointXYZ > ::Ptr cloud(new pcl ::PointCloud <pcl ::PointXYZ >());
  9. / / 加载bun 0.pcd文件,加载的文件在 PCL的测试数据中是存在的
  10. pcl ::io ::loadPCDFile( "bunny_hi_noise.pcd", *cloud);
  11. / / 创建一个KD树
  12. pcl :: search ::KdTree <pcl ::PointXYZ > ::Ptr tree(new pcl :: search ::KdTree <pcl ::PointXYZ >);
  13. / / 输出文件中有PointNormal类型,用来存储移动最小二乘法算出的法线
  14. pcl ::PointCloud <pcl ::PointNormal > mls_points;
  15. / / 定义对象 (第二种定义类型是为了存储法线, 即使用不到也需要定义出来)
  16. pcl ::MovingLeastSquares <pcl ::PointXYZ, pcl ::PointNormal > mls;
  17. mls.setComputeNormals( true);
  18. / /设置参数
  19. mls.setInputCloud(cloud);
  20. mls.setPolynomialFit( true);
  21. mls.setSearchMethod(tree);
  22. mls.setSearchRadius( 0.06);
  23. / / 曲面重建
  24. mls.process(mls_points);
  25. / / 保存结果
  26. pcl ::io ::savePCDFile( "bunny_hi_noise_mls.pcd", mls_points);
  27. }

2.双边滤波

2.1基于PCL

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


   
   
  1. #include "stdafx.h"
  2. #include <pcl /point_types.h >
  3. #include <pcl /io /pcd_io.h >
  4. #include <pcl /kdtree /kdtree_flann.h >
  5. #include <pcl /filters /bilateral.h >
  6. typedef pcl ::PointXYZI PointT;
  7. int
  8. main(int argc, char *argv[])
  9. {
  10. std :: string incloudfile = "block_noise.pcd";
  11. std :: string outcloudfile = "block_bf.pcd";
  12. float sigma_s = 0.1;
  13. float sigma_r = 0.2;
  14. / / Load cloud
  15. pcl ::PointCloud <PointT > ::Ptr cloud(new pcl ::PointCloud <PointT >);
  16. pcl ::io ::loadPCDFile(incloudfile.c_str(), *cloud);
  17. pcl ::PointCloud <PointT > outcloud;
  18. / / Set up KDTree
  19. / /pcl ::KdTreeFLANN <PointT > ::Ptr tree(new pcl ::KdTreeFLANN <PointT >);
  20. pcl :: search ::KdTree <PointT > ::Ptr tree 1(new pcl :: search ::KdTree <PointT >);
  21. pcl ::BilateralFilter <PointT > bf;
  22. bf.setInputCloud(cloud);
  23. bf.setSearchMethod(tree 1);
  24. bf.setHalfSize(sigma_s);
  25. bf.setStdDev(sigma_r);
  26. bf.filter(outcloud);
  27. / / Save filtered output
  28. pcl ::io ::savePCDFile(outcloudfile.c_str(), outcloud);
  29. return ( 0);
  30. }

2.2 基于CGAL

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


   
   
  1. #include <CGAL /Simple_cartesian.h >
  2. #include <CGAL / property_map.h >
  3. #include <CGAL /IO / read_xyz_points.h >
  4. #include <CGAL /IO / write_xyz_points.h >
  5. #include <CGAL /bilateral_smooth_point_ set.h >
  6. #include <CGAL /tags.h >
  7. #include <utility > / / defines std ::pair
  8. #include <fstream >
  9. / / Types
  10. typedef CGAL ::Simple_cartesian <double > Kernel;
  11. typedef Kernel ::Point_ 3 Point;
  12. typedef Kernel ::Vector_ 3 Vector;
  13. / / Point with normal vector stored in a std ::pair.
  14. typedef std ::pair <Point, Vector > PointVectorPair;
  15. / / Concurrency
  16. typedef CGAL ::Parallel_ if_available_tag Concurrency_tag;
  17. int main(int argc, char *argv[])
  18. {
  19. const char * input_filename = (argc > 1)?argv[ 1]: "data/fin90_with_PCA_normals.xyz";
  20. const char * output_filename = (argc > 2)?argv[ 2]: "data/fin90_with_PCA_normals_bilateral_smoothed.xyz";
  21. / / Reads a .xyz point set file in points[] * with normals *.
  22. std ::vector <PointVectorPair > points;
  23. std ::ifstream stream( input_filename);
  24. if (!stream ||
  25. !CGAL :: read_xyz_points(stream,
  26. std ::back_inserter(points),
  27. CGAL ::parameters ::point_map(CGAL :: First_ of_pair_ property_map <PointVectorPair >()).
  28. normal_map(CGAL ::Second_ of_pair_ property_map <PointVectorPair >())))
  29. {
  30. std ::cerr < < "Error: cannot read file " < < input_filename < < std ::endl;
  31. return EXIT_FAILURE;
  32. }
  33. / / Algorithm parameters
  34. int k = 120; / / size of neighborhood. The bigger the smoother the result will be.
  35. / / This value should bigger than 1.
  36. double sharpness_angle = 25; / / control sharpness of the result.
  37. / / The bigger the smoother the result will be
  38. int iter_ number = 3; / / number of times the projection is applied
  39. for (int i = 0; i < iter_ number; + +i)
  40. {
  41. / * double error = * /
  42. CGAL ::bilateral_smooth_point_ set <Concurrency_tag >(
  43. points,
  44. k,
  45. CGAL ::parameters ::point_map(CGAL :: First_ of_pair_ property_map <PointVectorPair >()).
  46. normal_map(CGAL ::Second_ of_pair_ property_map <PointVectorPair >()).
  47. sharpness_angle (sharpness_angle));
  48. }
  49. Save point set.
  50. std ::ofstream out( output_filename);
  51. out.precision( 17);
  52. if (!out ||
  53. !CGAL :: write_xyz_points(
  54. out, points,
  55. CGAL ::parameters ::point_map(CGAL :: First_ of_pair_ property_map <PointVectorPair >()).
  56. normal_map(CGAL ::Second_ of_pair_ property_map <PointVectorPair >())))
  57. {
  58. return EXIT_FAILURE;
  59. }
  60. return EXIT_SUCCESS;
  61. }

3.LOP

4.WLOP

基于CGAL:

安装CGAL可以参考:CGAL如何配置-小白向_Meet_csdn的博客-CSDN博客_cgal 配置

安装好后的工程文件是CGAL自带的,在文件夹example/Point_set_processing_3/wlop_simplify_and_regularize_point_set_example,运行结果如下:

原始模型

去噪下采样后模型

                       

参考代码:CGAL 5.3 - Point Set Processing: User Manual

文章:Huang H, Li D, Zhang H, et al. Consolidation of unorganized point clouds for surface reconstruction[J]. ACM transactions on graphics (TOG), 2009, 28(5): 1-7.

5.CLOP

官方实现,原始地址

对应文章:"Reinhold Preiner, Oliver Mattausch, Murat Arikan, Renato Pajarola, Michael Wimmer
Continuous Projection for Fast L1 Reconstruction
ACM Transactions on Graphics (Proc. of ACM SIGGRAPH 2014), 33(4):47:1-47:13, August 2014."

下载下来后可以运行,速度还不错,会对点云下采样

5.EAR

官方代码,有exe版本和源码版本,exe可以双击运行。

参考地址:Edge-Aware Point Set Resampling | Visual Computing Research Center @ Shenzhen University

文章:Huang H, Wu S, Gong M, et al. Edge-aware point set resampling[J]. ACM transactions on graphics (TOG), 2013, 32(1): 1-12.

6.PCN(point-clean-net)


可以去除离群点和噪声点


地址:https://github.com/mrakotosaon/pointcleannet


7.TD(total denoising)


第一篇点云无监督去噪方法,结果偏向平滑。


地址:https://github.com/phermosilla/TotalDenoising

TotalDenoising代码复现步骤_Meet_csdn的博客-CSDN博客


8.Pointfilter


目前SOTA,效果比较好,编码解码结构,简单有效


地址:https://github.com/dongbo-BUAA-VR/Pointfilter
 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
点云去噪点云处理中的一个重要任务,可以提高点云数据的质量。常用的点云去噪算法包括基于统计学的方法、基于几何学的方法和基于深度学习的方法。这里我们介绍几种常用的基于统计学和几何学的点云去噪算法的Python实现。 1. 基于统计学的点云去噪算法——Statistical Outlier Removal (SOR) SOR算法是一种基于统计学的点云去噪算法,其基本思想是通过计算每个点与周围点的距离的标准差,将距离超出一定阈值的点视为噪声点并剔除。SOR算法实现如下: ```python import open3d as o3d # 读取点云数据 pcd = o3d.io.read_point_cloud("point_cloud.ply") # SOR算法去噪 pcd_sor = pcd.remove_statistical_outlier(nb_neighbors=20, std_ratio=2.0) # 保存去噪后的点云数据 o3d.io.write_point_cloud("point_cloud_sor.ply", pcd_sor) ``` 2. 基于几何学的点云去噪算法——Uniform Sampling Uniform Sampling算法是一种基于几何学的点云去噪算法,其基本思想是通过对每个点的周围点进行均匀采样,来减少点云数据中的噪声点。Uniform Sampling算法实现如下: ```python import open3d as o3d # 读取点云数据 pcd = o3d.io.read_point_cloud("point_cloud.ply") # Uniform Sampling算法去噪 pcd_uniform = pcd.uniform_down_sample(every_k_points=10) # 保存去噪后的点云数据 o3d.io.write_point_cloud("point_cloud_uniform.ply", pcd_uniform) ``` 3. 基于几何学的点云去噪算法——Radius Outlier Removal (ROR) ROR算法是一种基于几何学的点云去噪算法,其基本思想是通过计算每个点与周围点的距离的平均值,将距离超出一定半径范围的点视为噪声点并剔除。ROR算法实现如下: ```python import open3d as o3d # 读取点云数据 pcd = o3d.io.read_point_cloud("point_cloud.ply") # ROR算法去噪 pcd_ror = pcd.remove_radius_outlier(nb_points=16, radius=0.05) # 保存去噪后的点云数据 o3d.io.write_point_cloud("point_cloud_ror.ply", pcd_ror) ``` 以上三种算法均基于Open3D库实现,可以通过pip安装: ``` pip install open3d ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值