ImageFilterPipeline#

The ImageFilterPipeline class provide a Helper that lets callers compose and reuse preprocessing filter pipelines.

Method / Attribute

Short Description

ImageFilterPipeline.Clear()

Removes every filter from the pipeline.

ImageFilterPipeline.RemoveAll()

Removes all filters matching the specified type.

ImageFilterPipeline.AddFilter()

Adds a filter to the pipeline.

ImageFilterPipeline.AddDeskew()

Adds a deskew filter to the pipeline.

ImageFilterPipeline.AddDilation()

Adds a dilation filter to the pipeline.

ImageFilterPipeline.AddRemoveVerticalLines()

Adds a remove vertical lines filter to the pipeline.

ImageFilterPipeline.AddRemoveHoriziontalLines()

Adds a remove horizontal lines filter to the pipeline.

ImageFilterPipeline.AddMedian()

Adds a median filter to the pipeline.

ImageFilterPipeline.AddGamma()

Adds a gamma correction filter to the pipeline.

ImageFilterPipeline.AddContrast()

Adds a contrast adjustment filter to the pipeline.

ImageFilterPipeline.AddGrayscale()

Adds a grayscale conversion filter to the pipeline.

ImageFilterPipeline.AddInvert()

Adds a color inversion filter to the pipeline.

ImageFilterPipeline.AddScale()

Adds a scale filter to the pipeline.

ImageFilterPipeline.AddScaleFit()

Adds a scale-to-fit filter to the pipeline.

ImageFilterPipeline.Apply()

Applies the configured filters to the supplied image.

Class API

class ImageFilterPipeline#
property Filters#

Gets a read-only view of the configured filters, in execution order.

Type:

IReadOnlyList<PreprocessingFilter>

Access:

Read-only

Clear()#

Removes every filter from the pipeline.

Returns:

None

RemoveAll(ImageProcessingFilterType type)#

Removes all filters matching the specified type.

Parameters:

type (ImageProcessingFilterType) – The filter type to remove from the pipeline.

Returns:

None

Note

Null filters are automatically excluded during the removal process.

AddFilter(ImageProcessingFilterType type, IImageProcessingFilterOptions options = null, bool replaceExisting = false)#

Adds a filter to the pipeline.

Parameters:
  • type (ImageProcessingFilterType) – The type of filter to add.

  • options (IImageProcessingFilterOptions) – Optional configuration options for the filter. Default is null.

  • replaceExisting (bool) – If true, removes all existing filters of the same type before adding. Default is false.

Returns:

None

AddFilter(PreprocessingFilter filter, bool replaceExisting = false)#

Adds an already constructed PreprocessingFilter.

Parameters:
  • filter (PreprocessingFilter) – The preprocessing filter to add to the pipeline.

  • replaceExisting (bool) – If true, removes all existing filters of the same type before adding. Default is false.

Raises:

ArgumentNullException – Thrown when filter is null.

Returns:

None

AddDeskew(double minAngle = DeskewFilterOptions.DEFAULT_TILT_CORRECTION_ANGLE_THRESHOLD, bool replaceExisting = true)#

Adds a deskew filter to the pipeline.

Parameters:
  • minAngle (double) – Minimum angle in degrees required to apply correction. Default is the default tilt correction angle threshold.

  • replaceExisting (bool) – If true, removes all existing deskew filters before adding. Default is true.

Raises:

ArgumentOutOfRangeException – Thrown when minAngle is negative.

Returns:

None

AddDilation(bool replaceExisting = false)#

Adds a dilation filter to the pipeline.

Parameters:

replaceExisting (bool) – If true, removes all existing dilation filters before adding. Default is false.

Returns:

None

AddRemoveVerticalLines(bool replaceExisting = true)#

Adds a remove vertical lines filter to the pipeline.

Parameters:

replaceExisting (bool) – If true, removes all existing remove vertical lines filters before adding. Default is true.

Returns:

None

AddRemoveHoriziontalLines(bool replaceExisting = true)#

Adds a remove horizontal lines filter to the pipeline.

Parameters:

replaceExisting (bool) – If true, removes all existing remove horizontal lines filters before adding. Default is true.

Returns:

None

AddMedian(int blockSize, bool replaceExisting = false)#

Adds a median filter to the pipeline.

Parameters:
  • blockSize (int) – Size of the median filter kernel. Must be positive.

  • replaceExisting (bool) – If true, removes all existing median filters before adding. Default is false.

Raises:

ArgumentOutOfRangeException – Thrown when blockSize is not positive.

Returns:

None

AddGamma(double gamma, bool replaceExisting = true)#

Adds a gamma correction filter to the pipeline.

Parameters:
  • gamma (double) – Gamma correction value. Must be greater than zero. Values less than 1.0 darken the image, values greater than 1.0 brighten it.

  • replaceExisting (bool) – If true, removes all existing gamma filters before adding. Default is true.

Raises:

ArgumentOutOfRangeException – Thrown when gamma is not greater than zero.

Returns:

None

AddContrast(int contrast, bool replaceExisting = true)#

Adds a contrast adjustment filter to the pipeline.

Parameters:
  • contrast (int) – Contrast adjustment level from -100 to +100. 0 means no change.

  • replaceExisting (bool) – If true, removes all existing contrast filters before adding. Default is true.

Returns:

None

AddGrayscale(bool replaceExisting = true)#

Adds a grayscale conversion filter to the pipeline.

Parameters:

replaceExisting (bool) – If true, removes all existing grayscale filters before adding. Default is true.

Returns:

None

AddInvert(bool replaceExisting = true)#

Adds a color inversion filter to the pipeline.

Parameters:

replaceExisting (bool) – If true, removes all existing invert filters before adding. Default is true.

Returns:

None

AddScale(double scaleFactor, SKFilterQuality quality = SKFilterQuality.High, bool replaceExisting = false)#

Adds a scale filter to the pipeline.

Parameters:
  • scaleFactor (double) – Scale factor (e.g., 0.5 for half size, 2.0 for double size). Must be greater than zero.

  • quality (SKFilterQuality) – Filter quality for scaling interpolation. Default is High.

  • replaceExisting (bool) – If true, removes all existing scale filters before adding. Default is false.

Raises:

ArgumentOutOfRangeException – Thrown when scaleFactor is not greater than zero.

Returns:

None

AddScaleFit(int maxDimension, SKFilterQuality quality = SKFilterQuality.High, bool replaceExisting = true)#

Adds a scale-to-fit filter to the pipeline.

Parameters:
  • maxDimension (int) – Maximum width or height in pixels. Must be greater than zero.

  • quality (SKFilterQuality) – Filter quality for scaling interpolation. Default is High.

  • replaceExisting (bool) – If true, removes all existing fit filters before adding. Default is true.

Raises:

ArgumentOutOfRangeException – Thrown when maxDimension is not greater than zero.

Returns:

None

Note

The image will be scaled to fit within a square of maxDimension * maxDimension pixels while maintaining aspect ratio.

Apply(ref SKBitmap image)#

Applies the configured filters to the supplied image.

Parameters:

image (SKBitmap) – The image to process. Will be replaced with the processed image.

Returns:

None (modifies image in place via ref parameter)

Note

Filters are applied sequentially in the order they were added to the pipeline.