|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.pearsoneduc.ip.op.StandardGreyOp | +--com.pearsoneduc.ip.op.NeighbourhoodOp | +--com.pearsoneduc.ip.op.ConvolutionOp
A class to perform convolution. ConvolutionOp is slower than ConvolveOp, but it is more flexible. Four different strategies for dealing with the image borders are supported (compared with two for ConvolveOp). Also, ConvolutionOp supports separable convolution, whereby a 1D kernel is applied along the rows of an image to generate an intermediate result, and then to the columns of this intermediate result to produce the final image. Finally, ConvolutionOp handles convolution with kernels containing negative coefficients properly, by convolving to temporary storage and then rescaling the stored data to lie within a 0-255 range.
ConvolutionOp also hosts a small number of static methods that act as shortcuts for common operations such as image blurring. These static methods delegate responsibility for convolution to ConvolutionOp or to ConvolveOp, as appropriate - ensuring that convolution is done in the most efficient manner possible.
Field Summary | |
static int |
NO_RESCALING
Indicates that no rescaling of output values should be done. |
static int |
RESCALE_MAX_ONLY
Indicates that maximum output value should be scaled to 255. |
static int |
RESCALE_MIN_AND_MAX
Indicates that range should be scaled to 0-255. |
static int |
SEPARABLE
Indicates that separable convolution is to be done. |
static int |
SINGLE_PASS
Indicates the convolution is to be done in a single pass. |
Fields inherited from class com.pearsoneduc.ip.op.NeighbourhoodOp |
borderStrategy,
CIRCULAR_INDEXING,
COPY_BORDER_PIXELS,
height,
NO_BORDER_OP,
REFLECTED_INDEXING,
size,
width |
Constructor Summary | |
ConvolutionOp(java.awt.image.Kernel kernel)
Constructs a ConvolutionOp for a given kernel. |
|
ConvolutionOp(java.awt.image.Kernel kernel,
int border,
int calc,
int rescale)
Constructs a ConvolutionOp with a specified kernel, border handling strategy, calculation method and rescaling strategy. |
Method Summary | |
static java.awt.image.BufferedImage |
blur(java.awt.image.BufferedImage image,
int w,
int h)
Computes a uniform blur of an image using the specified neighbourhood dimensions. |
static java.awt.image.BufferedImage |
blur(java.awt.image.BufferedImage image,
int w,
int h,
int border)
Computes a uniform blur of an image using the specified neighbourhood and border handling strategy. |
protected void |
convertToBytes(float[] in,
byte[] out)
Converts raw convolved values to bytes, rescaling if necessary. |
float[] |
convolve(java.awt.image.BufferedImage image)
Performs convolution on an image. |
protected void |
copyBorders(java.awt.image.Raster src,
float[] dest)
Copies border pixels that cannot be convolved by normal means from a raster to an array. |
java.awt.image.BufferedImage |
filter(java.awt.image.BufferedImage src,
java.awt.image.BufferedImage dest)
Performs convolution on an image. |
static java.awt.image.BufferedImage |
gaussianBlur(java.awt.image.BufferedImage image,
float sigma)
Performs Gaussian blurring of an image using a separable kernel. |
static java.awt.image.BufferedImage |
gaussianBlur(java.awt.image.BufferedImage image,
float sigma,
int borderStrategy)
Performs Gaussian blurring of an image using a separable kernel and the specified border strategy. |
float[] |
separableConvolve(java.awt.image.BufferedImage image)
Performs separable convolution on an image. |
Methods inherited from class com.pearsoneduc.ip.op.NeighbourhoodOp |
circIndex,
copyBorders,
getBorderStrategy,
getHeight,
getNumPixels,
getWidth,
refIndex |
Methods inherited from class com.pearsoneduc.ip.op.StandardGreyOp |
checkImage,
createCompatibleDestImage,
getBounds2D,
getPoint2D,
getRenderingHints |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final int SINGLE_PASS
public static final int SEPARABLE
public static final int NO_RESCALING
public static final int RESCALE_MAX_ONLY
public static final int RESCALE_MIN_AND_MAX
Constructor Detail |
public ConvolutionOp(java.awt.image.Kernel kernel)
kernel
- convolution kernelpublic ConvolutionOp(java.awt.image.Kernel kernel, int border, int calc, int rescale)
kernel
- convolution kernelborder
- border handling strategycalc
- calculation methodrescale
- rescaling strategyMethod Detail |
public static java.awt.image.BufferedImage blur(java.awt.image.BufferedImage image, int w, int h)
image
- source imagew
- width of neighbourhoodh
- height of neighbourhoodpublic static java.awt.image.BufferedImage blur(java.awt.image.BufferedImage image, int w, int h, int border)
image
- source imagew
- width of neighbourhoodh
- height of neighbourhoodborder
- border handling strategypublic static java.awt.image.BufferedImage gaussianBlur(java.awt.image.BufferedImage image, float sigma)
image
- source imagesigma
- standard deviation of Gaussianpublic static java.awt.image.BufferedImage gaussianBlur(java.awt.image.BufferedImage image, float sigma, int borderStrategy)
image
- source imagesigma
- standard deviation of Gaussianborder
- border handling strategypublic java.awt.image.BufferedImage filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dest)
src
- source imagedest
- destination image, or nullpublic float[] convolve(java.awt.image.BufferedImage image)
image
- source imagepublic float[] separableConvolve(java.awt.image.BufferedImage image)
image
- source imageprotected void copyBorders(java.awt.image.Raster src, float[] dest)
src
- source rasterdest
- destination arrayprotected void convertToBytes(float[] in, byte[] out)
in
- array of raw floating-point valuesout
- array of bytes
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |