Framerate in live video delay project : Ed Tannenbaum, Recollections

You are still computing the int() operation and the modulus one for every pixel of the image.

Again, I really don’t know if this can be it, I’m not qualified enough to be sure about the performance of those functions. Someone more capable can surely tell us if it can be that.

Edit:

You can try something like this.
You create an array with 256 values let’s call it brightToCol.
Since you have 8 different colors you would fill it in like this:

brightToCol[0] = 0;
brightToCol[1] = 1;
...
brightToCol[6] = 6;
brightToCol[7] = 0;
brightToCol[8] = 1;
...

Then you can get your color with this line:

color cc=colors2[brightToCol[b]];

Is this better? Specially combined with @GoToLoop optimization.