java.lang.Object
imagingbook.common.filter.generic.GenericFilter
imagingbook.common.filter.generic.GenericFilterScalar
imagingbook.common.filter.examples.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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected float
doPixel
(PixelPack.PixelSlice slice, 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.Methods inherited from class imagingbook.common.filter.generic.GenericFilterScalar
reportProgress, runPass
Methods inherited from class imagingbook.common.filter.generic.GenericFilter
abort, applyTo, applyTo, applyTo, closeFilter, getDepth, getHeight, getPass, getProgress, getWidth, initFilter, initPass, passesRequired, reportProgress
-
Constructor Details
-
ExampleFilter3x3Scalar
public ExampleFilter3x3Scalar()
-
-
Method Details
-
doPixel
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 aPixelPack.PixelSlice
container, which holds the scalar values of one image component. The methodPixelPack.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 classGenericFilterScalar
- Parameters:
slice
- the scalar-valued data for a single image componentu
- the current x-positionv
- the current y-position- Returns:
- the result of the filter calculation for this pixel
-