简体   繁体   中英

Finding holes in 2d point cloud

I have a set of 2d points. They are X,Y coordinates on a standard Cartesian grid system. Does anyone know a way to implement (preferentially in Python) an algorithm that will isolate each "hole's area" in order to find the largest diameter for each hole.

Below an example of actual point sets :

在此处输入图片说明

UPDATE :

I managed to isolate each area with a fixed number of clusters, but how can I define the number of clusters according to number of "hole's area" ?

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()

Results : 在此处输入图片说明

基于 解决方案 的基于密度的带噪声的应用程序空间聚类(DBSCAN)根据估计的聚类数识别每个孔,可使用凸包来计算直径

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM