pycolor.py 文件源码

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

项目:pycolor_detection 作者: parth1993 项目源码 文件源码
def closest_colour(requested_colour, dfs):
    min_colours = {}

    requested_color = colors.hex2color(requested_colour)

    requested_color = rgbtolab(requested_color)
    for key, color_shade, code, color_base in zip(dfs['hex_to_rgb'] \
            , dfs['Color_shade'], dfs['Hex_code'], dfs['Color_category']):
        r_c, g_c, b_c = map(float, key)
        rd = abs(r_c - float(requested_color[0]))
        gd = abs(g_c - float(requested_color[1]))
        bd = abs(b_c - float(requested_color[2]))
        min_colours[sqrt(rd + gd + bd)] = [color_shade, code, color_base]
    return min_colours[min(min_colours.keys())]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号