org.jaitools.media.jai.kernel
Class KernelFactory

java.lang.Object
  extended by org.jaitools.media.jai.kernel.KernelFactory

public class KernelFactory
extends Object

Provides static methods to create a variety of raster kernels (KernelJAI objects).

Since:
1.0
Version:
$Id$
Author:
Michael Bedward

Nested Class Summary
static class KernelFactory.ValueType
          Constants specifying how kernel element values are calculated.
 
Constructor Summary
KernelFactory()
           
 
Method Summary
static javax.media.jai.KernelJAI createAnnulus(int outerRadius, int innerRadius, KernelFactory.ValueType type)
          Creates an annular kernel (a doughnut).
static javax.media.jai.KernelJAI createAnnulus(int outerRadius, int innerRadius, KernelFactory.ValueType type, float centreValue)
          Deprecated. Please use #createAnnulua(int, int, ValueType) instead and set the centre element value on the returned kernel if that is required.
static javax.media.jai.KernelJAI createCircle(int radius)
          Create a circular kernel where all elements within the circle have value 1.0 while those outside have value 0.0.
static javax.media.jai.KernelJAI createCircle(int radius, KernelFactory.ValueType type)
          Creates a circular kernel with width 2*radius + 1.
static javax.media.jai.KernelJAI createCircle(int radius, KernelFactory.ValueType type, float centreValue)
          Deprecated. Please use createCircle(int, ValueType) instead and set the centre element value on the returned kernel if that is required.
static javax.media.jai.KernelJAI createConstantAnnulus(int outerRadius, int innerRadius, float value)
          Creates an annular kernel (a doughnut) where elements inside the annulus have a constant value while those outside are set to 0.
static javax.media.jai.KernelJAI createConstantCircle(int radius, float value)
          Create a circular kernel where all elements within the circle have a constant value while those outside have value 0.0.
static javax.media.jai.KernelJAI createConstantRectangle(int width, int height, float value)
          Creates a rectangular kernel where all elements have the same value.
static javax.media.jai.KernelJAI createConstantRectangle(int width, int height, int keyX, int keyY, float value)
          Creates a rectangular kernel where all elements have the same value.
static javax.media.jai.KernelJAI createFromShape(Shape shape, AffineTransform transform, KernelFactory.ValueType type, int keyX, int keyY, float keyValue)
          Create a kernel by rasterizing a shape.
static javax.media.jai.KernelJAI createRectangle(int width, int height)
          Creates a rectangular kernel where all elements have value 1.0.
static javax.media.jai.KernelJAI createRectangle(int width, int height, KernelFactory.ValueType type, int keyX, int keyY)
          Creates a rectangular kernel.
static javax.media.jai.KernelJAI createRectangle(int width, int height, KernelFactory.ValueType type, int keyX, int keyY, float keyValue)
          Deprecated. Please use createRectangle(int, int, ValueType, int, int) instead and set the centre element value on the returned kernel if that is required.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KernelFactory

public KernelFactory()
Method Detail

createCircle

public static javax.media.jai.KernelJAI createCircle(int radius)
Create a circular kernel where all elements within the circle have value 1.0 while those outside have value 0.0. Kernel width is 2*radius + 1. The key element is at position x=radius, y=radius.

This is equivalent to:


     createCircle(radius, Kernel.ValueType.BINARY, 1.0f)
 

Parameters:
radius - radius of the circle
Returns:
a new KernelJAI object

createConstantCircle

public static javax.media.jai.KernelJAI createConstantCircle(int radius,
                                                             float value)
Create a circular kernel where all elements within the circle have a constant value while those outside have value 0.0. Kernel width is 2*radius + 1. The key element is at position x=radius, y=radius.

Parameters:
radius - radius of the circle
value - constant value
Returns:
a new KernelJAI object

createCircle

public static javax.media.jai.KernelJAI createCircle(int radius,
                                                     KernelFactory.ValueType type,
                                                     float centreValue)
Deprecated. Please use createCircle(int, ValueType) instead and set the centre element value on the returned kernel if that is required.

Creates a circular kernel with width 2*radius + 1. The key element is at position x=radius, y=radius.

Parameters:
radius - the radius of the circle expressed in pixels
type - a KernelFactory.ValueType constant
centreValue - the value to assign to the kernel centre (key element)
Returns:
a new KernelJAI object

createCircle

public static javax.media.jai.KernelJAI createCircle(int radius,
                                                     KernelFactory.ValueType type)
Creates a circular kernel with width 2*radius + 1. The key element is at position x=radius, y=radius.

If type is KernelFactory.ValueType.INVERSE_DISTANCE the kernel's key element will be set to 1.0f.

Parameters:
radius - the radius of the circle expressed in pixels
type - a KernelFactory.ValueType constant
Returns:
a new KernelJAI object

createAnnulus

public static javax.media.jai.KernelJAI createAnnulus(int outerRadius,
                                                      int innerRadius,
                                                      KernelFactory.ValueType type,
                                                      float centreValue)
Deprecated. Please use #createAnnulua(int, int, ValueType) instead and set the centre element value on the returned kernel if that is required.

Creates an annular kernel (a doughnut). The kernel width is 2*outerRadius + 1. The kernel's key element is at position x=outerRadius, y=outerRadius.

Calling this method with innerRadius == 0 is equivalent to calling createCircle(int)

Parameters:
outerRadius - the radius of the annulus
innerRadius - the radius of the 'hole'
type - a KernelFactory.ValueType constant
centreValue - the value to assign to the kernel centre (key element)
Returns:
a new KernelJAI object
Throws:
IllegalArgumentException - if outerRadius <= 0 or innerRadius >= outerRadius

createConstantAnnulus

public static javax.media.jai.KernelJAI createConstantAnnulus(int outerRadius,
                                                              int innerRadius,
                                                              float value)
Creates an annular kernel (a doughnut) where elements inside the annulus have a constant value while those outside are set to 0.

The kernel width is 2*outerRadius + 1. The kernel's key element is at position x=outerRadius, y=outerRadius.

Parameters:
outerRadius - the outer radius of the annulus
innerRadius - the radius of the 'hole'
value - element value
Returns:
a new KernelJAI object
Throws:
IllegalArgumentException - if outerRadius <= 0 or innerRadius >= outerRadius

createAnnulus

public static javax.media.jai.KernelJAI createAnnulus(int outerRadius,
                                                      int innerRadius,
                                                      KernelFactory.ValueType type)
Creates an annular kernel (a doughnut). If innerRadius is 0 the returned kernel will be identical to that from createCircle(outerRadius, type).

The kernel width is 2*outerRadius + 1. The kernel's key element is at position x=outerRadius, y=outerRadius.

Parameters:
outerRadius - the outer radius of the annulus
innerRadius - the radius of the 'hole'
type - a KernelFactory.ValueType constant
Returns:
a new KernelJAI object
Throws:
IllegalArgumentException - if outerRadius <= 0 or innerRadius >= outerRadius

createRectangle

public static javax.media.jai.KernelJAI createRectangle(int width,
                                                        int height)
Creates a rectangular kernel where all elements have value 1.0. The key element will be at (width/2, height/2).

Parameters:
width - rectangle width
height - rectangle height
Returns:
a new KernelJAI object
Throws:
IllegalArgumentException - if either width or height are less than 1

createConstantRectangle

public static javax.media.jai.KernelJAI createConstantRectangle(int width,
                                                                int height,
                                                                float value)
Creates a rectangular kernel where all elements have the same value. The key element will be at (width/2, height/2).

Parameters:
width - rectangle width
height - rectangle height
value - element value
Returns:
a new KernelJAI object
Throws:
IllegalArgumentException - if either width or height are less than 1

createConstantRectangle

public static javax.media.jai.KernelJAI createConstantRectangle(int width,
                                                                int height,
                                                                int keyX,
                                                                int keyY,
                                                                float value)
Creates a rectangular kernel where all elements have the same value.

Parameters:
width - rectangle width
height - rectangle height
value - element value
keyX - key element X ordinate
keyY - key element Y ordinate
Returns:
a new KernelJAI object
Throws:
IllegalArgumentException - if either width or height are less than 1 or if the key element location is outside the rectangle

createRectangle

public static javax.media.jai.KernelJAI createRectangle(int width,
                                                        int height,
                                                        KernelFactory.ValueType type,
                                                        int keyX,
                                                        int keyY,
                                                        float keyValue)
Deprecated. Please use createRectangle(int, int, ValueType, int, int) instead and set the centre element value on the returned kernel if that is required.

Creates a rectangular kernel. If the element value type is one that involves proportional distance, such as KernelFactory.ValueType.COSINE or KernelFactory.ValueType.EPANECHNIKOV, this is calculated as the proportion of the maximum distance from the key element to a kernel edge element.

Parameters:
width - rectangle width
height - rectangle height
type - a KernelFactory.ValueType constant
keyX - X ordinate of the key element
keyY - Y ordinate of the key element (0 is top)
keyValue - value of the key element
Returns:
a new KernelJAI object
Throws:
IllegalArgumentException - if either width or height are less than 1; or if keyX is not in the interval [0,width); or if keyY is not in the interval [0,height);

createRectangle

public static javax.media.jai.KernelJAI createRectangle(int width,
                                                        int height,
                                                        KernelFactory.ValueType type,
                                                        int keyX,
                                                        int keyY)
Creates a rectangular kernel. If the element value type is one that involves proportional distance, such as KernelFactory.ValueType.COSINE or KernelFactory.ValueType.EPANECHNIKOV, this is calculated as the proportion of the maximum distance from the key element to a kernel edge element.

Parameters:
width - rectangle width
height - rectangle height
type - a KernelFactory.ValueType constant
keyX - X ordinate of the key element
keyY - Y ordinate of the key element (0 is top)
Returns:
a new KernelJAI object
Throws:
IllegalArgumentException - if either width or height are less than 1; or if keyX is not in the interval [0,width); or if keyY is not in the interval [0,height);

createFromShape

public static javax.media.jai.KernelJAI createFromShape(Shape shape,
                                                        AffineTransform transform,
                                                        KernelFactory.ValueType type,
                                                        int keyX,
                                                        int keyY,
                                                        float keyValue)
Create a kernel by rasterizing a shape. The shape must be a closed polygon. Kernel element centre coordinates are used to test whether elements are inside the shape.

This method can cope with arbitrary shape bounds, ie. there is no need to set the bounding rectangle to have origin x=0, y=0. The values of keyX and keyY, which specify the position of the kernel's key element, must be within the bounds of the shape as passed to this method, but do not need to be inside the shape itself.

Parameters:
shape - an object representing a closed polygon
transform - an optional AffineTransform to relate shape coordinates to kernel element coordinates. May be null. This is useful to scale and/or rotate the shape.
type - a KernelFactory.ValueType constant
keyX - X ordinate of the key element
keyY - Y ordinate of the key element
keyValue - the value of the key element
Returns:
a new instance of KernelJAI


Copyright © 2009-2013. All Rights Reserved.