Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.pearsoneduc.ip.op
Class ConvolutionOp

    java.lang.Object
      |
      +--com.pearsoneduc.ip.op.StandardGreyOp
            |
            +--com.pearsoneduc.ip.op.NeighbourhoodOp
                  |
                  +--com.pearsoneduc.ip.op.ConvolutionOp

public class ConvolutionOp
extends NeighbourhoodOp

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.

Version:
  1.1 [1999/07/27]
Author:
  Nick Efford

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

### SINGLE_PASS

    public static final int SINGLE_PASS

  Indicates the convolution is to be done in a single pass.

### SEPARABLE

    public static final int SEPARABLE

  Indicates that separable convolution is to be done.

### NO_RESCALING

    public static final int NO_RESCALING

  Indicates that no rescaling of output values should be done.

### RESCALE_MAX_ONLY

    public static final int RESCALE_MAX_ONLY

  Indicates that maximum output value should be scaled to 255.

### RESCALE_MIN_AND_MAX

    public static final int RESCALE_MIN_AND_MAX

  Indicates that range should be scaled to 0-255.

Constructor Detail

### ConvolutionOp

    public ConvolutionOp(java.awt.image.Kernel kernel)

  Constructs a ConvolutionOp for a given kernel. No special measures will be taken at the image borders. Convolution will be performed in a single pass, and no rescaling of output values will take place.
  Parameters:
    `kernel` - convolution kernel

### ConvolutionOp

    public 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.
  Parameters:
    `kernel` - convolution kernel
    `border` - border handling strategy
    `calc` - calculation method
    `rescale` - rescaling strategy

Method Detail

### blur

    public 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. No special measures will taken to deal with image borders.
  Parameters:
    `image` - source image
    `w` - width of neighbourhood
    `h` - height of neighbourhood
  Returns:
    blurred image.

### blur

    public 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.
  Parameters:
    `image` - source image
    `w` - width of neighbourhood
    `h` - height of neighbourhood
    `border` - border handling strategy
  Returns:
    blurred image.

### gaussianBlur

    public static java.awt.image.BufferedImage gaussianBlur(java.awt.image.BufferedImage image,
                                                            float sigma)

  Performs Gaussian blurring of an image using a separable kernel.
  Parameters:
    `image` - source image
    `sigma` - standard deviation of Gaussian
  Returns:
    blurred image.

### gaussianBlur

    public 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.
  Parameters:
    `image` - source image
    `sigma` - standard deviation of Gaussian
    `border` - border handling strategy
  Returns:
    blurred image.

### filter

    public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage src,
                                               java.awt.image.BufferedImage dest)

  Performs convolution on an image.
  Parameters:
    `src` - source image
    `dest` - destination image, or null
  Returns:
    convolved image
  Overrides:
    filter in class StandardGreyOp

### convolve

    public float[] convolve(java.awt.image.BufferedImage image)

  Performs convolution on an image.
  Parameters:
    `image` - source image
  Returns:
    array of convolved data

### separableConvolve

    public float[] separableConvolve(java.awt.image.BufferedImage image)

  Performs separable convolution on an image.
  Parameters:
    `image` - source image
  Returns:
    array of convolved data

### copyBorders

    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.
  Parameters:
    `src` - source raster
    `dest` - destination array

### convertToBytes

    protected void convertToBytes(float[] in,
                                  byte[] out)

  Converts raw convolved values to bytes, rescaling if necessary.
  Parameters:
    `in` - array of raw floating-point values
    `out` - array of bytes

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD