What is the best algorithm for finding the closest color in an array to another color?

algorithm, colors

Solution

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.

Problem

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.

Original source

Related problems