如何将十六进制值转换为颜色名称
是否有一种算法(我已经搜索过但没有想出太多),在给定十六进制值的情况下,能够返回颜色名称?它不必是太具体的东西,任何蓝色阴影作为“蓝色”都可以。
或者除此之外,是否有一个由十六进制值及其相应的颜色系列组成的大型列表。我找到了列表,但它们似乎只有几百种颜色。
我看到这篇文章,但那里的解决方案似乎只是打破了颜色分为三个区域。
编辑
我更改了RGB文本文件,以便每种颜色仅属于以下颜色颜色范围:
- 白色
- 灰色
- 洋红色
- 棕色
- 黑色
- 蓝
- 绿色
- 绿松石色
- 黄色
- 橙色
- 红色
Is there an algorithm (I've searched and haven't come up with much) that, given a hex value, is capable of returning the color name? It doesn't have to be anything too specific, any shade of blue coming back as just 'blue' is fine.
Or short of that, is there a large list somewhere that consists of hex values and their corresponding color family. I've found lists, but they only seem to be a couple hundred colors long.
I saw this post, but the solution there seems to only break the color down into three regions.
EDIT
I altered the RGB text file so that each color would only fall into the following color ranges:
- white
- grey
- magenta
- brown
- black
- blue
- green
- turquoise
- yellow
- orange
- red
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如你所说,你已经找到了列表,那么就很简单了。
计算 RGB 颜色的欧几里得距离(例如),并将该颜色称为最接近的名称。
顺便说一句,一百多种颜色对于人类语言来说实际上是一个很大的数字,即使只是一百种颜色,普通人也可能无法区分相当多的颜色之间的差异。
As you said you had already found lists, then it is simple.
Calculate Euclidean Distance of the color for RGB (for instance), and call that color the nearest name.
By the way, over a hundred colors is actually a big number for human languages, and even for just a hundred colors, ordinary people may not able to tell the differences between quite a few colors.
rgb.txt 是通常用于颜色名称的列表。只要找到最接近的三元组并命名它即可。
rgb.txt is the usual list used for color names. Just find the closest triplet and call it that.