当前位置:网站首页>欧氏聚类(API)及其单木分割
欧氏聚类(API)及其单木分割
2022-07-23 21:26:00 【仰望星空_2022】
1、 原理讲解
三维空间欧氏距离聚类算法中,涉及到唯一距离参数d。当点之间距离小于距离d 时,表明两点局部相连,属于同一簇点集。其中点之间相连满足如下性质:若点A 与点B 相连,点B 与点C 相连,则点A 与点C 也相连。
下图展示了基于欧氏距离聚类的原理,当距离阈值设置合理时,使用空间欧氏距离聚类算法对点进行聚类,所有的点被划分成左右两簇点集,并且两簇点云中任意两点相连。即对于一簇点中任意点,总能从该簇点中找到离该点距离小于d的另外一点。对于左边点集中C点,右边点集中距离C点最近的D点,两点之间距离大于距离阈值,经过聚类后C点与D点归属于两簇不同的点集。
2、PCL中代码示例
PCL自带基于欧氏距离的聚类,其主要代码如下:
std::vector<std::vector<pcl::PointXYZ>> result;
IOLAS IOExample;
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
cloud = IOExample.PointXYZ2Ptr(BeforeCluster);
std::vector<pcl::PointIndices>cluster_indices;
pcl::search::KdTree<pcl::PointXYZ>::Ptr tree(new pcl::search::KdTree<pcl::PointXYZ>);
tree->setInputCloud(cloud);
pcl::EuclideanClusterExtraction<pcl::PointXYZ> ec;
ec.setMinClusterSize(nmin);
ec.setClusterTolerance(disthres);
//ec.setMaxClusterSize(nmax);
ec.setSearchMethod(tree);
ec.setInputCloud(cloud);
ec.extract(cluster_indices);
for (std::vector<pcl::PointIndices>::const_iterator it = cluster_indices.begin(); it != cluster_indices.end(); ++it)
{
vector<pcl::PointXYZ> onecluster;
pcl::PointXYZ onepoint;
for (std::vector<int>::const_iterator pit = it->indices.begin(); pit != it->indices.end(); ++pit)
{
onecluster.push_back((*cloud)[*pit]);
}
result.push_back(onecluster);
}
3、聚类效果
下面是两种基于欧氏距离聚类实现的单木分离效果,其中一种对整个点云直接进行聚类,另一种是采用分层策略实现的聚类效果。
直接使用欧氏聚类聚类实现的单体分离
后面图均使用分层+欧氏距离得到的分离结果

说明:
基于欧氏距离的点云聚类,其效果与点簇之间的距离、采取的策略等各方面均相关。
4、基于欧氏聚类的代码下载链接:(基于PCL中API)
下载链接:https://download.csdn.net/download/qq_32867925/86246716
边栏推荐
- 初识js(适合新手的编程)
- 1063 Set Similarity
- (note) learning rate setting of optimizer Adam
- First acquaintance with JS (programming suitable for beginners)
- Edge cloud | 1. overview
- [complex overloaded operator]
- [isprint function determines whether characters can be output]
- Unity—3D数学-Vector3
- Cluster chat server: cluster and distributed theory
- High numbers | calculation of triple integral 1 | high numbers | handwritten notes
猜你喜欢

scala编程(中级进阶实验应用)

High numbers | calculation of triple integral 1 | high numbers | handwritten notes

Chapter1 data cleaning

The total ranking of blogs is 918

手机测试相关基础知识

Cluster chat server: Framework Design of model data layer and encapsulation of database code

Union and union all of Hana SQL

Network learning infrared module, 8-way emission independent control

Customer exit variable in query

BroadCast(广播)
随机推荐
手机测试相关基础知识
Pay more attention to which securities company has the lowest commission? Is it safe to open an account online?
TypeScript基础
Mysql database index
1063 Set Similarity
Improving performance with explicit rendering
一道golang中关于for range常见坑的面试题
Cesium core class viewer viewer details
Modular development
Network learning infrared module, 8-way emission independent control
[create birthday card application]
How to get the worker's hat? Where is the worker's helmet?
Looking for the missing class name
Kuberntes云原生实战六 使用Rook搭建Ceph集群
When we talk about Chen Chunhua and Huawei, what are we talking about?
北大清华2022年在各地录取人数排名
[continuous update] collection of raspberry pie startup and failure series
剑指Offer第二版:字符串(简单)
How to implement desktop lyrics in pyqt
C - documents