Class MorphologicalOperator

java.lang.Object
com.xinapse.filter.AbstractKernelFilter
com.xinapse.filter.MorphologicalOperator
All Implemented Interfaces:
SpatialFilter

public final class MorphologicalOperator extends AbstractKernelFilter implements SpatialFilter
A SpatialFilter for performing a morphological operation on an image.
  • Field Details

    • ERODE_2D_3_X_3

      public static final MorphologicalOperator ERODE_2D_3_X_3
      A 2-D erode operator with a 3x3 kernel.
    • DILATE_2D_3_X_3

      public static final MorphologicalOperator DILATE_2D_3_X_3
      A 2-D dilate operator with a 3x3 kernel.
    • ERODE_3D_3_X_3_X_3

      public static final MorphologicalOperator ERODE_3D_3_X_3_X_3
      A 3-D erode operator with a 3x3x3 kernel.
    • DILATE_3D_3_X_3_X_3

      public static final MorphologicalOperator DILATE_3D_3_X_3_X_3
      A 3-D dilate operator with a 3x3x3 kernel.
    • OPTIONS

      public static final org.apache.commons.cli.Options OPTIONS
      The Options for selecting a MorphologicalOperator.
  • Constructor Details

    • MorphologicalOperator

      public MorphologicalOperator(boolean[][][] elt, MorphologicalOperator.Op op, BoundaryCondition boundaryCondition) throws IllegalArgumentException
      Creates a new MorphologicalOperator with the given structuring element, operation and image boundary condition.
      Parameters:
      elt - a binary mask of the the structuring element.
      op - the operation to perform.
      boundaryCondition - how pixels at the edge of the image FoV should be treated.
      Throws:
      IllegalArgumentException - if the kernel size is not odd in any of the dimensions.
  • Method Details

    • newInstance

      public static MorphologicalOperator newInstance(org.apache.commons.cli.CommandLine commandLine, ReadableImage image) throws InvalidArgumentException
      Creates a new MorphologicalOperator using the supplied command line arguments.
      Parameters:
      commandLine - the command line from which a program is invoked.
      image - the image to which this filter is designed to apply.
      Returns:
      a new MorphologicalOperator.
      Throws:
      InvalidArgumentException - if the MorphologicalOperator cannot be created from the arguments.
    • newRectangular2DInstance

      public static MorphologicalOperator newRectangular2DInstance(int kernelSize, MorphologicalOperator.Op op, BoundaryCondition bc)
      Creates a new MorphologicalOperator with a 2-D rectangular kernel.
      Parameters:
      kernelSize - the kernel size.
      op - the MorphologicalOperator.Op to perform.
      bc - the image boundary condition to apply.
      Returns:
      a new MorphologicalOperator with a 2-D rectangular kernel.
    • newCircular2DInstance

      public static MorphologicalOperator newCircular2DInstance(int kernelSize, MorphologicalOperator.Op op, BoundaryCondition bc)
      Creates a new MorphologicalOperator with a 2-D circular kernel.
      Parameters:
      kernelSize - the kernel size (diameter).
      op - the MorphologicalOperator.Op to perform.
      bc - the image boundary condition to apply.
      Returns:
      a new MorphologicalOperator with a 2-D circular kernel.
    • newCubic3DInstance

      public static MorphologicalOperator newCubic3DInstance(int kernelSize, MorphologicalOperator.Op op, BoundaryCondition bc)
      Creates a new MorphologicalOperator with a 3-D cubic kernel.
      Parameters:
      kernelSize - the kernel size.
      op - the MorphologicalOperator.Op to perform.
      bc - the image boundary condition to apply.
      Returns:
      a new MorphologicalOperator with a 3-D cubic kernel.
    • newSpherical3DInstance

      public static MorphologicalOperator newSpherical3DInstance(int kernelSize, MorphologicalOperator.Op op, BoundaryCondition bc)
      Creates a new MorphologicalOperator with a 3-D spherical kernel.
      Parameters:
      kernelSize - the kernel size (diameter).
      op - the MorphologicalOperator.Op to perform.
      bc - the image boundary condition to apply.
      Returns:
      a new MorphologicalOperator with a 3-D spherical kernel.
    • getNKernelCols

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

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

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

      public void filterInPlaceFloat(float[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, boolean verbose) throws CancelledException
      Description copied from class: AbstractKernelFilter
      Filter an array of floating-point pixel values "in place".
      Specified by:
      filterInPlaceFloat in class AbstractKernelFilter
      Parameters:
      pixels - the array of image pixel values.
      nCols - the number of image columns
      nRows - the number of image rows.
      nSlices - the number of image slices.
      worker - the MonitorWorker that may be used to cancel the filter operation.
      verbose - whether verbose reporting to System.out is turned on.
      Throws:
      CancelledException - if the filter operation is cancelled by the user or programmatically.
    • filterInPlaceDouble

      public void filterInPlaceDouble(double[] pixels, int nCols, int nRows, int nSlices, MonitorWorker worker, boolean verbose) throws CancelledException
      Description copied from class: AbstractKernelFilter
      Filter an array of double-precision pixel values "in place". This default implementation should be overridden by SpatialFilters that are interested in a more efficient implementation for PixelDataType.DOUBLE images.
      Overrides:
      filterInPlaceDouble in class AbstractKernelFilter
      Parameters:
      pixels - the array of image pixel values.
      nCols - the number of image columns
      nRows - the number of image rows.
      nSlices - the number of image slices.
      worker - the MonitorWorker that may be used to cancel the filter operation.
      verbose - whether verbose reporting to System.out is turned on.
      Throws:
      CancelledException - if the filter operation is cancelled by the user or programmatically.
    • filterInPlace

      public void filterInPlace(Object pixels, PixelDataType dataType, int nCols, int nRows, int nSlices, MonitorWorker worker, boolean verbose) throws CancelledException
      Description copied from interface: SpatialFilter
      Filter an array of pixel values "in place".
      Specified by:
      filterInPlace in interface SpatialFilter
      Overrides:
      filterInPlace in class AbstractKernelFilter
      Parameters:
      pixels - the array of image pixel values.
      dataType - the PixelDataType of the pixels.
      nCols - the number of image columns.
      nRows - the number of image rows.
      nSlices - the number of image slices.
      worker - the MonitorWorker that may be used to cancel the filter operation.
      verbose - whether verbose reporting to System.out is turned on.
      Throws:
      CancelledException - if the filter operation is cancelled by the user or programmatically.
    • toString

      public String toString()
      Returns a String describing the operator.
      Overrides:
      toString in class Object
      Returns:
      a String describing the MorphologicalOperator.
    • getOptionName

      public static String getOptionName()
      Returns the name of this type of filter when specifying it in program optional arguments.
      Returns:
      the name of the filter for selection in program arguments.
    • getOptions

      public static org.apache.commons.cli.Options getOptions()
      Returns the options for this type of filter.
      Returns:
      the options for this type of filter.
    • getSpecifierPanel

      public static SpatialFilter.SpecifierPanel getSpecifierPanel(String preferencesNodeName)
      Returns a SpatialFilter.SpecifierPanel that can be used to set the parameters for a MorphologicalOperator.
      Parameters:
      preferencesNodeName - the preferences node name from which the initial settings will be taken.
      Returns:
      a SpatialFilter.SpecifierPanel to set the parameters for this type of filter.
    • getName

      public static String getName()
      Returns the human-readable name of this filter.
      Returns:
      the human-readable name of this filter.
    • equals

      public boolean equals(Object o)
      Tests whether the supplied argument is equal to this MorphologicalOperator.
      Overrides:
      equals in class Object
      Parameters:
      o - the Object to be tested for equality.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • main

      public static void main(String[] args)
      Runs a self-test of this class.
      Parameters:
      args - the program aguments (ignored).