Using the distance of the colors in a Euclidian space makes sense, but RGB isn't the best space to use.
You probably want something like CIELAB which is (quoting from Wikipedia) "designed so that the same amount of numerical change... corresponds to roughly the same amount of visually perceived change."
You probably want something like CIELAB which is (quoting from Wikipedia) "designed so that the same amount of numerical change... corresponds to roughly the same amount of visually perceived change."
https://en.m.wikipedia.org/wiki/CIELAB_color_space