Reputation: 779
Does an algorithm exists that will input a color's hex value and output what color family that value belongs to? For example if i input 3333FF it would identify that as being a shade of blue. I would need to be able to input any hex value and narrow it down to one of the 24 colors on a standard color wheel plus black, white, and grey. (i would consider black all grey values up to #151515, and white all values down to #F1F1F1)
Upvotes: 3
Views: 1564
Reputation: 17314
One way would be to convert the hex code to HSV and then split up the hue value into regions. So you just check the hue, if it's between these two values it's red, if it's between these it's yellow, etc. You can also check saturation and lightness to determine what to call white, grey, and black. Those thresholds will be all up to you.
Upvotes: 3