FileDocCategorySizeDatePackage
Kernel.javaAPI DocJava SE 5 API4459Fri Aug 26 14:56:54 BST 2005java.awt.image

Kernel

public class Kernel extends Object implements Cloneable
The Kernel class defines a matrix that describes how a specified pixel and its surrounding pixels affect the value computed for the pixel's position in the output image of a filtering operation. The X origin and Y origin indicate the kernel matrix element that corresponds to the pixel position for which an output value is being computed.
see
ConvolveOp
version
10 Feb 1997

Fields Summary
private int
width
private int
height
private int
xOrigin
private int
yOrigin
private float[]
data
Constructors Summary
public Kernel(int width, int height, float[] data)
Constructs a Kernel object from an array of floats. The first width*height elements of the data array are copied. If the length of the data array is less than width*height, an IllegalArgumentException is thrown. The X origin is (width-1)/2 and the Y origin is (height-1)/2.

param
width width of the kernel
param
height height of the kernel
param
data kernel data in row major order
throws
IllegalArgumentException if the length of data is less than the product of width and height

        ColorModel.loadLibraries();
        initIDs();
    
        this.width  = width;
        this.height = height;
        this.xOrigin  = (width-1)>>1;
        this.yOrigin  = (height-1)>>1;
        int len = width*height;
        if (data.length < len) {
            throw new IllegalArgumentException("Data array too small "+
                                               "(is "+data.length+
                                               " and should be "+len);
        }
        this.data = new float[len];
        System.arraycopy(data, 0, this.data, 0, len);

    
Methods Summary
public java.lang.Objectclone()
Clones this object.

return
a clone of this object.

	try {
	    return super.clone();
	} catch (CloneNotSupportedException e) {
	    // this shouldn't happen, since we are Cloneable
	    throw new InternalError();
	}
    
public final intgetHeight()
Returns the height of this Kernel.

return
the height of this Kernel.

        return height;
    
public final float[]getKernelData(float[] data)
Returns the kernel data in row major order. The data array is returned. If data is null, a new array is allocated.

param
data if non-null, contains the returned kernel data
return
the data array containing the kernel data in row major order or, if data is null, a newly allocated array containing the kernel data in row major order
throws
IllegalArgumentException if data is less than the size of this Kernel

        if (data == null) {
            data = new float[this.data.length];
        }
        else if (data.length < this.data.length) {
            throw new IllegalArgumentException("Data array too small "+
                                               "(should be "+this.data.length+
                                               " but is "+
                                               data.length+" )");
        }
        System.arraycopy(this.data, 0, data, 0, this.data.length);

        return data;
    
public final intgetWidth()
Returns the width of this Kernel.

return
the width of this Kernel.

        return width;
    
public final intgetXOrigin()
Returns the X origin of this Kernel.

return
the X origin.

        return xOrigin;
    
public final intgetYOrigin()
Returns the Y origin of this Kernel.

return
the Y origin.

        return yOrigin;
    
private static native voidinitIDs()