Class ColourImageFilter

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

public class ColourImageFilter extends Object implements SpatialFilter
A SpatialFilter for altering the colour components of a colour image.
  • Field Details

    • RED_FORMULA_OPTION

      public static final org.apache.commons.cli.Option RED_FORMULA_OPTION
      A public Option to specify the formula used to calculate the new red component values in the image.
    • GREEN_FORMULA_OPTION

      public static final org.apache.commons.cli.Option GREEN_FORMULA_OPTION
      A public Option to specify the formula used to calculate the new green component values in the output image.
    • BLUE_FORMULA_OPTION

      public static final org.apache.commons.cli.Option BLUE_FORMULA_OPTION
      A public Option to specify the formula used to calculate the new blue component values in the output image.
  • Constructor Details

    • ColourImageFilter

      public ColourImageFilter(String redFormula, String greenFormula, String blueFormula) throws InvalidArgumentException
      Creates a new ColourImageFilter based on three formulae used to compute the red, green and blue colour components.
      Parameters:
      redFormula - the formula to calculate the new red colour component.
      greenFormula - the formula to calculate the new green colour component.
      blueFormula - the formula to calculate the new blue colour component.
      Throws:
      InvalidArgumentException - if any of the formulae is invalid.
  • Method Details

    • newInstance

      public static ColourImageFilter newInstance(org.apache.commons.cli.CommandLine commandLine, ReadableImage image) throws InvalidArgumentException
      Creates a new ColourImageFilter 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 ColourImageFilter.
      Throws:
      InvalidArgumentException - if the ColourImageFilter cannot be created using the supplied command line arguments.
    • 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 ColourImageFilter.
      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.
    • 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.
    • main

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