I’m building a tool where i pick the dominant colors from an image and i have done that bit pretty well, the problem i’m facing now is how to combine the returned colors into a broad palette range like the X11 color range http://en.wikipedia.org/wiki/Web_colors#X11_color_names
So for example if i got : Color RGB:rgb(102,102,153), i would want to chalk it up to the purple colors and rgb(51,102,204) to blue and so on and so forth. Now i really can’t figure out how to do this. Is there a library or something i can use or how should i code it? I’m using imagemagick and php btw.
Is it possible to generate an array containing the range of rgb for each base colors and then see if my new color lies in it?
Thanks in advance guys!
OK, forget the previous code, here is a much more reliable version I put together from several sources which also uses the more common 0-360 for hue.
I also added a test little routine that picks random colours then ‘tells’ you what they are!
Seems more reliable, some fiddling might be needed around the cut-off values (especially orange/grey etc). I used this online colour picker for testing.