SceneConvolveMatrixPrimitive Class

A primitive that computes each pixel from the pixels around it with a matrix of weights: feConvolveMatrix of SVG.

public sealed class SceneConvolveMatrixPrimitive : SceneFilterPrimitive

Remarks

With a matrix of orderX columns and orderY rows and a target (tx, ty), a pixel of the result is sum(I(x - tx + j, y - ty + i) K(orderX - j - 1, orderY - i - 1)) / divisor + bias. The weights are one pixel of the rendered image apart.

Inheritance
SceneFilterPrimitive SceneConvolveMatrixPrimitive

Constructors

NameDescription
SceneConvolveMatrixPrimitive(int, int, ReadOnlySpan<double>)Initializes a new instance of the SceneConvolveMatrixPrimitive class.

SceneConvolveMatrixPrimitive(int, int, ReadOnlySpan<double>)

SceneConvolveMatrixPrimitive.cs

Initializes a new instance of the SceneConvolveMatrixPrimitive class.

public SceneConvolveMatrixPrimitive(int orderX, int orderY, params scoped ReadOnlySpan<double> kernel)

Parameters

orderX int
The number of columns of the matrix: order. Must be between 1 and 255.
orderY int
The number of rows of the matrix. Must be between 1 and 255.
kernel ReadOnlySpan<double>
The weights, row by row: kernelMatrix. They are copied.

Exceptions

ArgumentOutOfRangeException
An order is not between 1 and 255.
ArgumentException
The number of weights is not orderX orderY, or a weight is not a finite number.

Properties

NameDescription
BiasGets what is added to every component of the result: bias.
DivisorGets what the sum is divided by: divisor. The default is null: the sum of the weights, or 1 when it is zero.
EdgeModeGets what is read beyond the edges of the input: edgeMode. The default is SceneFilterEdgeMode.Duplicate, as in SVG.
InputGets the input: in.
KernelGets the weights, row by row.
OrderXGets the number of columns of the matrix.
OrderYGets the number of rows of the matrix.
PreserveAlphaGets a value indicating whether the colors are computed without their alpha, which each pixel keeps: preserveAlpha.
TargetXGets the column of the matrix that is on the pixel: targetX. The default is null: floor(orderX / 2).
TargetYGets the row of the matrix that is on the pixel: targetY. The default is null: floor(orderY / 2).

Gets what is added to every component of the result: bias.

public double Bias { get; init; }

Property value

double

Exceptions

ArgumentException
The value is not a finite number.

Gets what the sum is divided by: divisor. The default is null: the sum of the weights, or 1 when it is zero.

public double? Divisor { get; init; }

Property value

double?

Exceptions

ArgumentException
The value is zero or not a finite number.

Gets what is read beyond the edges of the input: edgeMode. The default is SceneFilterEdgeMode.Duplicate, as in SVG.

public SceneFilterEdgeMode EdgeMode { get; init; }

Property value

SceneFilterEdgeMode

Exceptions

ArgumentOutOfRangeException
The value is not a defined SceneFilterEdgeMode.

Gets the input: in.

public SceneFilterInput Input { get; init; }

Property value

SceneFilterInput

Gets the weights, row by row.

public IReadOnlyList<double> Kernel { get; }

Property value

IReadOnlyList<double>

Gets the number of columns of the matrix.

public int OrderX { get; }

Property value

int

Gets the number of rows of the matrix.

public int OrderY { get; }

Property value

int

Gets a value indicating whether the colors are computed without their alpha, which each pixel keeps: preserveAlpha.

public bool PreserveAlpha { get; init; }

Property value

bool

Gets the column of the matrix that is on the pixel: targetX. The default is null: floor(orderX / 2).

public int? TargetX { get; init; }

Property value

int?

Exceptions

ArgumentOutOfRangeException
The value is not a column of the matrix.

Gets the row of the matrix that is on the pixel: targetY. The default is null: floor(orderY / 2).

public int? TargetY { get; init; }

Property value

int?

Exceptions

ArgumentOutOfRangeException
The value is not a row of the matrix.