Finding Similar HEX colors using a threshold
image-processing, javascript, php
Solution
quick and dirty:
$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;
You would then compare `$distance_squared` to the square of the threshold. The factors may be adjusted (especially blue might get a higher factor), as well as their sum (in order to match the threshold)
For a "slow and clean" solution, I would start from here (and here for a more practical approach).
Problem
I have an array of RGB hex colors. I would like to find a quick and dirty way to group them by color similarity and threshold value. spec: