jaitools.media.jai.kernel
Class KernelFactory

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

public class KernelFactory
extends Object

A factory class with static methods to create a variety of KernelJAI objects with specified geometries

Since:
1.0
Version:
$Id: KernelFactory.java 1383 2011-02-10 11:22:29Z michael.bedward $
Author:
Michael Bedward

Nested Class Summary
static class KernelFactory.ValueType
          Meaning of the kernel values
 
Constructor Summary
KernelFactory()
           
 
Method Summary
static javax.media.jai.KernelJAI createAnnulus(int outerRadius, int innerRadius, KernelFactory.ValueType type, float centreValue)
          Creates a new KernelJAI object with an annular configuration (like a doughnut).
static javax.media.jai.KernelJAI createCircle(int radius)
          Create a new KernelJAI object with a circular configuration.
static javax.media.jai.KernelJAI createCircle(int radius, KernelFactory.ValueType type, float centreValue)
          Creates a new KernelJAI object with a circular configuration.
static javax.media.jai.KernelJAI createFromShape(Shape shape, AffineTransform transform, KernelFactory.ValueType type, int keyX, int keyY, float keyValue)
          Create a new KernelJAI object by rasterizing a shape.
static javax.media.jai.KernelJAI createRectangle(int width, int height)
          Creates a new KernelJAI object with a rectangular configuraton.
static javax.media.jai.KernelJAI createRectangle(int width, int height, KernelFactory.ValueType type, int keyX, int keyY, float keyValue)
          Creates a new KernelJAI object with a rectangular configuration.
 
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 new KernelJAI object with a circular configuration. Kernel elements within the circle will have value 1.0f; those outside will have value 0.0f.

This is equivalent to, but faster than, calling...

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

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

createCircle

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

Parameters:
radius - the radius of the circle expressed in pixels
type - one of KernelFactory.ValueType.BINARY, KernelFactory.ValueType.DISTANCE or KernelFactory.ValueType.INVERSE_DISTANCE
centreValue - the value to assign to the kernel centre (key element)
Returns:
a new instance of KernelJAI

createAnnulus

public static javax.media.jai.KernelJAI createAnnulus(int outerRadius,
                                                      int innerRadius,
                                                      KernelFactory.ValueType type,
                                                      float centreValue)
Creates a new KernelJAI object with an annular configuration (like a doughnut). The kernel width is 2*outerRadius + 1. The kernel's key element is at position x=outerRadius, y=outerRadius

An IllegalArgumentException will be thrown if:

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

Parameters:
outerRadius - the radius of the circle expressed in pixels
innerRadius - the radius of the 'hole' of the annulus
type - one of KernelFactory.ValueType.BINARY, KernelFactory.ValueType.DISTANCE or KernelFactory.ValueType.INVERSE_DISTANCE
centreValue - the value to assign to the kernel centre (key element)
Returns:
a new instance of KernelJAI

createRectangle

public static javax.media.jai.KernelJAI createRectangle(int width,
                                                        int height)
Creates a new KernelJAI object with a rectangular configuraton. An IllegalArgumentException will be thrown if width or height are less than 1.

This is equivalent to calling...

createRectangle(width, height, Kernel.ValueType.BINARY, width/2, height/2, 1.0f)

Parameters:
width - rectangle width
height - rectangle height
Returns:
a new instance of KernelJAI

createRectangle

public static javax.media.jai.KernelJAI createRectangle(int width,
                                                        int height,
                                                        KernelFactory.ValueType type,
                                                        int keyX,
                                                        int keyY,
                                                        float keyValue)
Creates a new KernelJAI object with a rectangular configuration.

An IllegalArgumentException will be thrown if:

Parameters:
width - rectangle width
height - rectangle height
type - one of KernelFactory.ValueType.BINARY, KernelFactory.ValueType.DISTANCE or KernelFactory.ValueType.INVERSE_DISTANCE
keyX - x position of the key element
keyY - y position of the key element (y coords increase downwards)
keyValue - value of the key element
Returns:
a new instance of KernelJAI

createFromShape

public static javax.media.jai.KernelJAI createFromShape(Shape shape,
                                                        AffineTransform transform,
                                                        KernelFactory.ValueType type,
                                                        int keyX,
                                                        int keyY,
                                                        float keyValue)
Create a new KernelJAI object by rasterizing a shape. The shape must be a closed polygon. The rasterizing process checks whether the centre of each pixel is inside the polygon.

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 - one of KernelFactory.ValueType.BINARY, KernelFactory.ValueType.DISTANCE or KernelFactory.ValueType.INVERSE_DISTANCE
keyX - the x coord of the key element
keyY - the y coord of the key element
keyValue - the value of the key element
Returns:
a new instance of KernelJAI


Copyright © 2009-2011. All Rights Reserved.