Is it possible to do a spot blur on an image ?
in
Programming Questions
•
3 years ago
Is it possible to use the dist() function to do a spot blur on an image ?
A better algorithm than this one
a=sblur(_a,a.width/2, a.height/2, 45,15);
A better algorithm than this one
a=sblur(_a,a.width/2, a.height/2, 45,15);
- PImage sblur(PImage img,int _x, int _y, float radius,float amt){
PImage retval = createImage(img.width,img.height,ARGB);
PImage retval2 = createImage(img.width,img.height,ARGB);
arraycopy(img.pixels,retval2.pixels);
retval2.filter(BLUR,amt);
for (int x=0;x<img.width;x++){
for (int y=0;y<img.height;y++){
if(dist(_x,_y,x,y)<radius){
retval.pixels[x+retval.width*y]=retval2.pixels[ x+retval.width*y];
}
else
{
retval.pixels[x+retval.width*y]=img.pixels[ x+retval.width*y];
}
}
}
return retval;
}
1