I’m in need of a way to get similar colors. So for example, if I have an RGB value that gives me a shade of red, for example. How then could I figure out if another RGB value is also a shade of red? I can also convert RGB values to HEX if that would be better for this?
If red is greater than green or blue, it’s a shade of red. Hexidecimal is a base16 numbering system that uses values 0 through F instead of 0 through 9, which is base10. Hex colors are 2 digits for each color, it is based in RGB. So #FF0000 is red, #00FF00 is green, and #0000FF is blue. What you want to consider red is up to your algorithm. Technically #010000 is shaded red, but it’s going to look black to the human eye.
Same thing with RGB, but RGB is a base10 numbering system. rgb(255, 0, 0) is the same as #FF0000.
FF = 255
Edits:
There might be good algorithms to figure this out somewhere, but I’ve never looked into it and I don’t know of any. I found this site Googling: http://www.compuphase.com/cmetric.htm
If you scroll down, you’ll see a function that calculates color distance in C. If you used something like that (I don’t know what language you’re working in), you could just compare it against the base color you want. So, say you wanted to see if something was Red, you’d use that to see the distance your color is from Red. And then check if it’s an acceptable value from the one you set as a predetermined “this is what I consider red” value, then it’s red.
Thanks for the info. It’s making more sense now although will still take some planning. I’m not needing real exact calculations or anything here but still want it to be mostly accurate in that if someone wants to view images that are mostly red, then I definitely don’t want black to show up (even if it technically is a shade of red). That link you gave looks complex but I’ll have to dig into it deeper.