Reputation: 94
When measuring color distance between two colors, there are plenty of methods. You can use the euclidean distance in the RGB space and you can do more sophisticated calculation such as the perceptual distance in the Lab space (deletE).
But I am asking if there exists any sort of distance that can be measured between a set of colors and another set of colors, which can be referred as palettes. In a first instance both sets could be of the same length, but ideally the set could contain any number of colors.
Eg.
set_1 = {(255, 0, 0), (200, 10, 10), (230, 20, 20)}
set_2 = {(255, 50, 50), (200, 50, 50)}
set_3 = {(0, 255, 0), (10, 255, 10)}
Intutively, the distance between set_1
and set_2
would be smaller than set_1
and set_3
. But I do not know if any method exists to have a quantitive approach to this problem.
I have already tried measuring the distance of the main color of the palette, but I have not found a solution that takes into account all the colors from the sets.
Upvotes: 0
Views: 174
Reputation: 1644
It won't be trivial, even with palettes exactly the same size.
An approach would be to convert RGB colors to YUV (CIE94 would be even better...), then substract the second palette from the first to obtain a vector of distances.
Then, you can compute on this vector average value and the standard deviation: according to what you find, you will be able to say if palettes are "close" or "far" from each other.
This is already a lot of code to implement... But things become ugly with palettes of different sizes. How will you "extend" the shortest one to match the longest one's size?
A possibility could be to set a maximum palette size (let's say 256 colors), and to compute, for EACH compared palette, a 256-entries palettes computed as a regular and homogeneous gradient (compute it directly in YUV/CIE94, not in RGB).
You can then test the two extended palettes with the previous method. But you'll probably have a lot of false positives until you find correct parameters to "calibrate" your algorithm to expand palettes... Maybe go for even larger palettes (1024?) and shrink them with an "antialias" that will merge adjacent colors, once gradient is computed, to reduce rounding errors?
Upvotes: 0