Created
September 23, 2017 21:02
-
-
Save federico-pepe/6e14570b926c502913d915635dba5f93 to your computer and use it in GitHub Desktop.
Glitch di un'immagine con Processing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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