What is the optimal way to select by color?
The Wikipedia page Color difference gives several formulas, the most advanced being CIEDE2000. They are all based on Euclidean distance $\Delta E$ (straight line distance) in the approximately perceptually uniform CIE Lab color space, with various corrections.