java.awt.image
Class ConvolveOp

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.awt.image.ConvolveOp
All Implemented Interfaces:
BufferedImageOp sample code for java.awt.image.BufferedImageOp definition code for java.awt.image.BufferedImageOp , RasterOp sample code for java.awt.image.RasterOp definition code for java.awt.image.RasterOp

public class ConvolveOp
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements BufferedImageOp sample code for java.awt.image.BufferedImageOp definition code for java.awt.image.BufferedImageOp , RasterOp sample code for java.awt.image.RasterOp definition code for java.awt.image.RasterOp

This class implements a convolution from the source to the destination. Convolution using a convolution kernel is a spatial operation that computes the output pixel from an input pixel by multiplying the kernel with the surround of the input pixel. This allows the output pixel to be affected by the immediate neighborhood in a way that can be mathematically specified with a kernel.

This class operates with BufferedImage data in which color components are premultiplied with the alpha component. If the Source BufferedImage has an alpha component, and the color components are not premultiplied with the alpha component, then the data are premultiplied before being convolved. If the Destination has color components which are not premultiplied, then alpha is divided out before storing into the Destination (if alpha is 0, the color components are set to 0). If the Destination has no alpha component, then the resulting alpha is discarded after first dividing it out of the color components.

Rasters are treated as having no alpha channel. If the above treatment of the alpha channel in BufferedImages is not desired, it may be avoided by getting the Raster of a source BufferedImage and using the filter method of this class which works with Rasters.

If a RenderingHints object is specified in the constructor, the color rendering hint and the dithering hint may be used when color conversion is required.

Note that the Source and the Destination may not be the same object.

See Also:
Kernel sample code for java.awt.image.Kernel definition code for java.awt.image.Kernel , RenderingHints.KEY_COLOR_RENDERING sample code for java.awt.RenderingHints.KEY_COLOR_RENDERING definition code for java.awt.RenderingHints.KEY_COLOR_RENDERING , RenderingHints.KEY_DITHERING sample code for java.awt.RenderingHints.KEY_DITHERING definition code for java.awt.RenderingHints.KEY_DITHERING

Field Summary
static int EDGE_NO_OP sample code for java.awt.image.ConvolveOp.EDGE_NO_OP definition code for java.awt.image.ConvolveOp.EDGE_NO_OP
          Pixels at the edge of the source image are copied to the corresponding pixels in the destination without modification.
static int EDGE_ZERO_FILL sample code for java.awt.image.ConvolveOp.EDGE_ZERO_FILL definition code for java.awt.image.ConvolveOp.EDGE_ZERO_FILL
          Pixels at the edge of the destination image are set to zero.
 
Constructor Summary
ConvolveOp sample code for java.awt.image.ConvolveOp.ConvolveOp(java.awt.image.Kernel) definition code for java.awt.image.ConvolveOp.ConvolveOp(java.awt.image.Kernel) (Kernel sample code for java.awt.image.Kernel definition code for java.awt.image.Kernel  kernel)
          Constructs a ConvolveOp given a Kernel.
ConvolveOp sample code for java.awt.image.ConvolveOp.ConvolveOp(java.awt.image.Kernel, int, java.awt.RenderingHints) definition code for java.awt.image.ConvolveOp.ConvolveOp(java.awt.image.Kernel, int, java.awt.RenderingHints) (Kernel sample code for java.awt.image.Kernel definition code for java.awt.image.Kernel  kernel, int edgeCondition, RenderingHints sample code for java.awt.RenderingHints definition code for java.awt.RenderingHints  hints)
          Constructs a ConvolveOp given a Kernel, an edge condition, and a RenderingHints object (which may be null).
 
Method Summary
 BufferedImage sample code for java.awt.image.BufferedImage definition code for java.awt.image.BufferedImage createCompatibleDestImage sample code for java.awt.image.ConvolveOp.createCompatibleDestImage(java.awt.image.BufferedImage, java.awt.image.ColorModel) definition code for java.awt.image.ConvolveOp.createCompatibleDestImage(java.awt.image.BufferedImage, java.awt.image.ColorModel) (BufferedImage sample code for java.awt.image.BufferedImage definition code for java.awt.image.BufferedImage  src, ColorModel sample code for java.awt.image.ColorModel definition code for java.awt.image.ColorModel  destCM)
          Creates a zeroed destination image with the correct size and number of bands.
 WritableRaster sample code for java.awt.image.WritableRaster definition code for java.awt.image.WritableRaster createCompatibleDestRaster sample code for java.awt.image.ConvolveOp.createCompatibleDestRaster(java.awt.image.Raster) definition code for java.awt.image.ConvolveOp.createCompatibleDestRaster(java.awt.image.Raster) (Raster sample code for java.awt.image.Raster definition code for java.awt.image.Raster  src)
          Creates a zeroed destination Raster with the correct size and number of bands, given this source.
 BufferedImage sample code for java.awt.image.BufferedImage definition code for java.awt.image.BufferedImage filter sample code for java.awt.image.ConvolveOp.filter(java.awt.image.BufferedImage, java.awt.image.BufferedImage) definition code for java.awt.image.ConvolveOp.filter(java.awt.image.BufferedImage, java.awt.image.BufferedImage) (BufferedImage sample code for java.awt.image.BufferedImage definition code for java.awt.image.BufferedImage  src, BufferedImage sample code for java.awt.image.BufferedImage definition code for java.awt.image.BufferedImage  dst)
          Performs a convolution on BufferedImages.
 WritableRaster sample code for java.awt.image.WritableRaster definition code for java.awt.image.WritableRaster filter sample code for java.awt.image.ConvolveOp.filter(java.awt.image.Raster, java.awt.image.WritableRaster) definition code for java.awt.image.ConvolveOp.filter(java.awt.image.Raster, java.awt.image.WritableRaster) (Raster sample code for java.awt.image.Raster definition code for java.awt.image.Raster  src, WritableRaster sample code for java.awt.image.WritableRaster definition code for java.awt.image.WritableRaster  dst)
          Performs a convolution on Rasters.
 Rectangle2D sample code for java.awt.geom.Rectangle2D definition code for java.awt.geom.Rectangle2D getBounds2D sample code for java.awt.image.ConvolveOp.getBounds2D(java.awt.image.BufferedImage) definition code for java.awt.image.ConvolveOp.getBounds2D(java.awt.image.BufferedImage) (BufferedImage sample code for java.awt.image.BufferedImage definition code for java.awt.image.BufferedImage  src)
          Returns the bounding box of the filtered destination image.
 Rectangle2D sample code for java.awt.geom.Rectangle2D definition code for java.awt.geom.Rectangle2D getBounds2D sample code for java.awt.image.ConvolveOp.getBounds2D(java.awt.image.Raster) definition code for java.awt.image.ConvolveOp.getBounds2D(java.awt.image.Raster) (Raster sample code for java.awt.image.Raster definition code for java.awt.image.Raster  src)
          Returns the bounding box of the filtered destination Raster.
 int getEdgeCondition sample code for java.awt.image.ConvolveOp.getEdgeCondition() definition code for java.awt.image.ConvolveOp.getEdgeCondition() ()
          Returns the edge condition.
 Kernel sample code for java.awt.image.Kernel definition code for java.awt.image.Kernel getKernel sample code for java.awt.image.ConvolveOp.getKernel() definition code for java.awt.image.ConvolveOp.getKernel() ()
          Returns the Kernel.
 Point2D sample code for java.awt.geom.Point2D definition code for java.awt.geom.Point2D getPoint2D sample code for java.awt.image.ConvolveOp.getPoint2D(java.awt.geom.Point2D, java.awt.geom.Point2D) definition code for java.awt.image.ConvolveOp.getPoint2D(java.awt.geom.Point2D, java.awt.geom.Point2D) (Point2D sample code for java.awt.geom.Point2D definition code for java.awt.geom.Point2D  srcPt, Point2D sample code for java.awt.geom.Point2D definition code for java.awt.geom.Point2D  dstPt)
          Returns the location of the destination point given a point in the source.
 RenderingHints sample code for java.awt.RenderingHints definition code for java.awt.RenderingHints getRenderingHints sample code for java.awt.image.ConvolveOp.getRenderingHints() definition code for java.awt.image.ConvolveOp.getRenderingHints() ()
          Returns the rendering hints for this op.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

EDGE_ZERO_FILL sample code for java.awt.image.ConvolveOp.EDGE_ZERO_FILL

public static final int EDGE_ZERO_FILL
Pixels at the edge of the destination image are set to zero. This is the default.

See Also:
Constant Field Values

EDGE_NO_OP sample code for java.awt.image.ConvolveOp.EDGE_NO_OP

public static final int EDGE_NO_OP
Pixels at the edge of the source image are copied to the corresponding pixels in the destination without modification.

See Also:
Constant Field Values
Constructor Detail

