Class PatchSimilarityFilter

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

public final class PatchSimilarityFilter extends Object implements SpatialFilter
Noise reduction filter based in averaging pixel intensities based on the similarity of patches that are not necessarily local to the pixel.
  • Field Details

    • NOISE_SUPPRESSION_LEVEL_PERCENT_OPTION

      public static final org.apache.commons.cli.Option NOISE_SUPPRESSION_LEVEL_PERCENT_OPTION
      A public Option to specify that the noise suppresion level for a Patch Similarity filter as a percentage of the robust image intensity range.
    • NOISE_SD_OPTION

      public static final org.apache.commons.cli.Option NOISE_SD_OPTION
      A public Option to specify that the noise suppresion level for a Patch Similarity filter as a noise intensity standard deviation.
  • Constructor Details

    • PatchSimilarityFilter

      public PatchSimilarityFilter(PixelDataType dataType, Float noisePercent, Float noiseSD, boolean threeD) throws IllegalArgumentException
      Creates a new PatchSimilarityFilter suitable for suppressing noise in an image with the given PixelDataType.
      Parameters:
      dataType - the presentation PixelDataType to which the filter will be applied.
      noisePercent - the noise suppression level as a percentage of the robust image intensity range (excluding background) [0..100].
      noiseSD - the standard deviation of the noise to suppress.
      threeD - whether a 3-D filter should be returned.
      Throws:
      IllegalArgumentException - if the PixelDataType or noise value is invalid.
  • Method Details

    • newInstance

      public static PatchSimilarityFilter newInstance(org.apache.commons.cli.CommandLine commandLine, ReadableImage image) throws InvalidArgumentException
      Creates a new PatchSimilarityFilter using the supplied command line arguments, suitable for filtering the supplied image.
      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 PatchSimilarityFilter.
      Throws:
      InvalidArgumentException - if the arguments are malformed.
    • newInstance

      public static PatchSimilarityFilter newInstance(ReadableImage image, Float noisePercent, Float noiseSD, boolean threeD) throws InvalidArgumentException
      Creates a new PatchSimilarityFilter suitable for suppressing noise in the supplied image.
      Parameters:
      image - the image to which this filter is designed to apply.
      noisePercent - the noise suppression level as a percentage of the robust image intensity range [0..100].
      noiseSD - the standard deviation of the noise to suppress.
      threeD - whether this should be a 3-D filter.
      Returns:
      a new PatchSimilarityFilter.
      Throws:
      InvalidArgumentException - if the noise value is invalid.
    • newInstance

      public static PatchSimilarityFilter newInstance(PixelDataType dataType, Float noisePercent, Float noiseSD, boolean threeD) throws InvalidArgumentException
      Creates a new PatchSimilarityFilter suitable for suppressing noise in an image with the given PixelDataType.
      Parameters:
      dataType - the presentation PixelDataType to which the filter will be applied.
      noisePercent - the noise suppression level as a percentage of the robust image intensity range (excluding background) [0..100].
      noiseSD - the standard deviation of the noise to suppress.
      threeD - whether a 3-D filter should be returned.
      Returns:
      a new PatchSimilarityFilter.
      Throws:
      InvalidArgumentException - if the PixelDataType or noise value is invalid.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • filter

      Description copied from interface: SpatialFilter
      Filter a ReadableImage, returning a new image which is a filtered version of the supplied image.
      Specified by:
      filter in interface SpatialFilter
      Parameters:
      image - the image to be filtered.
      Returns:
      a filtered version of the supplied image.
      Throws:
      InvalidImageException - if the supplied image cannot be filtered with this filter.
      IOException - if an I/O error occurs.
    • filter

      public WritableImage filter(ReadableImage image, MonitorWorker worker, boolean verbose) throws InvalidImageException, IOException, CancelledException
      Description copied from interface: SpatialFilter
      Filter a ReadableImage, returning a new image which is a filtered version of the supplied image.
      Specified by:
      filter in interface SpatialFilter
      Parameters:
      image - the image to be filtered.
      worker - the MonitorWorker that may be used to cancel the filter operation.
      verbose - whether verbose reporting to System.out is turned on.
      Returns:
      a filtered version of the supplied image.
      Throws:
      InvalidImageException - if the supplied image cannot be filtered with this filter.
      IOException - if an I/O error occurs.
      CancelledException - if the filter operation is cancelled by the user or programmatically.
    • filterInPlace

      public void filterInPlace(WritableImage image) throws InvalidImageException, IOException
      Description copied from interface: SpatialFilter
      Filter a WritableImage "in place".
      Specified by:
      filterInPlace in interface SpatialFilter
      Parameters:
      image - the image to be filtered.
      Throws:
      InvalidImageException - if the supplied image cannot be filtered with this filter.
      IOException - if an I/O error occurs.
    • filterInPlace

      public void filterInPlace(WritableImage image, MonitorWorker worker, boolean verbose) throws InvalidImageException, IOException, CancelledException
      Description copied from interface: SpatialFilter
      Filter a WritableImage "in place".
      Specified by:
      filterInPlace in interface SpatialFilter
      Parameters:
      image - the image to be filtered.
      worker - the MonitorWorker that may be used to cancel the filter operation.
      verbose - whether verbose reporting to System.out is turned on.
      Throws:
      InvalidImageException - if the supplied image cannot be filtered with this filter.
      IOException - if an I/O error occurs.
      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)
      Description copied from interface: SpatialFilter
      Filter an array of pixel values "in place".
      Specified by:
      filterInPlace in interface SpatialFilter
      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.
    • 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
      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.
    • 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 PatchSimilarityFilter.
      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.