Class MedianFilter

All Implemented Interfaces:
SpatialFilter

public final class MedianFilter extends AbstractKernelFilter implements SpatialFilter
A SpatialFilter for performing median filtering of an image.
  • Constructor Details

    • MedianFilter

      public MedianFilter(int[] kernelSize, BoundaryCondition boundaryCondition) throws IllegalArgumentException
      Construct a MedianFilter with a kernel size specified by the argument.
      Parameters:
      kernelSize - the kernel size in each direction.
      boundaryCondition - the BoundaryCondition to apply when this filter is applied to an array of pixels.
      Throws:
      IllegalArgumentException - if any of the kernel size values is illegal.
  • Method Details

    • 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.
    • newInstance

      public static MedianFilter newInstance(org.apache.commons.cli.CommandLine commandLine, ReadableImage image) throws InvalidArgumentException
      Creates a new MedianFilter 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. Not used in the design of a MedianFilter.
      Returns:
      a new MedianFilter.
      Throws:
      InvalidArgumentException - if the filter cannot be constructed from the arguments.
    • 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.
    • toString

      public String toString()
      Returns a String describing this MedianFilter.
      Overrides:
      toString in class Object
      Returns:
      a String describing this MedianFilter.
    • 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 MedianFilter.
      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.
    • main

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