PImage sourceimg, lastimg, refimg, dummy, dummyblobs; int imgcounter = 0; String url = "http://images.earthcam.com/ec_metros/newyork/newyork/fridays.jpg"; int avg_source, avg_ref, frame; void setup() { size(640, 240); frameRate(2); sourceimg = loadImage(url); lastimg = sourceimg; refimg = sourceimg; dummyblobs = new PImage(sourceimg.width/4, sourceimg.height/4, RGB); dummy = new PImage(sourceimg.width, sourceimg.height, ARGB); refimg = new PImage(sourceimg.width, sourceimg.height, RGB); } void draw() { background(255); sourceimg = loadImage(url); image(sourceimg, 0, 0, width/2, height); image(refimg, width/2, 0, width/2, height); drawDiff(); //image(dummy, 0, 0, width, height); sourceimg.loadPixels(); lastimg.loadPixels(); arraycopy(sourceimg.pixels, lastimg.pixels); lastimg.updatePixels(); frame ++; } void keyPressed() { //sourceimg.save("/home/zoellner/killswitch_source_"+frame+".jpg"); //refimg.save("/home/zoellner/killswitch_ref_"+frame+".jpg"); saveFrame("superplonk_####"); } void drawDiff() { int avg = 0; for (int i=0; i thispixel) ? lastpixel - thispixel : thispixel - lastpixel; // intensity normalization thisresult -= (thisresult < correction) ? thisresult : correction; if (thisresult < treshold) { refimg.pixels[i] = color( (brightness(refimg.pixels[i]) + brightness(sourceimg.pixels[i])) / 2); } float refpixel = brightness(refimg.pixels[i]); float refresult = (refpixel > thispixel) ? refpixel - thispixel : thispixel - refpixel; if (refresult > treshold) { dummy.pixels[i] = color(0,255,0,150); } else { dummy.pixels[i] = color(0,0,0,0); } dummy.updatePixels(); refimg.updatePixels(); avg_ref = avg_source; } }