在2d点云中找到漏洞

时间:2018-05-17 12:46:23

标签: python geometry 2d computational-geometry point-clouds

我有一组2d分。它们是标准笛卡尔网格系统上的X,Y坐标。有没有人知道一种实现(优先在Python中)一种算法的方法,该算法将隔离每个“洞的区域”,以便找到每个洞的最大直径。

下面是实际点集的示例:

enter image description here

更新:

我设法用固定数量的簇隔离每个区域,但是如何根据“孔区域”的数量来定义簇的数量?

from sklearn.cluster import KMeans
import numpy as np
import  ipyvolume.pylab as p

dat     = xyz
xycoors = dat[:,0:2]


fit = KMeans(n_clusters=5).fit(xycoors)
clus_datas={i: xycoors[np.where(fit.labels_ == i)] for i in 
range(fit.n_clusters)}

clus_1=clus_datas[0]
clus_2=clus_datas[1]
clus_3=clus_datas[2]
clus_4=clus_datas[3]
clus_5=clus_datas[4]



min_bloc=np.array(nuage)
fig = p.figure(width=1000)
fig.xlabel='x'
fig.ylabel='z'
fig.zlabel='y'

p.scatter(clus_1[:,1], clus_1[:,1]*0, clus_1[:,0], color="black", size=.1)     
p.scatter(clus_2[:,1], clus_2[:,1]*0, clus_2[:,0], color="red",  size=.1) 
p.scatter(clus_3[:,1], clus_3[:,1]*0, clus_3[:,0], color="green",  size=.1) 
p.scatter(clus_4[:,1], clus_1[:,1]*0, clus_4[:,0], color="bleu",  size=.1)     
p.scatter(clus_5[:,1], clus_2[:,1]*0, clus_5[:,0], color="red", size=.1) 

p.squarelim()
p.show()

结果: enter image description here

1 个答案:

答案 0 :(得分:0)

<强>解决 Density-based spatial clustering of applications with noise (DBSCAN)根据估计的簇数识别每个孔,可以使用Convex hull

计算直径