PImage orig, filtered; int w, h; void setup() { size(1024, 768); orig = loadImage("https://upload.wikimedia.org/wikipedia/commons/thumb/e/ed/SLU_portals.jpg/1024px-SLU_portals.jpg"); w = orig.width; h = orig.height; filtered = createImage(w, h, RGB); for (int x=0; x < w-1; x++) { for (int y=0; y < h-1; y++) { color a = orig.get(x,y); color b = orig.get(x+1,y); color c = orig.get(x,y+1); float rv = 2*red(a) - red(b) - red(c); float gv = 2*green(a) - green(b) - green(c); float bv = 2*blue(a) - blue(b) - blue(c); filtered.set(x,y,color(rv,gv,bv)); } } image(filtered,0,0); save("edgeDiag.jpg"); }