Class KernelFactory
KernelImageN objects).- Since:
- 1.0
- Author:
- Michael Bedward
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumConstants specifying how kernel element values are calculated. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic KernelImageNcreateAnnulus(int outerRadius, int innerRadius, KernelFactory.ValueType type) Creates an annular kernel (a doughnut).static KernelImageNcreateAnnulus(int outerRadius, int innerRadius, KernelFactory.ValueType type, float centreValue) Deprecated.static KernelImageNcreateCircle(int radius) Create a circular kernel where all elements within the circle have value 1.0 while those outside have value 0.0.static KernelImageNcreateCircle(int radius, KernelFactory.ValueType type) Creates a circular kernel with width2*radius + 1.static KernelImageNcreateCircle(int radius, KernelFactory.ValueType type, float centreValue) Deprecated.Please usecreateCircle(int, ValueType)instead and set the centre element value on the returned kernel if that is required.static KernelImageNcreateConstantAnnulus(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 KernelImageNcreateConstantCircle(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 KernelImageNcreateConstantRectangle(int width, int height, float value) Creates a rectangular kernel where all elements have the same value.static KernelImageNcreateConstantRectangle(int width, int height, int keyX, int keyY, float value) Creates a rectangular kernel where all elements have the same value.static KernelImageNcreateFromShape(Shape shape, AffineTransform transform, KernelFactory.ValueType type, int keyX, int keyY, float keyValue) Create a kernel by rasterizing a shape.static KernelImageNcreateRectangle(int width, int height) Creates a rectangular kernel where all elements have value 1.0.static KernelImageNcreateRectangle(int width, int height, KernelFactory.ValueType type, int keyX, int keyY) Creates a rectangular kernel.static KernelImageNcreateRectangle(int width, int height, KernelFactory.ValueType type, int keyX, int keyY, float keyValue) Deprecated.Please usecreateRectangle(int, int, ValueType, int, int)instead and set the centre element value on the returned kernel if that is required.
-
Constructor Details
-
KernelFactory
public KernelFactory()
-
-
Method Details
-
createCircle
public static KernelImageN 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 is2*radius + 1. The key element is at positionx=radius, y=radius.This is equivalent to:
createCircle(radius, Kernel.ValueType.BINARY, 1.0f)- Parameters:
radius- radius of the circle- Returns:
- a new
KernelImageNobject
-
createConstantCircle
public static KernelImageN 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 is2*radius + 1. The key element is at positionx=radius, y=radius.- Parameters:
radius- radius of the circlevalue- constant value- Returns:
- a new
KernelImageNobject
-
createCircle
public static KernelImageN createCircle(int radius, KernelFactory.ValueType type, float centreValue) Deprecated.Please usecreateCircle(int, ValueType)instead and set the centre element value on the returned kernel if that is required.Creates a circular kernel with width2*radius + 1. The key element is at positionx=radius, y=radius.- Parameters:
radius- the radius of the circle expressed in pixelstype- aKernelFactory.ValueTypeconstantcentreValue- the value to assign to the kernel centre (key element)- Returns:
- a new
KernelImageNobject
-
createCircle
Creates a circular kernel with width2*radius + 1. The key element is at positionx=radius, y=radius.If
typeisKernelFactory.ValueType.INVERSE_DISTANCEthe kernel's key element will be set to 1.0f.- Parameters:
radius- the radius of the circle expressed in pixelstype- aKernelFactory.ValueTypeconstant- Returns:
- a new
KernelImageNobject
-
createAnnulus
public static KernelImageN createAnnulus(int outerRadius, int innerRadius, KernelFactory.ValueType type, float centreValue) Deprecated.Please usecreateAnnulus(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 is2*outerRadius + 1. The kernel's key element is at positionx=outerRadius, y=outerRadius.Calling this method with
innerRadius == 0is equivalent to callingcreateCircle(int)- Parameters:
outerRadius- the radius of the annulusinnerRadius- the radius of the 'hole'type- aKernelFactory.ValueTypeconstantcentreValue- the value to assign to the kernel centre (key element)- Returns:
- a new
KernelImageNobject - Throws:
IllegalArgumentException- ifouterRadius <= 0orinnerRadius >= outerRadius
-
createConstantAnnulus
public static KernelImageN 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 positionx=outerRadius, y=outerRadius.- Parameters:
outerRadius- the outer radius of the annulusinnerRadius- the radius of the 'hole'value- element value- Returns:
- a new
KernelImageNobject - Throws:
IllegalArgumentException- ifouterRadius <= 0orinnerRadius >= outerRadius
-
createAnnulus
public static KernelImageN createAnnulus(int outerRadius, int innerRadius, KernelFactory.ValueType type) Creates an annular kernel (a doughnut). IfinnerRadiusis 0 the returned kernel will be identical to that fromcreateCircle(outerRadius, type).The kernel width is
2*outerRadius + 1. The kernel's key element is at positionx=outerRadius, y=outerRadius.- Parameters:
outerRadius- the outer radius of the annulusinnerRadius- the radius of the 'hole'type- aKernelFactory.ValueTypeconstant- Returns:
- a new
KernelImageNobject - Throws:
IllegalArgumentException- ifouterRadius <= 0orinnerRadius >= outerRadius
-
createRectangle
public static KernelImageN 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 widthheight- rectangle height- Returns:
- a new
KernelImageNobject - Throws:
IllegalArgumentException- if eitherwidthorheightare less than 1
-
createConstantRectangle
public static KernelImageN 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 widthheight- rectangle heightvalue- element value- Returns:
- a new
KernelImageNobject - Throws:
IllegalArgumentException- if eitherwidthorheightare less than 1
-
createConstantRectangle
public static KernelImageN 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 widthheight- rectangle heightvalue- element valuekeyX- key element X ordinatekeyY- key element Y ordinate- Returns:
- a new
KernelImageNobject - Throws:
IllegalArgumentException- if eitherwidthorheightare less than 1 or if the key element location is outside the rectangle
-
createRectangle
public static KernelImageN createRectangle(int width, int height, KernelFactory.ValueType type, int keyX, int keyY, float keyValue) Deprecated.Please usecreateRectangle(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 asKernelFactory.ValueType.COSINEorKernelFactory.ValueType.EPANECHNIKOV, this is calculated as the proportion of the maximum distance from the key element to a kernel edge element.- Parameters:
width- rectangle widthheight- rectangle heighttype- aKernelFactory.ValueTypeconstantkeyX- X ordinate of the key elementkeyY- Y ordinate of the key element (0 is top)keyValue- value of the key element- Returns:
- a new
KernelImageNobject - Throws:
IllegalArgumentException- if eitherwidthorheightare less than 1; or ifkeyXis not in the interval[0,width); or ifkeyYis not in the interval[0,height);
-
createRectangle
public static KernelImageN 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 asKernelFactory.ValueType.COSINEorKernelFactory.ValueType.EPANECHNIKOV, this is calculated as the proportion of the maximum distance from the key element to a kernel edge element.- Parameters:
width- rectangle widthheight- rectangle heighttype- aKernelFactory.ValueTypeconstantkeyX- X ordinate of the key elementkeyY- Y ordinate of the key element (0 is top)- Returns:
- a new
KernelImageNobject - Throws:
IllegalArgumentException- if eitherwidthorheightare less than 1; or ifkeyXis not in the interval[0,width); or ifkeyYis not in the interval[0,height);
-
createFromShape
public static KernelImageN 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 polygontransform- 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- aKernelFactory.ValueTypeconstantkeyX- X ordinate of the key elementkeyY- Y ordinate of the key elementkeyValue- the value of the key element- Returns:
- a new instance of KernelImageN
-
createAnnulus(int, int, ValueType)instead and set the centre element value on the returned kernel if that is required.