Is it possible to classify html hex colours into simple string values??
For example, the colour #CC3333, it’s not completely red, but as a human we can assume that it’s red. The colour #CCCCCC can be classified as white, because I don’t want black or grey involved.
Possible simple values at least consist of:
- red
- white
- green
More classification is better, but I want at least these colours.
Can it be done?
Optional info:
I’m creating a web apps that capture the pictures through webcam. The user can hold a white or red paper to the webcam and the apps detect the image’s major colour. Then the user will be redirected to a different options depending on their colour. I’ve done the colour detection, but I just want classify it into several colour only, red,white,and green.
This is a somewhat subjective question, because yes it can be done, but exactly how you would do it would depend on your specific application – colour itself is very subjective in the way that it is observed by the individual.
You would need to start by splitting the string into it’s red, green and blue components:
Then, it would probably be an idea to convert them to integers:
Then you need to apply some sort of logic to it to determine which one of your classes it falls into. How you do this is really up to you, but maybe you could do something like this: