Assume we have a priorly known set of n colors C. We are given a list of colors l.
The goal is for every color l, match it to a color in C such that it minimizes a distance function D.
The most straightforward approach is to use the euclidean distance, however that's not a good idea because of the following example:
Assume the input color is (0.1, 0, 0) so very dark red. Assume that brown (0,5, 0.5, 0) and pure red (1,0,0) are both in C.
The euclidean distance gives:
distance to brown = (0.4^2 + 0.5^2) = 0.41
distance to red = (0.9^2) = 0.81
Thus dark red is mapped to brown instead of red, which visually doesn't really make sense.
We could try the chebychev distance:
distance to brown = max(0.4, 0.5, 0) = 0.5
distance to red = max(0.9, 0, 0) = 0.9
Or the manhattan distance:
distance to brown = max(0.4 + 0.5) = 0.9
distance to red = max(0.9 + 0 + 0) = 0.9
The first still chooses brown over red, where the second picks both as equally valid choices. Although an improvement, it's not the ideal.
I however am not sure how to measure "visual distance", i.e if a color would "look green" to a human, how to map said color to green for example.
I am using opencv, and I have searched the documentation but I don''t seem to find if this problem is already solved.