什么是寻找最接近的颜色数组另一种颜色最好的算法? [英] What is the best algorithm for finding the closest color in an array to another color?

查看:161
本文介绍了什么是寻找最接近的颜色数组另一种颜色最好的算法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个彩色(RGB)从传感器读取。我也有知的色彩,每一个搭配一个字符串名称的列表。

I have a color (RGB) being read from a sensor. I also have a list of "known" colors, each paired with a string name.

将最佳的方式(即表现得象一个人的选择颜色)什么拉最接近的颜色的名称出此列表?

What would the best way (ie behave like a human choosing colors) to pull the name of the nearest color out of this list?

我试着RGB最短笛卡尔距离,但是,让灰色更接近绿色,而不是黑色或白色。

I've tried a shortest cartesian distance with RGB, but that makes grey closer to green than to black or white.

推荐答案

而不是使用RGB,尝试使用 HSL (色调,饱和度,亮度)或HSV(色调,饱和度和值)的颜色模型。然后尝试偏差不同的元素,如色调比亮度更重要的,当你计算距离。

Rather than using RGB, try using an HSL (Hue, Saturation, Lightness) or HSV (Hue, Saturation and Value) color model. Then experiment with different elements of bias, e.g. hue being more important than luminance when you're calculating the distance.

这篇关于什么是寻找最接近的颜色数组另一种颜色最好的算法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