For each pixel in pic:
r= random()
if r < 0.25:
set the red level to randrange(0,256),
set the green level to randrange(0,256)
set the blue level to randrange(0,256)
The rest of the unseen code is correct, I just can’t figure out how to phrase this function well enough for it to work.
I don’t know anything about the rest of your code, but it would be something like this:
Again, I don’t know how you get a list of the pixels, or how you set the RGB values for each one, but the result would be something like this.