Skip to content

Instantly share code, notes, and snippets.

@sota1235
Created February 13, 2014 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sota1235/8980916 to your computer and use it in GitHub Desktop.
Save sota1235/8980916 to your computer and use it in GitHub Desktop.
/* Created by sota1235
* Date:2014/02/14
*/
PImage img, img2;
img = loadImage("path/image");
int w = img.width, h = img.height;
size(w, h);
img2 = createImage(w,h,RGB);
img.loadPixels();
img2.loadPixels();
for(int i=0;i<w*h;i++){
if(brightness(img.pixels[i]) > 180) {
img2.pixels[i] = color(255);
} else {
img2.pixels[i] = color(0);
}
}
img.updatePixels();
img2.updatePixels();
image(img2, 0, 0);
save("path/");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment