Skip to content

Instantly share code, notes, and snippets.

@ynaoto
Created July 3, 2014 03:24
Show Gist options
  • Save ynaoto/957f5eb045f21f154e42 to your computer and use it in GitHub Desktop.
Save ynaoto/957f5eb045f21f154e42 to your computer and use it in GitHub Desktop.
background(255, 0, 0);
PImage img = loadImage("179033_486608097723_1903922_n.jpg");
img.loadPixels();
int n = img.width * img.height;
for (int i = 0; i < n; i++) {
color c = img.pixels[i];
float a = alpha(c);
float r = red(c);
float g = green(c);
float b = blue(c);
a = max(r, g, b);
img.pixels[i] = color(r, g, b, a);
}
img.updatePixels();
image(img, 0, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment