cluster.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:PyMaid 作者: schlegelp 项目源码 文件源码
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]}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号