# Class Kernel

java.lang.Object
java.awt.image.Kernel

All Implemented Interfaces:
  `Cloneable`

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 Also:
  - `ConvolveOp`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Kernel(int width, int height, float[] data)`
  Constructs a `Kernel` object from an array of floats.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `clone()`
  Clones this object.
  `final int`
  `getHeight()`
  Returns the height of this `Kernel`.
  `final float[]`
  `getKernelData(float[] data)`
  Returns the kernel data in row major order.
  `final int`
  `getWidth()`
  Returns the width of this `Kernel`.
  `final int`
  `getXOrigin()`
  Returns the X origin of this `Kernel`.
  `final int`
  `getYOrigin()`
  Returns the Y origin of this `Kernel`.

  ### Methods declared in class Object

  `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `protected void`
  `finalize()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Finalization is deprecated and subject to removal in a future release.
  `final Class<?>`
  `getClass()`
  Returns the runtime class of this `Object`.
  `int`
  `hashCode()`
  Returns a hash code value for this object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `String`
  `toString()`
  Returns a string representation of the object.
  `final void`
  `wait()`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
  `final void`
  `wait(long timeoutMillis)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
  `final void`
  `wait(long timeoutMillis, int nanos)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

- ## Constructor Details

  - ### Kernel

    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.
    Parameters:
      `width` - width of the kernel
      `height` - height of the kernel
      `data` - kernel data in row major order
    Throws:
      `NullPointerException` - if `data` is null
      `IllegalArgumentException` - if `width` or `height` is not positive
      `IllegalArgumentException` - if product of `width` and `height` overflows an int
      `IllegalArgumentException` - if the length of `data` is less than the product of `width` and `height`

- ## Method Details

  - ### getXOrigin

    public final int getXOrigin()
    Returns the X origin of this `Kernel`.
    Returns:
      the X origin.

  - ### getYOrigin

    public final int getYOrigin()
    Returns the Y origin of this `Kernel`.
    Returns:
      the Y origin.

  - ### getWidth

    public final int getWidth()
    Returns the width of this `Kernel`.
    Returns:
      the width of this `Kernel`.

  - ### getHeight

    public final int getHeight()
    Returns the height of this `Kernel`.
    Returns:
      the height of this `Kernel`.

  - ### getKernelData

    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.
    Parameters:
      `data` - if non-null, contains the returned kernel data
    Returns:
      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`

  - ### clone

    public Object clone()
    Clones this object.
    Overrides:
      `clone` in class `Object`
    Returns:
      a clone of this object.
    See Also:
      - `Cloneable`