Cycling through colours over time In blender is there any way to cycle through colours in an image. For example here is an image with 4 distinct sections of different colours.





How could a setup be made so that it recognises red in the top left? Now the red is at 0% on the color ramp so over 10 seconds it would cycle through the colour ramp until it got to 100%. Then in the next section, it would recognise the green is roughly at 66% of the way through the colour ramp. So over 10 seconds it would cycle from 66% to 100% and then from 0% to 66% of the colour ramp so it returns to its initial colour at the end of the animation. And so on for the other sections.

Also, as the white and black have the values rgb(255, 255, 255) and rgb(0, 0, 0) they should not be affected.

I tried using RGB curves connected to the picture and keyframes to achieve this effect, however, it proved unsuccessful.
You can animate the hue. Here's a setup I used some time ago. The hue is cyclic, and often represented by 0° to 360° on a circle, but in Blender it is represented by a value between 0 and 1. Greyscale values, including black and white, will not change by this, because they are completely desaturated.
Further explanations of HSL and HSV on Wikipedia



The Separate HSV and Combine HSV nodes separates a colour into Hue, Saturation and Value and combines Hue, Saturation and Value into a colour. They are located under Converter in the Add menu.

Modulo makes sure the hue never goes above 1. It's a Math node, also located under Converter. However, it doesn't prevent values from becoming negative (specifically, it keeps the value between -1 and 1). The Less Than node (also a Math node) followed by the Add node take care of that, by adding 1 if the value gets below 0. The reason I do not simply select Clamp in the first Add node, is that that would make the cycling stop at 0 if the value became negative and at 1 if the value became greater than one.

Now, animate the value marked with a red rectangle.



Here's a .blend, but I stripped it of the texture I used for the gif above.



UPDATE: The above will make the cycling linear in the positive direction on the hue circle. To make it go the other way, change the first Add node to Subtract. And below is a setup to get more control, for example to make the cycling go back and forth or non-linearly.



The Value node is the one to animate in this case. It's available under Input in the Add menu. The RGB to BW node (available under Converter) isn't strictly necessary; I just added it for clarity, though plugging an RGB into a single value socket, does this conversion automatically.

The output from the ColorRamp node is what gets added to or subtracted from the hue, so by tweaking it, you can make the cycling happen virtually any way you please.

Updated .blend