Class FixedWeightsComplexKernelFilter

java.lang.Object
com.xinapse.filter.AbstractComplexKernelFilter
com.xinapse.filter.FixedWeightsComplexKernelFilter
All Implemented Interfaces:
SpatialFilter

public class FixedWeightsComplexKernelFilter extends AbstractComplexKernelFilter implements SpatialFilter
A class for performing filtering of complex images based on a moving kernel of pixels with fixed complex weights within the kernel.
  • Field Details

    • complexWeights

      protected final float[][][] complexWeights
      The 3-D array of weights in the kernel. The first index is the slice index, the second is the row index, and the third is the column index. Weights are in iterleaved real/imaginary pairs.
  • Constructor Details

    • FixedWeightsComplexKernelFilter

      protected FixedWeightsComplexKernelFilter()
      Default constructor produces an identity FixedWeightsComplexKernelFilter with kernel size 1x1x1 that has no effect when applied.
    • FixedWeightsComplexKernelFilter

      public FixedWeightsComplexKernelFilter(FloatComplex[][] wts, boolean normalise, BoundaryCondition boundaryCondition) throws IllegalArgumentException
      Constructs a 2-dimensional kernel-based filter with the given filter weights. The filter may optionally be normalised so that it is intensity-preserving (i.e., the sum of the magnitude of the weights will be forced to add up to 1).
      Parameters:
      wts - a two-dimensional array of weights. This array must have an odd number of elements in each of the two dimensions. The centre of the weights kernel will be centred on the pixel being filtered. The first index of the array refers to the the row direction, and the second to the column direction.
      normalise - if true the weights will be normalised when constructing the kernel. If the weights cannot be normalised, then this argument has no effect.
      boundaryCondition - the BoundaryCondition to apply when this filter is applied to an array of pixels.
      Throws:
      IllegalArgumentException - if the dimensions of the kernel weights array aren't odd-numbered in each of the two dimensions.
    • FixedWeightsComplexKernelFilter

      public FixedWeightsComplexKernelFilter(FloatComplex[][][] wts, boolean normalise, BoundaryCondition boundaryCondition) throws IllegalArgumentException
      Constructs a 3-dimensional kernel-based filter with the given filter weights. The filter may optionally be normalised so that it is intensity-preserving (i.e., the sum of weights will be forced to add up to 1).
      Parameters:
      wts - a three-dimensional array of weights. This array must have an odd number of elements in each of the three dimensions. The centre of the weights kernel will be centred on the pixel being filtered. The first index of the array refers to the slice direction, the second index to the row direction, and the third to the column direction.
      normalise - if true the weights will be normalised when constructing the kernel. If the weights cannot be normalised, then this argument has no effect.
      boundaryCondition - the BoundaryCondition to apply when this filter is applied to an array of pixels.
      Throws:
      IllegalArgumentException - if the dimensions of the kernel weights array aren't odd-numbered in each of the three dimensions.
  • Method Details

    • getNKernelCols

      public int getNKernelCols()
      Description copied from class: AbstractComplexKernelFilter
      Returns the number of columns in the filter kernel.
      Specified by:
      getNKernelCols in class AbstractComplexKernelFilter
      Returns:
      the number of columns in the filter kernel.
    • getNKernelRows

      public int getNKernelRows()
      Description copied from class: AbstractComplexKernelFilter
      Returns the number of rows in the filter kernel.
      Specified by:
      getNKernelRows in class AbstractComplexKernelFilter
      Returns:
      the number of rows in the filter kernel.
    • getNKernelSlices

      public int getNKernelSlices()
      Description copied from class: AbstractComplexKernelFilter
      Returns the number of slices in the filter kernel.
      Specified by:
      getNKernelSlices in class AbstractComplexKernelFilter
      Returns:
      the number of slices in the filter kernel.
    • scale

      public void scale(float scaleFactor)
      Scale all kernel weights (both real and imaginary parts) by the given scaling factor.
      Parameters:
      scaleFactor - the scaling factor for the weights.
    • sumWeights

      public float sumWeights()
      Returns the sum of the magnitude of all the weights for this FixedWeightsComplexKernelFilter.
      Returns:
      the sum magnitude of all the weights.
    • add

      Adds the weights from a FixedWeightsComplexKernelFilter to the weights of this one.
      Parameters:
      filter - the FixedWeightsComplexKernelFilter from which to add the weights.
      Throws:
      IllegalArgumentException - if the two filters do not have the same kernel dimensions.
    • add

      Adds the weights from two FixedWeightsComplexKernelFilters to create a new FixedWeightsComplexKernelFilter.
      Parameters:
      filter1 - the first FixedWeightsComplexKernelFilter from which to add the weights.
      filter2 - the second FixedWeightsComplexKernelFilter from which to add the weights.
      Returns:
      a new FixedWeightsComplexKernelFilter with weights which calculated by summing the weights from the two supplied filters.
      Throws:
      IllegalArgumentException - if the two filters do not have the same kernel dimensions.
    • copyResize

      public FixedWeightsComplexKernelFilter copyResize(int[] newSize, boolean normalise) throws IllegalArgumentException
      Copies a FixedWeightsComplexKernelFilter, possibly resizing it, creating a new FixedWeightsComplexKernelFilter. If the requested size is larger than the current size in any direction, the new filter is padded with zeros. If the requested size is smaller than the current size in any direction, the new filter is cropped.
      Parameters:
      newSize - an array of length at least 3 that specifies the new kernel size.
      normalise - whether the resulting FixedWeightsComplexKernelFilter should be normalised (the sum of all weights should be unity).
      Returns:
      a copy of the supplied FixedWeightsComplexKernelFilter, but resized.
      Throws:
      IllegalArgumentException
    • convolve

      Convolves this FixedWeightsComplexKernelFilter with another FixedWeightsComplexKernelFilter to create a new FixedWeightsComplexKernelFilter.
      Parameters:
      filter - the FixedWeightsComplexKernelFilter with which this FixedWeightsComplexKernelFilter will be convolved.
      Returns:
      a new FixedWeightsComplexKernelFilter that results from convolving this filter with the supplied filter.
    • toString

      public String toString()
      Returns a String describing this FixedWeightsComplexKernelFilter.
      Overrides:
      toString in class Object
      Returns:
      a String showing the weights of this FixedWeightsComplexKernelFilter.