Skip to content

Instantly share code, notes, and snippets.

@SteveClement
Created January 26, 2018 16:20
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 SteveClement/fae082146b2d40cfab620bf27b69de6c to your computer and use it in GitHub Desktop.
Save SteveClement/fae082146b2d40cfab620bf27b69de6c to your computer and use it in GitHub Desktop.
Processing examples
PImage kitten;
void setup() {
size(2024, 512);
kitten = loadImage("kitten.jpg");
//kitten.filter(GRAY);
image(kitten, 0, 0);
}
void draw() {
kitten.loadPixels();
for (int x = 0; x < kitten.width; x++) {
for (int y = 0; y < kitten.height; y++) {
int index = x+ y * kitten.width;
color pix = kitten.pixels[index];
float r = red(pix);
float g = green(pix);
float b = blue(pix);
r = round(4* r/ 255) * (255/4);
g = round(4* g/ 255) * (255/4);
b = round(4* b/ 255) * (255/4);
kitten.pixels[index] = color(r, g, b);
}
}
kitten.updatePixels();
image(kitten,kitten.width, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment