Class MorphologyOp
- java.lang.Object
-
- org.apache.batik.ext.awt.image.rendered.MorphologyOp
-
- All Implemented Interfaces:
java.awt.image.BufferedImageOp
,java.awt.image.RasterOp
public class MorphologyOp extends java.lang.Object implements java.awt.image.BufferedImageOp, java.awt.image.RasterOp
This class provides an implementation for the SVG feMorphology filter, as defined in Chapter 15, section 20 of the SVG specification.- Version:
- $Id: MorphologyOp.java 1733416 2016-03-03 07:07:13Z gadams $
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
doDilation
private java.awt.color.ColorSpace
lRGB
private int
radiusX
The radius of the operation on X axisprivate int
radiusY
The radius of the operation on Y axisprivate int
rangeX
private int
rangeY
private java.awt.color.ColorSpace
sRGB
-
Constructor Summary
Constructors Constructor Description MorphologyOp(int radiusX, int radiusY, boolean doDilation)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
checkCompatible(java.awt.image.ColorModel colorModel, java.awt.image.SampleModel sampleModel)
private void
checkCompatible(java.awt.image.SampleModel model)
java.awt.image.BufferedImage
createCompatibleDestImage(java.awt.image.BufferedImage src, java.awt.image.ColorModel destCM)
java.awt.image.WritableRaster
createCompatibleDestRaster(java.awt.image.Raster src)
java.awt.image.BufferedImage
filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dest)
This implementation of filter does the morphology operation on a premultiplied alpha image.java.awt.image.WritableRaster
filter(java.awt.image.Raster src, java.awt.image.WritableRaster dest)
Filters src and writes result into dest.java.awt.geom.Rectangle2D
getBounds2D(java.awt.image.BufferedImage src)
java.awt.geom.Rectangle2D
getBounds2D(java.awt.image.Raster src)
java.awt.geom.Point2D
getPoint2D(java.awt.geom.Point2D srcPt, java.awt.geom.Point2D destPt)
java.awt.RenderingHints
getRenderingHints()
(package private) static boolean
isBetter(int v1, int v2, boolean doDilation)
private boolean
isCompatible(java.awt.image.ColorModel colorModel, java.awt.image.SampleModel sampleModel)
private void
specialProcessColumn(java.awt.image.Raster src, java.awt.image.WritableRaster dest)
private void
specialProcessRow(java.awt.image.Raster src, java.awt.image.WritableRaster dest)
-
-
-
Field Detail
-
radiusX
private int radiusX
The radius of the operation on X axis
-
radiusY
private int radiusY
The radius of the operation on Y axis
-
doDilation
private boolean doDilation
-
rangeX
private final int rangeX
-
rangeY
private final int rangeY
-
sRGB
private final java.awt.color.ColorSpace sRGB
-
lRGB
private final java.awt.color.ColorSpace lRGB
-
-
Constructor Detail
-
MorphologyOp
public MorphologyOp(int radiusX, int radiusY, boolean doDilation)
- Parameters:
radiusX
- defines the radius of filter operation on X-axis. Should not be negative. A value of zero will disable the effect of the operation on X-axis, as described in the SVG specification.radiusY
- defines the radius of filter operation on Y-axis. Should not be negative. A value of zero will disable the effect of the operation on Y-axis, as described in the SVG specification.doDilation
- defines whether to do dilation or erosion operation. Will do dilation when the value is true, erosion when false.
-
-
Method Detail
-
getBounds2D
public java.awt.geom.Rectangle2D getBounds2D(java.awt.image.Raster src)
- Specified by:
getBounds2D
in interfacejava.awt.image.RasterOp
-
getBounds2D
public java.awt.geom.Rectangle2D getBounds2D(java.awt.image.BufferedImage src)
- Specified by:
getBounds2D
in interfacejava.awt.image.BufferedImageOp
-
getPoint2D
public java.awt.geom.Point2D getPoint2D(java.awt.geom.Point2D srcPt, java.awt.geom.Point2D destPt)
- Specified by:
getPoint2D
in interfacejava.awt.image.BufferedImageOp
- Specified by:
getPoint2D
in interfacejava.awt.image.RasterOp
-
checkCompatible
private void checkCompatible(java.awt.image.ColorModel colorModel, java.awt.image.SampleModel sampleModel)
-
isCompatible
private boolean isCompatible(java.awt.image.ColorModel colorModel, java.awt.image.SampleModel sampleModel)
-
checkCompatible
private void checkCompatible(java.awt.image.SampleModel model)
-
getRenderingHints
public java.awt.RenderingHints getRenderingHints()
- Specified by:
getRenderingHints
in interfacejava.awt.image.BufferedImageOp
- Specified by:
getRenderingHints
in interfacejava.awt.image.RasterOp
-
createCompatibleDestRaster
public java.awt.image.WritableRaster createCompatibleDestRaster(java.awt.image.Raster src)
- Specified by:
createCompatibleDestRaster
in interfacejava.awt.image.RasterOp
-
createCompatibleDestImage
public java.awt.image.BufferedImage createCompatibleDestImage(java.awt.image.BufferedImage src, java.awt.image.ColorModel destCM)
- Specified by:
createCompatibleDestImage
in interfacejava.awt.image.BufferedImageOp
-
isBetter
static final boolean isBetter(int v1, int v2, boolean doDilation)
-
specialProcessRow
private void specialProcessRow(java.awt.image.Raster src, java.awt.image.WritableRaster dest)
-
specialProcessColumn
private void specialProcessColumn(java.awt.image.Raster src, java.awt.image.WritableRaster dest)
-
filter
public java.awt.image.WritableRaster filter(java.awt.image.Raster src, java.awt.image.WritableRaster dest)
Filters src and writes result into dest. If dest if null, then a Raster is created. If dest and src refer to the same object, then the source is modified.The filtering kernel(the operation range for each pixel) is a rectangle of width 2*radiusX+1 and height radiusY+1
- Specified by:
filter
in interfacejava.awt.image.RasterOp
- Parameters:
src
- the Raster to be filtereddest
- stores the filtered image. If null, a destination will be created. src and dest can refer to the same Raster, in which situation the src will be modified.
-
filter
public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dest)
This implementation of filter does the morphology operation on a premultiplied alpha image. This tends to muddy the colors. so something that is supposed to be a mostly transparent bright red may well become a muddy opaque red. Where as I think it should become a bright opaque red. Which is the result you would get if you were using unpremult data.- Specified by:
filter
in interfacejava.awt.image.BufferedImageOp
-
-