Maybe you could restate your problem / goal.
What, concretely are you trying to produce as output? A single grid of boxes, of arbitrary dimensions, that represents a 255 brightness value?
And then you want to display that one single grid on the screen – e.g. the whole sketch canvas taken up by a single 8x8 grid of rectangles, with 64 values, representing a 0-255 brightness?
And then you want to animate it by permutations for that one pixel that you are measuring? So the pixel is 101/255, so you round that to 25 and permute 25 bright boxes across a grid of 64 boxes?
Is that right?
What happens once you have animated through all the permutations of that one pixel? Do you move on to the next pixel in the image and start over?