Ask Your Question
0

How to know the name of the standard Color present in Color.colorlist

asked 2013-08-08 14:15:35 -0500

Shuvam_Bosana gravatar image

I have a color and I want to know its name. As the color can be anything and thus might not have any real name, I am detecting the closest standard color (among the ones present in SimpleCV.Color.colorlist) with this code:

c_match=img_in.toRGB().meanColor()
least=255*3
color=None
for c in s.Color.colorlist:
    diff=0
    for rgb in range(3):
        diff+=abs(c_match[rgb]-c[rgb])
    if diff<least:
        print(diff)
        print(c)
        color=c
        least=diff

print(color)

Now the thing is how can I know the name of this color variable?

I am guessing this is not really possible with SimpleCV because of the way the color module is arranged, but in that case shouldnt it be more helpful so that this things are possible by default?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2013-08-09 15:58:44 -0500

Shuvam_Bosana gravatar image

o thnks.. this would be a great help..

edit flag offensive delete link more
0

answered 2013-08-09 07:18:23 -0500

Davis Marques gravatar image

updated 2013-08-09 07:20:49 -0500

If I'm understanding your question correctly: You might consider using the webcolors package (available in PiPi at https://pypi.python.org/pypi/webcolors/). It provides a variety of functions for converting colors from one representation to another. Of interest to you would be the rgbtoname() function.

https://webcolors.readthedocs.org/en/v1.4/#webcolors.rgbtoname

The one drawback with this function is that it requires an exact match. If you don't have an exact match, it throws a ValueError.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-08-08 14:15:35 -0500

Seen: 369 times

Last updated: Aug 09 '13