How can I generate a color keeping a consistency?

54 Views Asked by At

I need some advice that could help me with the problem that I'm going to explain.

I have a list of lists with some values, these are some examples:

[9798, 15349596, 692, 142, 45568, 0, 1, 1, 1.9821, 3105.3198, 0.1399, 0.02872, 9.2186, 22181.4971, 4, 0, 50, 0, 5, 0, 33255, 161, 172, 0.805, 0.86, 166.275, 4943]
[0, 0, 44, 7, 0, 1, 1, 0, 0.0, 0.0, 0.06800618238021638, 0.010819165378670788, 0.0, 0.0, 15, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0, 647]

Each number is a feature of an user and, as you can see, there are some 1s and 0s that represent some boolean value. Obviously, the lists have the same length.

Now, I want to generate a color (or colors, like a color-mapping function) from those lists keeping a sort of "consistency" between the colors.

An example of what I mean with consistency: suppose that I have two lists that are pretty the same

[0, 0, 44, 7, 0, 1, 1, 0, 0.0, 0.0, 0.06800618238021638, 0.010819165378670788, 0.0, 0.0, 15, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0, 647]
[1, 0, 44, 7, 0, 1, 1, 0, 0.0, 0.0, 0.06800618238021638, 0.010819165378670788, 0.0, 0.0, 15, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0, 647]

as you can see in this example the difference is only the first value. If the algorithm produces the red for the first list, I want the red (or similar) for the second one.

I'm looking for a sort of idea, because I don't have any :(. As note I'm using python, but I'm not looking for the code, just an idea or references to some algorithm.

Thank you in advance :)!

1

There are 1 best solutions below

1
datenwolf On

Consider a color space along 3 axes (could be RGB, XYZ, La*b*, etc.). For each axis' endpoint define what specific "extreme" values of your feature vectors you want to map there; the unnormalized length of each axis would be the Levenshtein distance between these vectors.

Then to map a feature vector, determine its Levenshtein distance to the endpoints along each axis, normalize it, then use the value on each axis as point in your designated color space.