Hm...
Your code starts with:
A*(255,0,0) + B*(0,255,0) + C*(0,0,255)
Then the way you increment and decrement stuff, when you're halfway through one state it should be:
A*(127,0,127) + B*(127,127,0) + C*(0,127,127)
So if your initial image was red, then A would be (255, 255, 255), and B and C would be (0,0,0).
So:
(255, 255, 255)*(127,0,127) + (0,0,0)*(127,127,0) + (0,0,0)*(0,127,127)
= (127,0,127)
There's your problem. You need to increment the green until it reaches 255 and THEN start to decrement the red until it is 0, leaving the green at 255, not increment one while decrementing the other simulaneously. The total value of the three channels for each grayscale image should oscillate between 255 and 510.
But due to the way your code works, and a bug you have somewhere, it doesn't do that.
Try printing this:
Text 0,0,c\red+c\green+c\blue
It starts a 255, then jumps to 260 suddenly and stays there/ That's obviously wrong, even if 255 was the right value to always have.
Your code starts with:
A*(255,0,0) + B*(0,255,0) + C*(0,0,255)
Then the way you increment and decrement stuff, when you're halfway through one state it should be:
A*(127,0,127) + B*(127,127,0) + C*(0,127,127)
So if your initial image was red, then A would be (255, 255, 255), and B and C would be (0,0,0).
So:
(255, 255, 255)*(127,0,127) + (0,0,0)*(127,127,0) + (0,0,0)*(0,127,127)
= (127,0,127)
There's your problem. You need to increment the green until it reaches 255 and THEN start to decrement the red until it is 0, leaving the green at 255, not increment one while decrementing the other simulaneously. The total value of the three channels for each grayscale image should oscillate between 255 and 510.
But due to the way your code works, and a bug you have somewhere, it doesn't do that.
Try printing this:
Text 0,0,c\red+c\green+c\blue
It starts a 255, then jumps to 260 suddenly and stays there/ That's obviously wrong, even if 255 was the right value to always have.