%ffp Category: "easy.Filter" Title: "Edge detection" Version: "1.0" Filename: "edgedetection.8bf" Author: "Alois Zingl" Copyright:"© 2008" URL: "http://free.pages.at/easyfilter/gauss.html" Description:"Detection monochrome edges by derivative convolution." // fast and easy: works only in RGB 8bit mode and considers only grey pixel values SupportedModes: RGBMode ctl(0): "Blur (pixels)", divisor = 2, range=(1,N_CELLS/3) OnFilterStart: { int Blur = doingProxy?(ctl(0)+scaleFactor/2)/scaleFactor:ctl(0); // blur radius needPadding = 3*Blur/2+2; bandWidth = 100+4*needPadding; isTileable = !doingProxy; // split large images return false; } ForEveryTile: { int Blur = max(1, (ctl(0)+scaleFactor/2)/scaleFactor); // blur radius int x, y, z, p, Blur2 = (3*Blur+1)/2; double Weight = 1.0/(Blur*Blur*Blur); for (x = x_start; x= y_start) dif -= 3*get(y+2*Blur);// -3, if (y+Blur >= y_start) dif += 3*get(y+Blur); // +3, if (y >= y_start) // -1} { dif -= get(y); p = (der*Blur*Weight/2)+2048; // derivation and .. psetp(x, y, (int)(sum*Weight)+(p<<12)); // .. blur stored in 12 bit accuracy } sum += der; der += dif; // accumulate pixel blur } // y } // x //Update progress bar and cancel if ESC key was pressed if (updateProgress(doingProxy*y_start+y_end, doingProxy?y_end-y_start:Y)) abort(); for (y = y_start; y < y_end; ++y) // horizontal blur for every column { int dif = 0, der = 0, sum = 0; // blur int dif2 = 0, sum2 = 0, p2; // derivative blur for (x = x_start-3*Blur; x < x_end; ++x) // horizontal blur loop { p = pgetp(x+Blur2, y)&0xffffff; // pixel value put(p, x+3*Blur); // buffer pixel, min buffer size: 3*Blur dif += p>>12; dif2 += p&0xfff;// accumulate differences {+1, if (x+2*Blur >= x_start) // -3, { p = get(x+2*Blur); dif -= 3*(p>>12); dif2 -= 3*(p&0xfff); } if (x+Blur >= x_start) // +3, { p = get(x+Blur); dif += 3*(p>>12); dif2 += 3*(p&0xfff); } if (x >= x_start) // -1} { p = get(x); dif -= p>>12; dif2 -= p&0xfff; p = 2*sum*Weight-4096; // horizontal edges p2 = sum2*Blur*Weight; // vertical edges p = min(255, sqr(p*p+p2*p2)/12); // sum up edges psetp(x, y, p*0x10101); // set RGB pixel } sum += der; der += dif; sum2 += dif2; // accumulate pixel blur } // x } // y return true; //Done! } OnFilterEnd: { updateProgress(0, 1); return false; }