Class GenericFilterScalarSeparable

java.lang.Object
imagingbook.common.filter.generic.GenericFilter
imagingbook.common.filter.generic.GenericFilterScalarSeparable
All Implemented Interfaces:
ProgressReporter
Direct Known Subclasses:
BilateralFilterScalarSeparable, LinearFilterSeparable

public abstract class GenericFilterScalarSeparable extends GenericFilter
This (abstract) class represents a generic scalar filter whose pixel-operation is x/y-separable. It is similar to GenericFilterScalar but requires two methods to be implemented by concrete sub-classes: doPixelX(PixelSlice, int, int) and doPixelY(PixelSlice, int, int) for the x- and y-pass, respectively, which are invoked in exactly this order. 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 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).
  • Field Details

    • doX

      protected boolean doX
    • doY

      protected boolean doY
  • 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
    • doPixelX

      protected abstract float doPixelX(PixelPack.PixelSlice source, int u, int v)
      Applies a 1D filter operation in x-direction. This method must be implemented by concrete sub-classes. This method is invoked before doPixelY(PixelSlice, int, int). 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
    • doPixelY

      protected abstract float doPixelY(PixelPack.PixelSlice source, int u, int v)
      Applies a 1D filter operation in y-direction. This method must be implemented by concrete sub-classes. This method is invoked after doPixelX(PixelSlice, int, int). 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)