How to convert a hex value into a color name

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

  • 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 is the usual list used for color names. Just find the closest triplet and call it that.

    链接地址: http://www.djcxy.com/p/87538.html

    上一篇: 将RGB转换为RGBA

    下一篇: 如何将十六进制值转换为颜色名称