I'm thinking about writing a little library to make a guess at the name of an (RGB value) colour, from a predetermined list of candidates.
My first attempt was based purely on pythagorean distance within the three-dimensional RGB colour space - this wasn't massively succesful as most of the named colour points were at the edges of the space (eg Blue at 0, 0, 255), so, for most colours in the middle of the space, the named colour that it was closest too was fairly arbitrary.
So, I'm thinking about better approaches and have come up with a few candidates
Cylindrical distance within an HSV colourspace - which may well have similar problems to the above, however, HSV seems to be more meaningful in a human sort of sense than RGB, which could be useful.
Either of the above, but with each named colour point being weighted with an arbitrary value that denotes the strength of its attraction to points in the surrounding space. is there a name for such a model? I realise this is a bit vague, but it seems like a fairly intuitive idea to me.
A Bayesian network that examines properties of an HSV colour and returns the most likely colour name (I'm imagining nodes similar to, for instance P(Black | Saturation < 10), P(Red | Hue = 0), However, this seems less than ideal - for instance, the probability that a given colour is red is proportional to how close its hue is to 0, rather than being a discrete value. Is there a way of adapting bayesian networks to deal with probabilities that are continuous on the variable being tested?
Finally, I was wondering if some sort of Support Vector Machine-based classification within either the HSV or RGB colour space, but not being massively familiar with these, I'm unsure whether this will offer any particular advantage over the pythagorean distance based approach I tried originally, especially as I'm only dealing with a three dimensional space.
Therefore, I was wondering, do any of you have any experience with similar problems, or know of any resources that might be able to help me to decide on an approach? If anyone could point me in the right direction (whether it's one of the above, or something entirely different) I'd be extremely grateful.
Cheers!
Tim
Name that Color seems to determine the name based on both the RGB and HSL values, perhaps you could use something similar.
After having a quick look at the script, it seems to pick the color that is closest to the given color in terms of both RGB and HSL. It's basically just a big map of predefined colors and does nothing advanced, such as weighted values, but given the large amount of defined color names, it may be 'good enough', depending on your requirements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With