Package com.jhlabs.image
Class ConvolveFilter
- java.lang.Object
-
- com.jhlabs.image.AbstractBufferedImageOp
-
- com.jhlabs.image.ConvolveFilter
-
- All Implemented Interfaces:
java.awt.image.BufferedImageOp,java.lang.Cloneable
- Direct Known Subclasses:
AverageFilter,BlurFilter,BumpFilter,GaussianFilter,SharpenFilter
public class ConvolveFilter extends AbstractBufferedImageOp
A filter which applies a convolution kernel to an image.
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanalphastatic intCLAMP_EDGESprotected java.awt.image.Kernelkernelstatic intWRAP_EDGESstatic intZERO_EDGES
-
Constructor Summary
Constructors Constructor Description 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidconvolve(java.awt.image.Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction)static voidconvolve(java.awt.image.Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, int edgeAction)static voidconvolveH(java.awt.image.Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction)Convolve with a kernel consisting of one rowstatic voidconvolveHV(java.awt.image.Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction)Convolve with a 2D kernelstatic voidconvolveV(java.awt.image.Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction)Convolve with a kernel consisting of one columnjava.awt.image.BufferedImagecreateCompatibleDestImage(java.awt.image.BufferedImage src, java.awt.image.ColorModel dstCM)java.awt.image.BufferedImagefilter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dst)java.awt.geom.Rectangle2DgetBounds2D(java.awt.image.BufferedImage src)intgetEdgeAction()java.awt.image.KernelgetKernel()java.awt.geom.Point2DgetPoint2D(java.awt.geom.Point2D srcPt, java.awt.geom.Point2D dstPt)java.awt.RenderingHintsgetRenderingHints()booleangetUseAlpha()voidsetEdgeAction(int edgeAction)voidsetKernel(java.awt.image.Kernel kernel)voidsetUseAlpha(boolean useAlpha)java.lang.StringtoString()-
Methods inherited from class com.jhlabs.image.AbstractBufferedImageOp
clone, getRGB, setRGB
-
-
-
-
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 kernelcols- the number of columns in the kernelmatrix- 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:
matrix- an array of 9 floats containing the kernel
-
-
Method Detail
-
setKernel
public void setKernel(java.awt.image.Kernel kernel)
-
getKernel
public java.awt.image.Kernel getKernel()
-
setEdgeAction
public void setEdgeAction(int edgeAction)
-
getEdgeAction
public int getEdgeAction()
-
setUseAlpha
public void setUseAlpha(boolean useAlpha)
-
getUseAlpha
public boolean getUseAlpha()
-
filter
public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dst)
-
createCompatibleDestImage
public java.awt.image.BufferedImage createCompatibleDestImage(java.awt.image.BufferedImage src, java.awt.image.ColorModel dstCM)- Specified by:
createCompatibleDestImagein interfacejava.awt.image.BufferedImageOp- Overrides:
createCompatibleDestImagein classAbstractBufferedImageOp
-
getBounds2D
public java.awt.geom.Rectangle2D getBounds2D(java.awt.image.BufferedImage src)
- Specified by:
getBounds2Din interfacejava.awt.image.BufferedImageOp- Overrides:
getBounds2Din classAbstractBufferedImageOp
-
getPoint2D
public java.awt.geom.Point2D getPoint2D(java.awt.geom.Point2D srcPt, java.awt.geom.Point2D dstPt)- Specified by:
getPoint2Din interfacejava.awt.image.BufferedImageOp- Overrides:
getPoint2Din classAbstractBufferedImageOp
-
getRenderingHints
public java.awt.RenderingHints getRenderingHints()
- Specified by:
getRenderingHintsin interfacejava.awt.image.BufferedImageOp- Overrides:
getRenderingHintsin classAbstractBufferedImageOp
-
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)
-
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
-
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
-
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
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-