I have a rgb value and if it doesn\'t exist in the color table in my database I need to find the closest color. I was thinking of comparing all values and finding the diffe
Calculate both the average and the distance like this:
(r + g + b) / 3 = average (r - average) + (g - average) + (b - average) = distance
This should give you a good idea of the closest value.