%ffp // This template gets you started when you plan to enhance one of // your FilterFactory plugins with FilterMeister. For this purpose it is // important to be put the FF source code into FilterMeister's // ForEverTile handler as it gives you a lot of new possibilities. //------------------------------------------------------------------------------------------ // Filter Infos Category :"AstroPlugins" Title :"Star bloat" Copyright :"@2005" Author :"James Ryan" Organization:"Astroplugins" URL:"http://www.grekalova.com/plugins/" Filename :"Star Isolate.8bf" Description:"Star Bloat" Version :"v1.01" About :"!T !V\n!D\n" "!c\n!U" Dialog: Text = "AstroPlugins Star Bloat !V !c !A" //Only apply filter to RGB and Grayscale images SupportedModes: RGBMode //------------------------------------------------------------------------------------------ // Filter Control Definitions // Insert you own slider label names and comment out the slider that // you don't need ctl(0):"Red",val=30 ctl(1):"Green",val=30 ctl(2):"Blue",val=30 ctl(3):"Radius",range = (0,20), val=3 ctl(4):"Bloat",range = (10,100), val=80 ctl(7):"Counter" //------------------------------------------------------------------------------------------ // Here comes the filter code ForEveryTile:{ int x,y,r,g,b,r1,g1,b1,count,counter; word intensity, cubed, xbox, i,j,k,l,m,n,radius,maxx,maxy,minx,miny; float sumx, sumy, avex, avey, posx, posy,totalr,totalg,totalb,sigmarun,sigmas; float mexp, e, twopi,sigmainv,fx,valuex,valuey, power,dx,dy,dxy,bloat; cubed = ctl(0) + ctl(1) + ctl(2); radius = ctl(3); counter = ctl(7); count = 0; bloat = (float)ctl(4)/100; e = 2.71828; twopi = 2.2675; for (y=y_start; y ctl(0) && g > ctl(1) && b > ctl(2) && tget(x,y,0)==0) { posx = 0; posy = 0; sumx = 0; sumy = 0; totalr = 0; totalb = 0; totalg = 0; m = 0; n = y; while (r > ctl(0) && g > ctl(1) && b > ctl(2) && n < Y) { n = n+1; r = src(x+1,n,0); g = src(x+1,n,1); b = src(x+1,n,2); m=m+1; } xbox = m/2+radius; m=0; maxx = 0; minx = X; maxy = 0; miny = Y; //if (count < counter){Info("%f %f %f %d",sigmarun,sigmas,posx,xbox);count = count +1;} for (j=y; j ctl(0) && g > ctl(1) && b > ctl(2) && tget(i,j,0)==0) { k = x + 2 -i; l = y + xbox - j; if (k*k + l*l < xbox * xbox) { if (i > maxx) maxx = i+radius; if (i < minx) minx = i-radius; if (j > maxy) maxy = j+radius; if (i < miny) miny = j-radius; sumx = sumx + (r + g + b) * i; sumy = sumy + (r + g + b) * j; totalr = totalr + r; totalg = totalg + g; totalb = totalb + b; m = m + 1; tset(i,j,0,1); // pset(i,j,0, r ); // pset(i,j,1, g ); // pset(i,j,2, b); } } } } avex = totalr/m; posx = sumx/(totalr + totalg + totalb); posy = sumy/(totalr + totalg + totalb); sigmarun = 0; for (j=miny; j ctl(0) && g > ctl(1) && b > ctl(2)) { r = src(i,j,0); // g = src(i,j,1) +r; // b = (src(i,j,2) +g); sigmarun = (i - posx) * (i - posx) + sigmarun; } } } sigmas = sqrt(sigmarun/m)*bloat; //if (count < counter){Info("%f %f %f %d",sigmas,maxx,miny,m);count = count +1;} for (j=miny; j ctl(0) && g > ctl(1) && b > ctl(2)) { dx = (i-posx); dy = (j-posy); dxy = sqrt(dx*dx+dy*dy); mexp = -dxy*dxy/(2 * sigmas*sigmas); sigmainv = 1/(sigmas * twopi); power = pow(e,mexp); valuex = sigmainv * power; r = valuex * totalr/sqrt((float)m); g = valuex * totalg/sqrt((float)m); b = valuex * totalb/sqrt((float)m); if (count < counter){Info("t %f %f %f %d r %d",valuex,power,totalr,m,r);count = count +1;} pset(i,j,0, r ); pset(i,j,1, g ); pset(i,j,2, b); } else { pset(i,j,0, r ); pset(i,j,1, g ); pset(i,j,2, b); } } } } } } return true; }//ForEveryTile