public class ConvolveFilter extends AbstractBufferedImageOp
Modifier and Type | Field and Description |
---|---|
protected boolean |
alpha
Whether to convolve alpha.
|
static int |
CLAMP_EDGES
Clamp pixels off the edge to the nearest edge.
|
protected java.awt.image.Kernel |
kernel
The convolution kernel.
|
protected boolean |
premultiplyAlpha
Whether to promultiply the alpha before convolving.
|
static int |
WRAP_EDGES
Wrap pixels off the edge to the opposite edge.
|
static int |
ZERO_EDGES
Treat pixels off the edge as zero.
|
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
static void |
convolve(java.awt.image.Kernel kernel,
int[] inPixels,
int[] outPixels,
int width,
int height,
boolean alpha,
int edgeAction)
Convolve a block of pixels.
|
static void |
convolve(java.awt.image.Kernel kernel,
int[] inPixels,
int[] outPixels,
int width,
int height,
int edgeAction)
Convolve a block of pixels.
|
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()
Get the action to perfomr for pixels off the image edges.
|
java.awt.image.Kernel |
getKernel()
Get the convolution kernel.
|
java.awt.geom.Point2D |
getPoint2D(java.awt.geom.Point2D srcPt,
java.awt.geom.Point2D dstPt) |
boolean |
getPremultiplyAlpha()
Get whether to premultiply the alpha channel.
|
java.awt.RenderingHints |
getRenderingHints() |
boolean |
getUseAlpha()
Get whether to convolve the alpha channel.
|
void |
setEdgeAction(int edgeAction)
Set the action to perfomr for pixels off the image edges.
|
void |
setKernel(java.awt.image.Kernel kernel)
Set the convolution kernel.
|
void |
setPremultiplyAlpha(boolean premultiplyAlpha)
Set whether to premultiply the alpha channel.
|
void |
setUseAlpha(boolean useAlpha)
Set whether to convolve the alpha channel.
|
java.lang.String |
toString() |
clone, getRGB, setRGB, stringToColor
public static int ZERO_EDGES
public static int CLAMP_EDGES
public static int WRAP_EDGES
protected java.awt.image.Kernel kernel
protected boolean alpha
protected boolean premultiplyAlpha
public ConvolveFilter()
public ConvolveFilter(float[] matrix)
matrix
- an array of 9 floats containing the kernelpublic ConvolveFilter(int rows, int cols, float[] matrix)
rows
- the number of rows in the kernelcols
- the number of columns in the kernelmatrix
- an array of rows*cols floats containing the kernelpublic ConvolveFilter(java.awt.image.Kernel kernel)
kernel
- the convolution kernelpublic void setKernel(java.awt.image.Kernel kernel)
kernel
- the kernelgetKernel()
public java.awt.image.Kernel getKernel()
setKernel(java.awt.image.Kernel)
public void setEdgeAction(int edgeAction)
edgeAction
- the actiongetEdgeAction()
public int getEdgeAction()
setEdgeAction(int)
public void setUseAlpha(boolean useAlpha)
useAlpha
- true to convolve the alphagetUseAlpha()
public boolean getUseAlpha()
setUseAlpha(boolean)
public void setPremultiplyAlpha(boolean premultiplyAlpha)
premultiplyAlpha
- true to premultiply the alphagetPremultiplyAlpha()
public boolean getPremultiplyAlpha()
setPremultiplyAlpha(boolean)
public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dst)
public java.awt.image.BufferedImage createCompatibleDestImage(java.awt.image.BufferedImage src, java.awt.image.ColorModel dstCM)
createCompatibleDestImage
in interface java.awt.image.BufferedImageOp
createCompatibleDestImage
in class AbstractBufferedImageOp
public java.awt.geom.Rectangle2D getBounds2D(java.awt.image.BufferedImage src)
getBounds2D
in interface java.awt.image.BufferedImageOp
getBounds2D
in class AbstractBufferedImageOp
public java.awt.geom.Point2D getPoint2D(java.awt.geom.Point2D srcPt, java.awt.geom.Point2D dstPt)
getPoint2D
in interface java.awt.image.BufferedImageOp
getPoint2D
in class AbstractBufferedImageOp
public java.awt.RenderingHints getRenderingHints()
getRenderingHints
in interface java.awt.image.BufferedImageOp
getRenderingHints
in class AbstractBufferedImageOp
public static void convolve(java.awt.image.Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, int edgeAction)
kernel
- the kernelinPixels
- the input pixelsoutPixels
- the output pixelswidth
- the widthheight
- the heightedgeAction
- what to do at the edgespublic static void convolve(java.awt.image.Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction)
kernel
- the kernelinPixels
- the input pixelsoutPixels
- the output pixelswidth
- the widthheight
- the heightalpha
- include alpha channeledgeAction
- what to do at the edgespublic static void convolveHV(java.awt.image.Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction)
kernel
- the kernelinPixels
- the input pixelsoutPixels
- the output pixelswidth
- the widthheight
- the heightalpha
- include alpha channeledgeAction
- what to do at the edgespublic static void convolveH(java.awt.image.Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction)
kernel
- the kernelinPixels
- the input pixelsoutPixels
- the output pixelswidth
- the widthheight
- the heightalpha
- include alpha channeledgeAction
- what to do at the edgespublic static void convolveV(java.awt.image.Kernel kernel, int[] inPixels, int[] outPixels, int width, int height, boolean alpha, int edgeAction)
kernel
- the kernelinPixels
- the input pixelsoutPixels
- the output pixelswidth
- the widthheight
- the heightalpha
- include alpha channeledgeAction
- what to do at the edgespublic java.lang.String toString()
toString
in class java.lang.Object