Class Kernel1D

java.lang.Object
imagingbook.common.filter.linear.Kernel1D
Direct Known Subclasses:
GaussianKernel1D

public class Kernel1D extends Object
This class represents a 1D filter kernel.
Version:
2020/12/29
  • Constructor Summary

    Constructors
    Constructor
    Description
    Kernel1D(float[] h)
    Constructor.
    Kernel1D(float[] h, int xc, boolean normalize)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    float[]
    Returns the kernel's 1D array.
    int
    Returns the width (length) of this kernel.
    int
    Returns the center coordinate of this kernel.
    static float[]
    normalize(float[] A)
    Normalizes the specified array such that its sum becomes 1.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Kernel1D

      public Kernel1D(float[] h)
      Constructor. The kernel's hot spot is at its center. The kernel is normalized.
      Parameters:
      h - the 1D kernel array
    • Kernel1D

      public Kernel1D(float[] h, int xc, boolean normalize)
      Constructor. The hot spot index must be specified. The kernel is optionally normalized.
      Parameters:
      h - the 1D kernel array
      xc - the x-coordinate of the kernel's hot spot, default is (width-1)/2
      normalize - if true the kernel is normalized (to sum = 1)
  • Method Details

    • getH

      public float[] getH()
      Returns the kernel's 1D array.
      Returns:
      the kernel's 1D array
    • getWidth

      public int getWidth()
      Returns the width (length) of this kernel.
      Returns:
      the kernel's width
    • getXc

      public int getXc()
      Returns the center coordinate of this kernel.
      Returns:
      the kernel's center coordinate
    • normalize

      public static float[] normalize(float[] A) throws ArithmeticException
      Normalizes the specified array such that its sum becomes 1. Throws an exception if the array's sum is zero. The original array is not modified.
      Parameters:
      A - a 1D array
      Returns:
      the normalized array
      Throws:
      ArithmeticException - if array sums to zero