de.erichseifert.gral.data.filters
Class Kernel
- java.lang.Object
-
- de.erichseifert.gral.data.filters.Kernel
-
- All Implemented Interfaces:
- java.io.Serializable
public class Kernel extends java.lang.Object implements java.io.SerializableClass that represents an one dimensional array of coefficients for a weighted filtering.
Functionality includes:
- Adding of other kernels or scalars
- Multiplication with other kernels or scalars
- Normalization
- Negation
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description Kernel(double... values)Creates a new kernel object with the specified values and an offset being half the size of this kernel (rounded down).Kernel(int offset, double[] values)Creates a new Kernel object with the specified offset and values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description Kerneladd(double v)Returns a new Kernel, where the specified value was added to each of the items.Kerneladd(Kernel k)Returns a new Kernel, where the specified kernel was added.doubleget(int i)Returns the value at the specified position of this kernel.static KernelgetBinomial(double variance)Returns a Kernel of specified variance with binomial coefficients.static KernelgetBinomial(int size)Returns a Kernel of specified size with binomial coefficients.intgetMaxIndex()Returns the index of the "rightmost" value.intgetMinIndex()Returns the index of the "leftmost" value.intgetOffset()Returns the offset of this kernel.static KernelgetUniform(int size, int offset, double value)Returns a Kernel with the specified size and offset, filled with a single value.Kernelmul(double v)Returns a new Kernel, where the specified value was multiplied with each of the items.Kernelmul(Kernel k)Returns a new Kernel, where the specified kernel was multiplied.Kernelnegate()Returns a Kernel with all values being negated.Kernelnormalize()Returns a normalized Kernel so that the sum of all values equals 1.intsize()Returns the number of values in this kernel.
-
-
-
Constructor Detail
-
Kernel
public Kernel(int offset, double[] values)Creates a new Kernel object with the specified offset and values.- Parameters:
offset- Offset to the first item in the kernel.values- Array of values in the kernel.
-
Kernel
public Kernel(double... values)
Creates a new kernel object with the specified values and an offset being half the size of this kernel (rounded down).- Parameters:
values- Data values for the kernel.
-
-
Method Detail
-
getBinomial
public static Kernel getBinomial(double variance)
Returns a Kernel of specified variance with binomial coefficients.- Parameters:
variance- Variance.- Returns:
- Kernel.
-
getBinomial
public static Kernel getBinomial(int size)
Returns a Kernel of specified size with binomial coefficients.- Parameters:
size- Size of the Kernel.- Returns:
- Kernel.
-
getUniform
public static Kernel getUniform(int size, int offset, double value)
Returns a Kernel with the specified size and offset, filled with a single value.- Parameters:
size- Size.offset- Offset.value- Value the Kernel is filled with.- Returns:
- Kernel.
-
get
public double get(int i)
Returns the value at the specified position of this kernel. If the position exceeds the minimum or maximum index, 0.0 is returned.- Parameters:
i- Index to be returned.- Returns:
- Value at the specified index.
-
getOffset
public int getOffset()
Returns the offset of this kernel.- Returns:
- Offset.
-
size
public int size()
Returns the number of values in this kernel.- Returns:
- Number of values.
-
getMinIndex
public int getMinIndex()
Returns the index of the "leftmost" value.- Returns:
- Minimal index.
-
getMaxIndex
public int getMaxIndex()
Returns the index of the "rightmost" value.- Returns:
- Maximal index.
-
add
public Kernel add(double v)
Returns a new Kernel, where the specified value was added to each of the items.- Parameters:
v- Value to be added.- Returns:
- Kernel with new values.
-
add
public Kernel add(Kernel k)
Returns a new Kernel, where the specified kernel was added.- Parameters:
k- Kernel to be added.- Returns:
- Kernel with new values.
-
mul
public Kernel mul(double v)
Returns a new Kernel, where the specified value was multiplied with each of the items.- Parameters:
v- Value to be multiplied.- Returns:
- Kernel with new values.
-
mul
public Kernel mul(Kernel k)
Returns a new Kernel, where the specified kernel was multiplied.- Parameters:
k- Kernel to be multiplied.- Returns:
- Kernel with new values.
-
normalize
public Kernel normalize()
Returns a normalized Kernel so that the sum of all values equals 1.- Returns:
- Normalized Kernel.
-
negate
public Kernel negate()
Returns a Kernel with all values being negated.- Returns:
- Negated Kernel.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG