Need someone good with color algorythms to figure this out. (Advanced)

I want to get the longest linear string of perceptually changing colors. Basically following the black line on the picture. If you follow the line you are more likely to see a color change as the color is getting darker and lighter from peak of color to troff of color change. Does anyone have an algorithm for this? I want to put in a linear value as if all the black lines were stretched out in one line and get back the color rgb values.
You will be highly esteemed and loved by everyone for figuring this out!

I’m not sure how this would result in a “longest linear string of perceptually changing colors”. But I’m guessing you want a conversion from HSB (Hue, Saturation, Brightness) to RGB. (Or HSL/HSV.) You can find more on that on the wikipedia page.

Ah, now I see what you mean. In that case the longest line is the one that bounces up and down an infinite amount of times, so that won’t really work. You will need to define the number of bounces. Turning a straight line into a bouncing line is fairly straightforward math.

Next you noted the perceptual difference in the change of color. There are various formulas for that, which are also listed on wikipedia.

That’s simple you need enough contrast between each color, there is 3 type of contrast, value, saturation and hue, so you have to sample this space by using equidistant point to maximize contrast between points. How you traverse that space is up to you. But if you want an unbroken line to keep continuity just traverse the array in a snaking pattern

Alternative is all the space filling curve like Hilbert, slice by slice

Similar problem:
https://gamedev.stackexchange.com/questions/46463/how-can-i-find-an-optimum-set-of-colors-for-10-players

Thanks guys for the reply’s. I had a hard time explaining this one. I basically wanted to get the color value underneath the black line. I thought I needed an algorithm for it and started down that road. But then decided on sampling the 15 colors and Lerping between each. So, if I input my float value up to a value of 15. If value is less than 1, I lerp between color[0] and color[1]. if it’s less than 2 then I subtract one from the value and lerp between color[1] and color[2] and work my way though each. It works pretty well.
Thanks Again!
Great links!

1 Like