quick and dirty:
$dr = $red1 - $red2;
$dg = $green1 - $green2;
$db = $blue1 - $blue2;
$fr = 2;
$fg = 4;
$fb = 1;
$distance_squared = $fr * $dr * $dr + $fg * $dg * $dg + $fb * $db * $db;
Then you compare $distance_squaredwith the squared threshold. Factors can be adjusted (especially blue can get a higher coefficient), as well as their amount (to match the threshold)
For a βslow and cleanβ solution, I started with here (and here for a more practical approach).
source
share