I have a color (RGB) being read from a sensor. I also have a list of “known” colors, each paired with a string name.
What would the best way (ie behave like a human choosing colors) to pull the name of the nearest color out of this list?
I’ve tried a shortest cartesian distance with RGB, but that makes grey closer to green than to black or white.
Rather than using RGB, try using an HSL (Hue, Saturation, Lightness) or HSV (Hue, Saturation and Value) color model. Then experiment with different elements of bias, e.g. hue being more important than luminance when you’re calculating the distance.