de.erichseifert.gral.data.filters
Class Kernel

java.lang.Object
  extended by de.erichseifert.gral.data.filters.Kernel

public class Kernel
extends Object

Class that represents an array of coefficients for a weighted filtering. Functionality includes:


Constructor Summary
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
 Kernel add(double v)
          Returns a new Kernel, where the specified value was added to each of the items.
 Kernel add(Kernel k)
          Returns a new Kernel, where the specified kernel was added.
 double get(int i)
          Returns the value at the specified position of this kernel.
 int getMaxIndex()
          Returns the index of the "rightmost" value.
 int getMinIndex()
          Returns the index of the "leftmost" value.
 int getOffset()
          Returns the offset of this kernel.
 Kernel mul(double v)
          Returns a new Kernel, where the specified value was multiplied with each of the items.
 Kernel mul(Kernel k)
          Returns a new Kernel, where the specified kernel was multiplied.
 Kernel negate()
          Returns a Kernel with all values being negated.
 Kernel normalize()
          Returns a normalized Kernel so that the sum of all values equals 1.
 int size()
          Returns the number of values in this kernel.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

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.


Copyright © 2009-2010. All Rights Reserved.