// Super Fast Blur v1.1 // by Mario Klingemann // // Tip: Multiple invovations of this filter with a small // radius will approximate a gaussian blur quite well. // BImage a; BImage b; void setup() { a=loadImage("dog.jpg"); size(a.width, a.height); b=new BImage(a.width, a.height); fill(255); noStroke(); framerate(25); } void loop() { System.arraycopy(a.pixels,0,b.pixels,0,a.pixels.length); fastblur(b,mouseY/8); image(b, 0, 0); } void fastblur(BImage img,int radius){ if (radius<1){ return; } int w=img.width; int h=img.height; int wm=w-1; int hm=h-1; int wh=w*h; int div=radius+radius+1; int r[]=new int[wh]; int g[]=new int[wh]; int b[]=new int[wh]; int rsum,gsum,bsum,x,y,i,p,p1,p2,yp,yi,yw; int vmin[] = new int[max(w,h)]; int vmax[] = new int[max(w,h)]; int[] pix=img.pixels; int dv[]=new int[256*div]; for (i=0;i<256*div;i++){ dv[i]=(i/div); } yw=yi=0; for (y=0;y>16; gsum+=(p & 0x00ff00)>>8; bsum+= p & 0x0000ff; } for (x=0;x>16; gsum+=((p1 & 0x00ff00)-(p2 & 0x00ff00))>>8; bsum+= (p1 & 0x0000ff)-(p2 & 0x0000ff); yi++; } yw+=w; } for (x=0;x