PImage img = loadImage("robotmarko-g.jpg"); size(600, 400); loadPixels(); img.loadPixels(); for (int y = 0; y < img.height; y++) for (int x = 0; x < img.width; x++) { int imgIndex = x + y * img.width; float r = brightness(img.pixels[imgIndex]); float s = 255 - r; pixels[imgIndex] = color(s); } updatePixels();