public class FastBlurFilter extends AbstractFilter
A fast blur filter can be used to blur pictures quickly. This filter is an implementation of the box blur algorithm. The blurs generated by this algorithm might show square artifacts, especially on pictures containing straight lines (rectangles, text, etc.) On most pictures though, the result will look very good.
The force of the blur can be controlled with a radius and the default radius is 3. Since the blur clamps values on the edges of the source picture, you might need to provide a picture with empty borders to avoid artifacts at the edges. The performance of this filter are independent from the radius.
Modifier and Type | Field and Description |
---|---|
private int |
radius |
Constructor and Description |
---|
FastBlurFilter()
Creates a new blur filter with a default radius of 3.
|
FastBlurFilter(int radius)
Creates a new blur filter with the specified radius.
|
Modifier and Type | Method and Description |
---|---|
(package private) static void |
blur(int[] srcPixels,
int[] dstPixels,
int width,
int height,
int radius)
Blurs the source pixels into the destination pixels.
|
BufferedImage |
filter(BufferedImage src,
BufferedImage dst) |
int |
getRadius()
Returns the radius used by this filter, in pixels.
|
createCompatibleDestImage, getBounds2D, getPoint2D, getRenderingHints
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, clone, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getPropertyChangeListeners, getPropertyChangeListeners, getVetoableChangeListeners, getVetoableChangeListeners, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
private final int radius
public FastBlurFilter()
Creates a new blur filter with a default radius of 3.
public FastBlurFilter(int radius)
Creates a new blur filter with the specified radius. If the radius is lower than 1, a radius of 1 will be used automatically.
radius
- the radius, in pixels, of the blurpublic int getRadius()
Returns the radius used by this filter, in pixels.
public BufferedImage filter(BufferedImage src, BufferedImage dst)
filter
in interface BufferedImageOp
filter
in class AbstractFilter
static void blur(int[] srcPixels, int[] dstPixels, int width, int height, int radius)
Blurs the source pixels into the destination pixels. The force of the blur is specified by the radius which must be greater than 0.
The source and destination pixels arrays are expected to be in the INT_ARGB format.
After this method is executed, dstPixels contains a transposed and filtered copy of srcPixels.
srcPixels
- the source pixelsdstPixels
- the destination pixelswidth
- the width of the source pictureheight
- the height of the source pictureradius
- the radius of the blur effectWebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses