Created
March 8, 2017 23:54
-
-
Save maxattack/a6e938825f326182f44bd885272e4b21 to your computer and use it in GitHub Desktop.
RB remap
This file contains 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
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