ConvolveOp sample code for java.awt.image.ConvolveOp(java.awt.image.Kernel, int, java.awt.RenderingHints) definition code for java.awt.image.ConvolveOp(java.awt.image.Kernel, int, java.awt.RenderingHints)

public ConvolveOp(Kernel sample code for java.awt.image.Kernel definition code for java.awt.image.Kernel  kernel,
                  int edgeCondition,
                  RenderingHints sample code for java.awt.RenderingHints definition code for java.awt.RenderingHints  hints)
Constructs a ConvolveOp given a Kernel, an edge condition, and a RenderingHints object (which may be null).

Parameters:
kernel - the specified Kernel
edgeCondition - the specified edge condition
hints - the specified RenderingHints object
See Also:
Kernel sample code for java.awt.image.Kernel definition code for java.awt.image.Kernel , EDGE_NO_OP sample code for java.awt.image.ConvolveOp.EDGE_NO_OP definition code for java.awt.image.ConvolveOp.EDGE_NO_OP , EDGE_ZERO_FILL sample code for java.awt.image.ConvolveOp.EDGE_ZERO_FILL definition code for java.awt.image.ConvolveOp.EDGE_ZERO_FILL , RenderingHints sample code for java.awt.RenderingHints definition code for java.awt.RenderingHints

ConvolveOp sample code for java.awt.image.ConvolveOp(java.awt.image.Kernel) definition code for java.awt.image.ConvolveOp(java.awt.image.Kernel)

public ConvolveOp(Kernel sample code for java.awt.image.Kernel definition code for java.awt.image.Kernel  kernel)
Constructs a ConvolveOp given a Kernel. The edge condition will be EDGE_ZERO_FILL.

Parameters:
kernel - the specified Kernel
See Also:
Kernel sample code for java.awt.image.Kernel definition code for java.awt.image.Kernel , EDGE_ZERO_FILL sample code for java.awt.image.ConvolveOp.EDGE_ZERO_FILL definition code for java.awt.image.ConvolveOp.EDGE_ZERO_FILL
Method Detail

getEdgeCondition sample code for java.awt.image.ConvolveOp.getEdgeCondition() definition code for java.awt.image.ConvolveOp.getEdgeCondition()

public int getEdgeCondition()
Returns the edge condition.

Returns:
the edge condition of this ConvolveOp.
See Also:
EDGE_NO_OP sample code for java.awt.image.ConvolveOp.EDGE_NO_OP definition code for java.awt.image.ConvolveOp.EDGE_NO_OP , EDGE_ZERO_FILL sample code for java.awt.image.ConvolveOp.EDGE_ZERO_FILL definition code for java.awt.image.ConvolveOp.EDGE_ZERO_FILL

getKernel sample code for java.awt.image.ConvolveOp.getKernel() definition code for java.awt.image.ConvolveOp.getKernel()

public final Kernel sample code for java.awt.image.Kernel definition code for java.awt.image.Kernel  getKernel()
Returns the Kernel.

Returns:
the Kernel of this ConvolveOp.

filter sample code for java.awt.image.ConvolveOp.filter(java.awt.image.BufferedImage, java.awt.image.BufferedImage) definition code for java.awt.image.ConvolveOp.filter(java.awt.image.BufferedImage, java.awt.image.BufferedImage)

public final BufferedImage sample code for java.awt.image.BufferedImage definition code for java.awt.image.BufferedImage  filter(BufferedImage sample code for java.awt.image.BufferedImage definition code for java.awt.image.BufferedImage  src,
                                  BufferedImage sample code for java.awt.image.BufferedImage definition code for java.awt.image.BufferedImage  dst)
Performs a convolution on BufferedImages. Each component of the source image will be convolved (including the alpha component, if present). If the color model in the source image is not the same as that in the destination image, the pixels will be converted in the destination. If the destination image is null, a BufferedImage will be created with the source ColorModel. The IllegalArgumentException may be thrown if the source is the same as the destination.

Specified by:
filter sample code for java.awt.image.BufferedImageOp.filter(java.awt.image.BufferedImage, java.awt.image.BufferedImage) definition code for java.awt.image.BufferedImageOp.filter(java.awt.image.BufferedImage, java.awt.image.BufferedImage) in interface BufferedImageOp sample code for java.awt.image.BufferedImageOp definition code for java.awt.image.BufferedImageOp
Parameters:
src - the source BufferedImage to filter
dst - the destination BufferedImage for the filtered src
Returns:
the filtered BufferedImage
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if src is null
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if src equals dst
ImagingOpException sample code for java.awt.image.ImagingOpException definition code for java.awt.image.ImagingOpException - if src cannot be filtered

filter sample code for java.awt.image.ConvolveOp.filter(java.awt.image.Raster, java.awt.image.WritableRaster) definition code for java.awt.image.ConvolveOp.filter(java.awt.image.Raster, java.awt.image.WritableRaster)

public final WritableRaster sample code for java.awt.image.WritableRaster definition code for java.awt.image.WritableRaster  filter(Raster sample code for java.awt.image.Raster definition code for java.awt.image.Raster  src,
                                   WritableRaster sample code for java.awt.image.WritableRaster definition code for java.awt.image.WritableRaster  dst)
Performs a convolution on Rasters. Each band of the source Raster will be convolved. The source and destination must have the same number of bands. If the destination Raster is null, a new Raster will be created. The IllegalArgumentException may be thrown if the source is the same as the destination.

Specified by:
filter sample code for java.awt.image.RasterOp.filter(java.awt.image.Raster, java.awt.image.WritableRaster) definition code for java.awt.image.RasterOp.filter(java.awt.image.Raster, java.awt.image.WritableRaster) in interface RasterOp sample code for java.awt.image.RasterOp definition code for java.awt.image.RasterOp
Parameters:
src - the source Raster to filter
dst - the destination WritableRaster for the filtered src
Returns:
the filtered WritableRaster
Throws:
NullPointerException sample code for java.lang.NullPointerException definition code for java.lang.NullPointerException - if src is null
ImagingOpException sample code for java.awt.image.ImagingOpException definition code for java.awt.image.ImagingOpException - if src and dst do not have the same number of bands
ImagingOpException sample code for java.awt.image.ImagingOpException definition code for java.awt.image.ImagingOpException - if src cannot be filtered
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if src equals dst

createCompatibleDestImage sample code for java.awt.image.ConvolveOp.createCompatibleDestImage(java.awt.image.BufferedImage, java.awt.image.ColorModel) definition code for java.awt.image.ConvolveOp.createCompatibleDestImage(java.awt.image.BufferedImage, java.awt.image.ColorModel)

public BufferedImage sample code for java.awt.image.BufferedImage definition code for java.awt.image.BufferedImage  createCompatibleDestImage(BufferedImage sample code for java.awt.image.BufferedImage definition code for java.awt.image.BufferedImage  src,
                                               ColorModel sample code for java.awt.image.ColorModel definition code for java.awt.image.ColorModel  destCM)
Creates a zeroed destination image with the correct size and number of bands. If destCM is null, an appropriate ColorModel will be used.

Specified by:
createCompatibleDestImage sample code for java.awt.image.BufferedImageOp.createCompatibleDestImage(java.awt.image.BufferedImage, java.awt.image.ColorModel) definition code for java.awt.image.BufferedImageOp.createCompatibleDestImage(java.awt.image.BufferedImage, java.awt.image.ColorModel) in interface BufferedImageOp sample code for java.awt.image.BufferedImageOp definition code for java.awt.image.BufferedImageOp
Parameters:
src - Source image for the filter operation.
destCM - ColorModel of the destination. Can be null.
Returns:
a destination BufferedImage with the correct size and number of bands.

createCompatibleDestRaster sample code for java.awt.image.ConvolveOp.createCompatibleDestRaster(java.awt.image.Raster) definition code for java.awt.image.ConvolveOp.createCompatibleDestRaster(java.awt.image.Raster)

public WritableRaster sample code for java.awt.image.WritableRaster definition code for java.awt.image.WritableRaster  createCompatibleDestRaster(Raster sample code for java.awt.image.Raster definition code for java.awt.image.Raster  src)
Creates a zeroed destination Raster with the correct size and number of bands, given this source.

Specified by:
createCompatibleDestRaster sample code for java.awt.image.RasterOp.createCompatibleDestRaster(java.awt.image.Raster) definition code for java.awt.image.RasterOp.createCompatibleDestRaster(java.awt.image.Raster) in interface RasterOp sample code for java.awt.image.RasterOp definition code for java.awt.image.RasterOp
Parameters:
src - the source Raster
Returns:
a WritableRaster that is compatible with src

getBounds2D sample code for java.awt.image.ConvolveOp.getBounds2D(java.awt.image.BufferedImage) definition code for java.awt.image.ConvolveOp.getBounds2D(java.awt.image.BufferedImage)

