com.jhlabs.image

Class GaussianFilter

Implemented Interfaces:
BufferedImageOp, Cloneable
Known Direct Subclasses:
GlowFilter, HighPassFilter, UnsharpFilter

public class GaussianFilter
extends ConvolveFilter

A filter which applies Gaussian blur to an image. This is a subclass of ConvolveFilter which simply creates a kernel with a Gaussian distribution for blurring.

Field Summary

protected Kernel
kernel
The convolution kernel.
protected float
radius
The blur radius.

Fields inherited from class com.jhlabs.image.ConvolveFilter

CLAMP_EDGES, WRAP_EDGES, ZERO_EDGES, alpha, kernel, premultiplyAlpha

Constructor Summary

GaussianFilter()
Construct a Gaussian filter.
GaussianFilter(float radius)
Construct a Gaussian filter.

Method Summary

static void
convolveAndTranspose(Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, boolean premultiply, boolean unpremultiply, int edgeAction)
Blur and transpose a block of ARGB pixels.
BufferedImage
filter(BufferedImage src, BufferedImage dst)
float
getRadius()
Get the radius of the kernel.
static Kernel
makeKernel(float radius)
Make a Gaussian blur kernel.
void
setRadius(float radius)
Set the radius of the kernel, and hence the amount of blur.
String
toString()

Methods inherited from class com.jhlabs.image.ConvolveFilter

convolve, convolve, convolveH, convolveHV, convolveV, createCompatibleDestImage, filter, getBounds2D, getEdgeAction, getKernel, getPoint2D, getPremultiplyAlpha, getRenderingHints, getUseAlpha, setEdgeAction, setKernel, setPremultiplyAlpha, setUseAlpha, toString

Methods inherited from class com.jhlabs.image.AbstractBufferedImageOp

clone, createCompatibleDestImage, getBounds2D, getPoint2D, getRGB, getRenderingHints, setRGB

Field Details

kernel

protected Kernel kernel
The convolution kernel.

radius

protected float radius
The blur radius.

Constructor Details

GaussianFilter

public GaussianFilter()
Construct a Gaussian filter.

GaussianFilter

public GaussianFilter(float radius)
Construct a Gaussian filter.
Parameters:
radius - blur radius in pixels

Method Details

convolveAndTranspose

public static void convolveAndTranspose(Kernel kernel,
                                        int[] inPixels,
                                        int[] outPixels,
                                        int width,
                                        int height,
                                        boolean alpha,
                                        boolean premultiply,
                                        boolean unpremultiply,
                                        int edgeAction)
Blur and transpose a block of ARGB pixels.
Parameters:
kernel - the blur kernel
inPixels - the input pixels
outPixels - the output pixels
width - the width of the pixel array
height - the height of the pixel array
alpha - whether to blur the alpha channel
edgeAction - what to do at the edges

filter

public BufferedImage filter(BufferedImage src,
                            BufferedImage dst)
Overrides:
filter in interface ConvolveFilter

getRadius

public float getRadius()
Get the radius of the kernel.
Returns:
the radius

makeKernel

public static Kernel makeKernel(float radius)
Make a Gaussian blur kernel.
Parameters:
radius - the blur radius
Returns:
the kernel

setRadius

public void setRadius(float radius)
Set the radius of the kernel, and hence the amount of blur. The bigger the radius, the longer this filter will take.
Parameters:
radius - the radius of the blur in pixels.

toString

public String toString()
Overrides:
toString in interface ConvolveFilter