In [1]:
%matplotlib nbagg

from sklearn.neighbors import NearestNeighbors

from planet4 import io, markings

In [2]:
pid = markings.ImageID('1cl', scope='planet4')

In [11]:
blotches = pid.get_fans()

In [12]:
X = blotches[['x','y']].as_matrix()

In [13]:
nbrs = NearestNeighbors(n_neighbors=5).fit(X)

In [14]:
dists, inds = nbrs.kneighbors(X)

In [15]:
dists.shape


Out[15]:
(353, 5)

In [16]:
col = dists[:,-1]

In [17]:
sorted_dists = list(reversed(np.sort(col)))

In [18]:
plt.plot(sorted_dists)


Out[18]:
[<matplotlib.lines.Line2D at 0x11b254d30>]

In [ ]: