Class GenericFilterScalar

java.lang.Object
imagingbook.common.filter.generic.GenericFilter
imagingbook.common.filter.generic.GenericFilterScalar
All Implemented Interfaces:
ProgressReporter
Direct Known Subclasses:
BilateralFilterScalar, ExampleFilter3x3Scalar, KuwaharaFilterScalar, LinearFilter, NagaoMatsuyamaFilterScalar, PeronaMalikFilterScalar, ScalarMedianFilter

public abstract class GenericFilterScalar extends GenericFilter

This (abstract) class represents a filter which treats all pixel values as scalars. If the processed image has more than one component (e.g., a RGB color image), this filter is automatically and independently applied to all (scalar-valued) components. The filter calls the method doPixel(PixelSlice, int, int) for each image pixel, which must be implemented by any concrete sub-class.

Thus a custom filter based on this class only needs to specify the steps to be performed for a single pixel. The remaining filter mechanics including multiple components, out-of-bounds coordinate handling, multiple passes and data copying are handled by this class and its super-class (see GenericFilter).

  • Constructor Details

  • Method Details

    • runPass

      protected void runPass(PixelPack source, PixelPack target)
      Description copied from class: GenericFilter
      This method performs one pass of the filter, it must be implemented by a sub-class. There is usually no need for a custom filter class to override this method.
      Specified by:
      runPass in class GenericFilter
      Parameters:
      source - the image source data
      target - the image target data
    • doPixel

      protected abstract float doPixel(PixelPack.PixelSlice source, int u, int v)
      This method defines the steps to be performed for a single image pixel and must be implemented by any concrete sub-class. The source data are passed as a PixelPack.PixelSlice container, which holds the scalar values of one image component. The method PixelPack.PixelSlice.getVal(int, int) should be used to read individual pixel values. These data should not be modified but the (float) result of the single-pixel calculation must be returned.
      Parameters:
      source - the scalar-valued data for a single image component
      u - the current x-position
      v - the current y-position
      Returns:
      the result of the filter calculation for this pixel
    • reportProgress

      protected final double reportProgress(double subProgress)
      Description copied from class: GenericFilter
      This method is used for internal progress reporting through the class hierarchy. It should not be overridden or modified.
      Overrides:
      reportProgress in class GenericFilter
      Parameters:
      subProgress - the current progress reported by the immediate sub-task (0,...,1)
      Returns:
      the cumulative progress (0,...,1)