How to judge whether it is in a certain color range after obtaining the color value of canvas

I would like to ask how I get the RGBA value of a color in canvas and how it matches the color in the specified color array.

I want to match the acquired colors with the colors in the array, and replace the acquired colors with similar colors!

is there any way I can give you some advice? It is not clear how to match! I don"t know how to find the approximate value!

Mar.18,2021

calculate the color with the smallest distance. There are many algorithms for color distance. Please refer to Wikipedia

.

https://zh.wikipedia.org/wiki.

the simplest method is, of course, the spatial distance algorithm, which takes the square root of the following value:
(r2-r1) ^ 2 + (g2-g1) ^ 2 + (b2-b1) ^ 2

but the reality is that this "distance" is not consistent with the "distance" felt by the human eye. A better algorithm is to convert RGB to LAB before calculating. Of course, there is a better algorithm, please refer to the above documentation.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be9eff-319b0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be9eff-319b0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?