最佳答案
又快又脏:
原文链接:https://www.f2er.com/js/429600.html$dr = $red1 - $red2;
$dg = $green1 - $green2;
$db = $blue1 - $blue2;
$fr = 2; // may be adjusted
$fg = 4; // "
$fb = 1; // "
$distance_squared = $fr * $dr * $dr + $fg * $dg * $dg + $fb * $db * $db;
然后,您将$distance_squared与阈值的平方进行比较.可以调整因子(特别是蓝色可能会得到更高的因子),以及它们的总和(为了匹配阈值)