Skip to content

Instantly share code, notes, and snippets.

@federico-pepe
Created September 23, 2017 21:02
Show Gist options
  • Save federico-pepe/6e14570b926c502913d915635dba5f93 to your computer and use it in GitHub Desktop.
Save federico-pepe/6e14570b926c502913d915635dba5f93 to your computer and use it in GitHub Desktop.
Glitch di un'immagine con Processing
/*
* Glitch di un'immagine con Processing
* Federico Pepe, 23.09.2017
* http://blog.federicopepe.com/processing
*/
PImage img;
int minThreshold = 200;
int maxThreshold = 255;
void setup() {
size(1, 1);
surface.setResizable(true);
img = loadImage("fire.jpg");
surface.setSize(img.width, img.height);
noStroke();
noLoop();
}
void draw() {
background(255);
image(img, 0, 0);
img.loadPixels();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
if (brightness(img.pixels[y*width+x]) > minThreshold && brightness(img.pixels[y*width+x]) < maxThreshold) {
color c = get(x, y);
stroke(c);
line(x, y, x, y+2);
noFill();
}
}
}
}
void mousePressed() {
save("export/export.png");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment