Class ExampleFilter3x3Scalar

All Implemented Interfaces:
ProgressReporter

Example filter based on GenericFilterScalar performing linear convolution with a custom 3x3 filter kernel. This filter may be applied to any image. On vector-valued images (e.g., RGB images) the filter is applied independently to each component.

Usage:

 ImageProcessor ip = ...        // any image
 GenericFilter filter = new ExampleFilter3x3Scalar();
 filter.applyTo(ip);            // modifies ip
 

Note: This is merely a linear filter with a custom kernel to demonstrate the concept of a generic filter. In practice (depending on the type of kernel) this would be implemented as a sub-class of LinearFilter or LinearFilterSeparable, which is much more efficient.

See Also:
  • Constructor Details

  • Method Details

    • doPixel

      protected float doPixel(PixelPack.PixelSlice slice, int u, int v)
      Description copied from class: GenericFilterScalar
      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.
      Specified by:
      doPixel in class GenericFilterScalar
      Parameters:
      slice - 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