This asks a question or what kind of proximity in colors.
You need to try this; colors are not all maths. If you want to find the distance between two points in three-dimensional space (three colors), then the one indicated in color 1 and color2 will be: ((r2-r1) ^ 2 + (b2-b2) ^ 2 + (g2-g1) ^ 2) ^ 0.5 (the final square root is not needed for comparison purposes).
Perhaps the best way is to do the calculations in the HSB space, maybe just look at Hue.
source share