Class GaussianFilter

  • All Implemented Interfaces:
    java.awt.image.BufferedImageOp, java.lang.Cloneable
    Direct Known 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.
    Author:
    Jerry Huxtable
    • Field Detail

      • radius

        protected float radius
        The blur radius.
      • kernel

        protected java.awt.image.Kernel kernel
        The convolution kernel.
    • Constructor Detail

      • GaussianFilter

        public GaussianFilter()
        Construct a Gaussian filter.
      • GaussianFilter

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

      • 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, min-value 0, max-value 100+.
        See Also:
        getRadius()
      • getRadius

        public float getRadius()
        Get the radius of the kernel.
        Returns:
        the radius
        See Also:
        setRadius(float)
      • filter

        public java.awt.image.BufferedImage filter​(java.awt.image.BufferedImage src,
                                                   java.awt.image.BufferedImage dst)
        Specified by:
        filter in interface java.awt.image.BufferedImageOp
        Overrides:
        filter in class ConvolveFilter
      • convolveAndTranspose

        public static void convolveAndTranspose​(java.awt.image.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
        premultiply - whether to premultiply
        unpremultiply - whether to unpremultiply
        edgeAction - what to do at the edges
      • makeKernel

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