Package org.esa.snap.core.datamodel
Class Kernel
- java.lang.Object
-
- org.esa.snap.core.datamodel.Kernel
-
- All Implemented Interfaces:
Cloneable
public class Kernel extends Object implements Cloneable
TheKernelclass 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 filter matrix element that corresponds to the pixel position for which an output value is being computed.
-
-
Constructor Summary
Constructors Constructor Description Kernel(int width, int height, double[] data)Constructs aKernelobject from an array of floats.Kernel(int width, int height, double factor, double[] data)Constructs aKernelobject from an array of floats.Kernel(int width, int height, int xOrigin, int yOrigin, double factor, double[] data)Constructs aKernelobject from an array of floats.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectclone()Clones this object.doublegetFactor()Returns the factor of thisKernel.intgetHeight()Returns the height of thisKernel.double[]getKernelData(double[] data)Returns the filter data in row major order.intgetWidth()Returns the width of thisKernel.intgetXOrigin()Returns the X origin of thisKernel.intgetYOrigin()Returns the Y origin of thisKernel.
-
-
-
Constructor Detail
-
Kernel
public Kernel(int width, int height, double[] data)Constructs aKernelobject from an array of floats. The firstwidth*heightelements of thedataarray are copied. If the length of thedataarray is less than width*height, anIllegalArgumentExceptionis thrown. The X origin is (width-1)/2 and the Y origin is (height-1)/2.- Parameters:
width- width of the filterheight- height of the filterdata- filter data in row major order- Throws:
IllegalArgumentException- if the length ofdatais less than the product ofwidthandheight
-
Kernel
public Kernel(int width, int height, double factor, double[] data)Constructs aKernelobject from an array of floats. The firstwidth*heightelements of thedataarray are copied. If the length of thedataarray is less than width*height, anIllegalArgumentExceptionis thrown. The X origin is (width-1)/2 and the Y origin is (height-1)/2.- Parameters:
width- width of the filterheight- height of the filterfactor- factor to be applied to each element ofdatadata- filter data in row major order- Throws:
IllegalArgumentException- if the length ofdatais less than the product ofwidthandheight
-
Kernel
public Kernel(int width, int height, int xOrigin, int yOrigin, double factor, double[] data)Constructs aKernelobject from an array of floats. The firstwidth*heightelements of thedataarray are copied. If the length of thedataarray is less than width*height, anIllegalArgumentExceptionis thrown. The X origin is (width-1)/2 and the Y origin is (height-1)/2.- Parameters:
width- width of the filterheight- height of the filterxOrigin- X origin of the filteryOrigin- Y origin of the filterfactor- factor to be applied to each element ofdatadata- filter data in row major order- Throws:
IllegalArgumentException- if the length ofdatais less than the product ofwidthandheight
-
-
Method Detail
-
getXOrigin
public final int getXOrigin()
Returns the X origin of thisKernel.- Returns:
- the X origin.
-
getYOrigin
public final int getYOrigin()
Returns the Y origin of thisKernel.- Returns:
- the Y origin.
-
getWidth
public final int getWidth()
Returns the width of thisKernel.- Returns:
- the width of this
Kernel.
-
getHeight
public final int getHeight()
Returns the height of thisKernel.- Returns:
- the height of this
Kernel.
-
getFactor
public final double getFactor()
Returns the factor of thisKernel.- Returns:
- the factor of this
Kernel.
-
getKernelData
public final double[] getKernelData(double[] data)
Returns the filter data in row major order. Thedataarray is returned. Ifdataisnull, a new array is allocated.- Parameters:
data- if non-null, contains the returned filter data- Returns:
- the
dataarray containing the filter data in row major order or, ifdataisnull, a newly allocated array containing the filter data in row major order - Throws:
IllegalArgumentException- ifdatais less than the size of thisKernel
-
-