Pixels and images

HI! I’m a beginner in processing and I’m trying to do a sketch with an image with a noise filter using pixel, but I don’t know exactly what to do.
this is my code right now, but I want the image to have the original color and the noise but with the image still visible.

PImage ed;

float g,b,r;

void setup(){
 size(600,600); 
 ed = loadImage("ed.jpg");
 ed.resize(width,height);
}
void draw(){
  image(ed,0,0);
  loadPixels();
  
    for(int x=0;x<width;x++){
      for(int y=0;y<height;y++){
    int loc = x+y*width;
   r=random(255);
   g = green(ed.pixels[loc]);
   b=random(255);
   pixels[loc]=color(g,b,r);
      }
    }
   
  updatePixels();
}

thanks!

1 Like

Were you able to resolve this?

Do you mean that you want to change the color of each pixel in a random way, just a bit?

This gives you a total different (random) R and B channel. That’s pretty loud noise! You might want something where you get the RGB values (like you currently get G) and then add a small random amount to them. random(-32, 32) would shift the value up to 12% in either direction…

1 Like