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

前端 未结 8 1586
别跟我提以往
别跟我提以往 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:25

    From looking at the Wikipedia page on Color difference, the idea is to treat RGB colours as points in three dimensions. The difference between two colours is the same as the distance between two points:

    difference = sqrt((red1 - red2)^2 + (green1 - green2)^2 + (blue1 - blue2)^2)
    

提交回复
热议问题