def get_colormap(self, k=5, criterion='maxclust'):
"""Generate colormap based on clustering.
Parameters
----------
k : {int, float}
criterion : {'maxclust','distance'}, optional
If `maxclust`, `k` clusters will be formed. If `distance`,
clusters will be created at threshold `k`.
Returns
-------
dict
{'skeleton_id': (r,g,b),...}
"""
cl = self.get_clusters(k, criterion, return_type='indices')
cl = [[self.mat.index.tolist()[i] for i in l] for l in cl]
colors = [colorsys.hsv_to_rgb(1 / len(cl) * i, 1, 1)
for i in range(len(cl) + 1)]
return {n: colors[i] for i in range(len(cl)) for n in cl[i]}
评论列表
文章目录