Class GaussianBlurFilter

All Implemented Interfaces:
BufferedImageOp

public class GaussianBlurFilter extends AbstractFilter
  • Field Details

    • radius

      private final int radius
  • Constructor Details

    • GaussianBlurFilter

      public GaussianBlurFilter()

      Creates a new blur filter with a default radius of 3.

    • GaussianBlurFilter

      public GaussianBlurFilter(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.

      Parameters:
      radius - the radius, in pixels, of the blur
  • Method Details

    • getRadius

      public int getRadius()

      Returns the radius used by this filter, in pixels.

      Returns:
      the radius of the blur
    • filter

      public BufferedImage filter(BufferedImage src, BufferedImage dst)
      Specified by:
      filter in interface BufferedImageOp
      Specified by:
      filter in class AbstractFilter
    • blur

      static void blur(int[] srcPixels, int[] dstPixels, int width, int height, float[] kernel, 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.

      Parameters:
      srcPixels - the source pixels
      dstPixels - the destination pixels
      width - the width of the source picture
      height - the height of the source picture
      kernel - the kernel of the blur effect
      radius - the radius of the blur effect
    • createGaussianKernel

      static float[] createGaussianKernel(int radius)