/* * A filter to convert to sepia tone. */ PImage slu; int w,h; void setup() { size(408,300); // take advantage of our knowledge of the size // Can either load an image stored locally, as follows: // slu = loadImage("campus4.jpg"); // Or can load an image from a URL as follows: slu = loadImage("http://business.slu.edu/uploads/2012/11/08/slu-homepage-campus4.jpg"); w = slu.width; h = slu.height; for (int x=0; x < w; x++) { for (int y=0; y < h; y++) { color c = slu.get(x,y); float newRed = 0.393 * red(c) + 0.769 * green(c) + 0.189 * blue(c); float newGreen = 0.349 * red(c) + 0.686 * green(c) + 0.168 * blue(c); float newBlue = 0.272 * red(c) + 0.534 * green(c) + 0.131 * blue(c); color replace = color(min(newRed,255), min(newGreen,255), min(newBlue,255)); slu.set(x,y,replace); } } // time to display it image(slu, 0, 0); }