utility.py 文件源码

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

项目:AlphaLogo 作者: gigaflw 项目源码 文件源码
def lab_reduce_colors(colors, weights,  threshold=30, return_rgb=True):
    """
    Reduce colors by L*a*b* space.
    """
    _colors = np.array([colors], dtype=np.uint8)  # cv2.cvtColor only accept 2d array
    lab_colors = cv2.cvtColor(_colors, cv2.COLOR_RGB2LAB)[0].astype(np.double)

    inds = []

    for i, color in enumerate(lab_colors):
        dist = np.linalg.norm(hsv_colors_xyz[inds] - color, axis=1)
        if not dist.size or dist.min() > threshold:
            inds.append(i)

    if return_rgb:
        ret = colors[inds]
    else:
        ret = lab_colors[inds]

    return ret
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号