CGAL 加权局部最优投影(WLOP)简化算法

文章介绍了WLOP(WLOP)简化算法的实现,该算法用于处理点云数据,能去噪并生成均匀分布的采样点。关键函数`CGAL::wlop_simplify_and_regularize_point_set`被用于简化和正则化点集,参数如`require_uniform_sampling`和`neighbor_radius`影响结果。代码示例展示了如何使用CGAL库读取、处理和保存点云数据。
摘要由CSDN通过智能技术生成

一、概述

  这是加权局部最优投影(WLOP)简化算法的一个实现。WLOP简化算法可以在原始密集点云上产生一组去噪、无异常值、均匀分布的粒子。该算法的核心是一个带密度均匀化项的加权局部最优投影算子。
在这里插入图片描述

1、主要函数

头文件

#include <CGAL/wlop_simplify_and_regularize_point_set.h> // WLOP

函数

OutputIterator CGAL::wlop_simplify_and_regularize_point_set  ( PointRange &  points,  
  OutputIterator  output,  
  const NamedParameters &  np = parameters::default_values()  
 ) 

  加权局部最优投影(WLOP)简化算法的一个实现。

2、参数解析

** require_uniform_sampling**
  计算每个点的密度权重是一个可选的预处理。例如,如下图所示,当require_uniform_sampling设为false时,WLOP保留了原始点的内在非均匀采样;如果require_uniform_sampling设置为true, WLOP对非均匀采样有弹性,生成分布更均匀的采样点,但计算效率会降低。
在这里插入图片描述

neighbor_radius
  通常,样本点的邻域至少包括两个相邻样本点的环。使用较小的邻域大小可能无法生成正则化结果,而使用较大的邻域大小会使样本点收缩到局部表面内部(欠拟合)。如果该参数值设置为默认值或小于零值,则该函数会根据点云密度自动估计邻域大小。
在这里插入图片描述

二、代码实现

#include <vector>
#include <fstream>
#include <iostream>
#include <CGAL/IO/read_points.h>
#include <CGAL/IO/write_points.h>
#include <CGAL/wlop_simplify_and_regularize_point_set.h> // WLOP
#include <CGAL/Simple_cartesian.h>
// types
typedef CGAL::Simple_cartesian<double> Kernel;

int main(int argc, char** argv)
{
	const std::string input_filename = CGAL::data_file_path("cgal//points_3//sphere_20k.xyz");
	const char* output_filename =  "cgal//sphere_20k_WLOPED.xyz";

	// ----------------------------读取点云--------------------------------
	std::vector<Kernel::Point_3> points;

	if (!CGAL::IO::read_points(input_filename, std::back_inserter(points)))
	{
		std::cerr << "Error: cannot read file " << input_filename << std::endl;
		return -1;
	}

	std::vector<Kernel::Point_3> output;

	// ---------------------------参数设置--------------------------------
	const double r_percentage = 20;// 保留点所占百分比
	const double n_radius = 0.5;   // 邻域大小
	// ----------------------------滤波-----------------------------------
	CGAL::wlop_simplify_and_regularize_point_set<CGAL::Parallel_if_available_tag>
		(points, std::back_inserter(output),
			CGAL::parameters::select_percentage(r_percentage).
			neighbor_radius(n_radius));
	// --------------------------结果保存---------------------------------
	if (!CGAL::IO::write_points(output_filename, output, CGAL::parameters::stream_precision(8)))
		return -1;

	return 0;
}

三、结果展示

在这里插入图片描述

  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

点云侠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值