%ffp Category: "easy.Filter" Title: "Blur - Sharpen" Version: "1.0" Filename: "blursharpen.8bf" Author: "Alois Zingl" Copyright:"© 2008" URL: "http://free.pages.at/easyfilter/gauss.html" Description:"Improve contrast by blur and sharpen." ctl(0): "Radius (pixels)", val = 4, divisor = 2, range=(0,340) ctl(1): "Blur (%)", range = (0, 100), val = 32 ctl(2): "Sharpen (%)", val = 64 ctl(3): "Threshold (0..255)", val = 16 OnFilterStart: { int Blur = doingProxy?(ctl(0)+scaleFactor/2)/scaleFactor:ctl(0); // blur radius needPadding = 3*Blur/2+2; isTileable = !doingProxy; // split large images bandWidth = 100+4*needPadding; return false; } ForEveryTile: { int Blur = sqrt(1.0+ctl(0)*ctl(0)/(scaleFactor*scaleFactor)); // blur radius int x, y, z, i, Blur2 = (3*Blur+1)/2; double Weight = Blur*Blur*Blur; int th = (imageMode= y_start) dif -= 3*get(y+2*Blur);// -3, if (y+Blur >= y_start) dif += 3*get(y+Blur); // +3, (-1)} } for (; y= x_start) dif -= 3*get(x+2*Blur); // -3, if (x+Blur >= x_start) dif += 3*get(x+Blur); // +3, (-1)} } for (; x < x_end; ++x) { // inner horizontal blur loop sum += der; der += dif; // accumulate pixel blur p = (int)(sum/Weight)-src(x, y, z); // local contrast p = (2*ctl(1)*p - ctl(2)*(abs(p-th)-abs(p+th)+2*p))/200; // blur - sharpen pset(x, y, z, src(x, y, z)+p); p = pget(x+Blur2, y, z); // next pixel put(p, x+3*Blur); // buffer pixel dif += p+3*(get(x+Blur)-get(x+2*Blur))-get(x); // {+1,-3,+3,-1} } // x } // y } // color plane return true; //Done! } OnFilterEnd: { updateProgress(0, 1); return false; }