Class BoxBlurFilter

All Implemented Interfaces:
BufferedImageOp, Cloneable

public class BoxBlurFilter extends AbstractBufferedImageOp
A filter which performs a box blur on an image. The horizontal and vertical blurs can be specified separately and a number of iterations can be given which allows an approximation to Gaussian blur.
  • Constructor Details

    • BoxBlurFilter

      public BoxBlurFilter()
      Construct a default BoxBlurFilter.
    • BoxBlurFilter

      public BoxBlurFilter(float hRadius, float vRadius, int iterations)
      Construct a BoxBlurFilter.
      Parameters:
      hRadius - the horizontal radius of blur
      vRadius - the vertical radius of blur
      iterations - the number of time to iterate the blur
  • Method Details

    • setPremultiplyAlpha

      public void setPremultiplyAlpha(boolean premultiplyAlpha)
      Set whether to premultiply the alpha channel.
      Parameters:
      premultiplyAlpha - true to premultiply the alpha
      See Also:
    • getPremultiplyAlpha

      public boolean getPremultiplyAlpha()
      Get whether to premultiply the alpha channel.
      Returns:
      true to premultiply the alpha
      See Also:
    • filter

      public BufferedImage filter(BufferedImage src, BufferedImage dst)
    • blur

      public static void blur(int[] in, int[] out, int width, int height, float radius)
      Blur and transpose a block of ARGB pixels.
      Parameters:
      in - the input pixels
      out - the output pixels
      width - the width of the pixel array
      height - the height of the pixel array
      radius - the radius of blur
    • blurFractional

      public static void blurFractional(int[] in, int[] out, int width, int height, float radius)
    • setHRadius

      public void setHRadius(float hRadius)
      Set the horizontal size of the blur.
      Parameters:
      hRadius - the radius of the blur in the horizontal direction
      See Also:
    • getHRadius

      public float getHRadius()
      Get the horizontal size of the blur.
      Returns:
      the radius of the blur in the horizontal direction
      See Also:
    • setVRadius

      public void setVRadius(float vRadius)
      Set the vertical size of the blur.
      Parameters:
      vRadius - the radius of the blur in the vertical direction
      See Also:
    • getVRadius

      public float getVRadius()
      Get the vertical size of the blur.
      Returns:
      the radius of the blur in the vertical direction
      See Also:
    • setRadius

      public void setRadius(float radius)
      Set both the horizontal and vertical sizes of the blur.
      Parameters:
      radius - the radius of the blur in both directions
      See Also:
    • getRadius

      public float getRadius()
      Get the size of the blur.
      Returns:
      the radius of the blur in the horizontal direction
      See Also:
    • setIterations

      public void setIterations(int iterations)
      Set the number of iterations the blur is performed.
      Parameters:
      iterations - the number of iterations
      See Also:
    • getIterations

      public int getIterations()
      Get the number of iterations the blur is performed.
      Returns:
      the number of iterations
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object