Bonus: Glitch 2


PImage img;
int min = 40, max = 80;
int r = 10;
 
void setup() {
  img = loadImage("https://s-media-cache-ak0.pinimg.com/736x/2c/f6/a5/2cf6a58f75b368949cf98db03b925f1b.jpg");
  size(img.width, img.height);
  image(img, 0, 0);
}
 
void draw() {
  doStuff();
}
 
void keyPressed() {
  save(random(123456)+".jpg");
}
 
void doStuff() {
  PImage tmp = createImage(width, height, RGB);
  tmp.loadPixels();
  float rd = random(25, 100);
  for (int px=0; px < width; px++) {
    for (int py=0; py < height; py++) {
      float br = brightness(img.get(px, py));
      if (br>rd) tmp.pixels[py*width+px]=get(px, py);
    }
  }
  tmp.updatePixels();
  int v = (int)random(-r, r);
  int v2 = (int)random(-r, r);
  image(tmp, v, v2);
}
 
void mouseClicked() {
  //doStuff();
}

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *