Given an RGB value what would be the best way to find the closest match in the database?

前端 未结 8 1582
别跟我提以往
别跟我提以往 2020-12-04 17:02

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

8条回答
  •  北海茫月
    2020-12-04 17:20

    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.

提交回复
热议问题