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()
Solved Density-based spatial clustering of applications with noise (DBSCAN) Identify each hole according to estimated number of clusters, the diameter can be calculated using the Convex hull