Skip to content

Instantly share code, notes, and snippets.

@maxattack
Created March 8, 2017 23:54
Show Gist options
  • Save maxattack/a6e938825f326182f44bd885272e4b21 to your computer and use it in GitHub Desktop.
Save maxattack/a6e938825f326182f44bd885272e4b21 to your computer and use it in GitHub Desktop.
RB remap
PImage img;
img = loadImage("https://espnfivethirtyeight.files.wordpress.com/2017/03/wasserman-landslides1.png", "png");
img.loadPixels();
int w = img.width;
int h = img.height;
int len = w * h;
for(int i=0; i<len; ++i) {
color c = img.pixels[i];
float r = red(c);
float b = blue(c);
println(r);
float normalize = 1.0 / sqrt(r*r + b*b);
r *= normalize;
b *= normalize;
img.pixels[i] = color(255 * r, 0, 255 * b);
}
img.updatePixels();
img.save("remapped.png");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment