We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello everyone, I am writing a code that has turned the pixels of an image into noise. While I am excited that I managed to get the code to scramble an image, I was wondering if anyone had an idea of how to slow the effect down so that when the code is run, the effect is more apparent; rather than the sketch opening, the picture appearing for a moment, and then is scrambled. An algorithm that would slowly update the RGB values- because I am really stumped. Any other suggestions aside from frame rate? Something that could happen in the draw loop? Code follows! Thanks!
PImage img; // The source image
color c;
int r;
int g;
int b;
int loc;
void setup() {
size(564, 424);
img = loadImage("ring.jpg"); // Load the image
image(img,0,0);
loadPixels();
}
void draw() {
updatePixels();
// Begin loop for columns
for (int i = 0; i < img.width; i++ ) {
// Begin loop for rows
for (int j = 0; j < img.height; j++ ) {
//focus on an algorithm to slowly update the RGB values
if(r<255){r=r+10;}else {r=0;}
if(b<255){b=b+10;}else {b=0;}
if(g<255){g=g+10;}else {g=0;}
// print("R:");println(r);
//print("G:");println(r);
//print("B:");println(r);
loc = (int)random(236139);
//loc=i+j*img.width;
/* if(loc<239135)
{
loc++; }
else{loc=0;}*/
c = color(r,g,b);
pixels[loc]=c;
//println(loc);
}//j
}//i
}
Answers
Here is an example that you might to try. The picture can be downloaded from below.
Oh my goodness! This is amazing! this is what I was trying to do! Thank you!!!