com.jhlabs.image
Class ConvolveFilter

java.lang.Object
  extended by com.jhlabs.image.AbstractBufferedImageOp
      extended by com.jhlabs.image.ConvolveFilter
All Implemented Interfaces:
java.awt.image.BufferedImageOp
Direct Known Subclasses:
GaussianFilter

public class ConvolveFilter
extends AbstractBufferedImageOp

A filter which applies a convolution kernel to an image.

Author:
Jerry Huxtable

Field Summary
static int CLAMP_EDGES
           
static int WRAP_EDGES
           
static int ZERO_EDGES
           
 
Constructor Summary
ConvolveFilter()
          Construct a filter with a null kernel.
ConvolveFilter(float[] matrix)
          Construct a filter with the given 3x3 kernel.
ConvolveFilter(int rows, int cols, float[] matrix)
          Construct a filter with the given kernel.
ConvolveFilter(java.awt.image.Kernel kernel)
          Construct a filter with the given 3x3 kernel.
 
Method Summary
static void convolve(java.awt.image.Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction)
           
static void convolve(java.awt.image.Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, int edgeAction)
           
static void convolveH(java.awt.image.Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction)
          Convolve with a kernel consisting of one row.
static void convolveHV(java.awt.image.Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction)
          Convolve with a 2D kernel.
static void convolveV(java.awt.image.Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction)
          Convolve with a kernel consisting of one column.
 java.awt.image.BufferedImage createCompatibleDestImage(java.awt.image.BufferedImage src, java.awt.image.ColorModel dstCM)
           
 java.awt.image.BufferedImage filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dst)
           
 java.awt.geom.Rectangle2D getBounds2D(java.awt.image.BufferedImage src)
           
 int getEdgeAction()
           
 java.awt.image.Kernel getKernel()
           
 java.awt.geom.Point2D getPoint2D(java.awt.geom.Point2D srcPt, java.awt.geom.Point2D dstPt)
           
 java.awt.RenderingHints getRenderingHints()
           
 boolean hasAlpha()
           
 void setEdgeAction(int edgeAction)
           
 void setKernel(java.awt.image.Kernel kernel)
           
 java.lang.String toString()
           
 
Methods inherited from class com.jhlabs.image.AbstractBufferedImageOp
getRGB, setRGB
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLAMP_EDGES

public static final int CLAMP_EDGES
See Also:
Constant Field Values

WRAP_EDGES

public static final int WRAP_EDGES
See Also:
Constant Field Values

ZERO_EDGES

public static final int ZERO_EDGES
See Also:
Constant Field Values
Constructor Detail

ConvolveFilter

public ConvolveFilter()
Construct a filter with a null kernel. This is only useful if you're going to change the kernel later on.


ConvolveFilter

public ConvolveFilter(float[] matrix)
Construct a filter with the given 3x3 kernel.

Parameters:
matrix - an array of 9 floats containing the kernel

ConvolveFilter

public ConvolveFilter(int rows,
                      int cols,
                      float[] matrix)
Construct a filter with the given kernel.

Parameters:
rows - the number of rows in the kernel
cols - the number of columns in the kernel
matrix - an array of rows*cols floats containing the kernel

ConvolveFilter

public ConvolveFilter(java.awt.image.Kernel kernel)
Construct a filter with the given 3x3 kernel.

Parameters:
kernel - Description of the parameter
Method Detail

setEdgeAction

public void setEdgeAction(int edgeAction)

setKernel

public void setKernel(java.awt.image.Kernel kernel)

getBounds2D

public java.awt.geom.Rectangle2D getBounds2D(java.awt.image.BufferedImage src)
Specified by:
getBounds2D in interface java.awt.image.BufferedImageOp
Overrides:
getBounds2D in class AbstractBufferedImageOp

getEdgeAction

public int getEdgeAction()

getKernel

public java.awt.image.Kernel getKernel()

getPoint2D

public java.awt.geom.Point2D getPoint2D(java.awt.geom.Point2D srcPt,
                                        java.awt.geom.Point2D dstPt)
Specified by:
getPoint2D in interface java.awt.image.BufferedImageOp
Overrides:
getPoint2D in class AbstractBufferedImageOp

getRenderingHints

public java.awt.RenderingHints getRenderingHints()
Specified by:
getRenderingHints in interface java.awt.image.BufferedImageOp
Overrides:
getRenderingHints in class AbstractBufferedImageOp

convolve

public static void convolve(java.awt.image.Kernel kernel,
                            int[] inPixels,
                            int[] outPixels,
                            int width,
                            int height,
                            int edgeAction)

convolve

public static void convolve(java.awt.image.Kernel kernel,
                            int[] inPixels,
                            int[] outPixels,
                            int width,
                            int height,
                            boolean alpha,
                            int edgeAction)

convolveH

public static void convolveH(java.awt.image.Kernel kernel,
                             int[] inPixels,
                             int[] outPixels,
                             int width,
                             int height,
                             boolean alpha,
                             int edgeAction)
Convolve with a kernel consisting of one row.


convolveHV

public static void convolveHV(java.awt.image.Kernel kernel,
                              int[] inPixels,
                              int[] outPixels,
                              int width,
                              int height,
                              boolean alpha,
                              int edgeAction)
Convolve with a 2D kernel.


convolveV

public static void convolveV(java.awt.image.Kernel kernel,
                             int[] inPixels,
                             int[] outPixels,
                             int width,
                             int height,
                             boolean alpha,
                             int edgeAction)
Convolve with a kernel consisting of one column.


createCompatibleDestImage

public java.awt.image.BufferedImage createCompatibleDestImage(java.awt.image.BufferedImage src,
                                                              java.awt.image.ColorModel dstCM)
Specified by:
createCompatibleDestImage in interface java.awt.image.BufferedImageOp
Overrides:
createCompatibleDestImage in class AbstractBufferedImageOp

filter

public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage src,
                                           java.awt.image.BufferedImage dst)

hasAlpha

public boolean hasAlpha()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object