public final Rectangle2D sample code for java.awt.geom.Rectangle2D definition code for java.awt.geom.Rectangle2D  getBounds2D(BufferedImage sample code for java.awt.image.BufferedImage definition code for java.awt.image.BufferedImage  src)
Returns the bounding box of the filtered destination image. Since this is not a geometric operation, the bounding box does not change.

Specified by:
getBounds2D sample code for java.awt.image.BufferedImageOp.getBounds2D(java.awt.image.BufferedImage) definition code for java.awt.image.BufferedImageOp.getBounds2D(java.awt.image.BufferedImage) in interface BufferedImageOp sample code for java.awt.image.BufferedImageOp definition code for java.awt.image.BufferedImageOp
Parameters:
src - The BufferedImage to be filtered
Returns:
The Rectangle2D representing the destination image's bounding box.

getBounds2D sample code for java.awt.image.ConvolveOp.getBounds2D(java.awt.image.Raster) definition code for java.awt.image.ConvolveOp.getBounds2D(java.awt.image.Raster)

public final Rectangle2D sample code for java.awt.geom.Rectangle2D definition code for java.awt.geom.Rectangle2D  getBounds2D(Raster sample code for java.awt.image.Raster definition code for java.awt.image.Raster  src)
Returns the bounding box of the filtered destination Raster. Since this is not a geometric operation, the bounding box does not change.

Specified by:
getBounds2D sample code for java.awt.image.RasterOp.getBounds2D(java.awt.image.Raster) definition code for java.awt.image.RasterOp.getBounds2D(java.awt.image.Raster) in interface RasterOp sample code for java.awt.image.RasterOp definition code for java.awt.image.RasterOp
Parameters:
src - the source Raster
Returns:
a Rectangle2D that is the bounding box of the Raster resulting from the filtering operation.

getPoint2D sample code for java.awt.image.ConvolveOp.getPoint2D(java.awt.geom.Point2D, java.awt.geom.Point2D) definition code for java.awt.image.ConvolveOp.getPoint2D(java.awt.geom.Point2D, java.awt.geom.Point2D)

public final Point2D sample code for java.awt.geom.Point2D definition code for java.awt.geom.Point2D  getPoint2D(Point2D sample code for java.awt.geom.Point2D definition code for java.awt.geom.Point2D  srcPt,
                                Point2D sample code for java.awt.geom.Point2D definition code for java.awt.geom.Point2D  dstPt)
Returns the location of the destination point given a point in the source. If dstPt is non-null, it will be used to hold the return value. Since this is not a geometric operation, the srcPt will equal the dstPt.

Specified by:
getPoint2D sample code for java.awt.image.BufferedImageOp.getPoint2D(java.awt.geom.Point2D, java.awt.geom.Point2D) definition code for java.awt.image.BufferedImageOp.getPoint2D(java.awt.geom.Point2D, java.awt.geom.Point2D) in interface BufferedImageOp sample code for java.awt.image.BufferedImageOp definition code for java.awt.image.BufferedImageOp
Specified by:
getPoint2D sample code for java.awt.image.RasterOp.getPoint2D(java.awt.geom.Point2D, java.awt.geom.Point2D) definition code for java.awt.image.RasterOp.getPoint2D(java.awt.geom.Point2D, java.awt.geom.Point2D) in interface RasterOp sample code for java.awt.image.RasterOp definition code for java.awt.image.RasterOp
Parameters:
srcPt - the Point2D that represents the point in the source image
dstPt - The Point2D in which to store the result
Returns:
The Point2D in the destination image that corresponds to the specified point in the source image.

getRenderingHints sample code for java.awt.image.ConvolveOp.getRenderingHints() definition code for java.awt.image.ConvolveOp.getRenderingHints()

public final RenderingHints sample code for java.awt.RenderingHints definition code for java.awt.RenderingHints  getRenderingHints()
Returns the rendering hints for this op.

Specified by:
getRenderingHints sample code for java.awt.image.BufferedImageOp.getRenderingHints() definition code for java.awt.image.BufferedImageOp.getRenderingHints() in interface BufferedImageOp sample code for java.awt.image.BufferedImageOp definition code for java.awt.image.BufferedImageOp
Specified by:
getRenderingHints sample code for java.awt.image.RasterOp.getRenderingHints() definition code for java.awt.image.RasterOp.getRenderingHints() in interface RasterOp sample code for java.awt.image.RasterOp definition code for java.awt.image.RasterOp
Returns:
The RenderingHints object for this BufferedImageOp