Class ErrorDiffusionKernel
- Namespace
- Egami.Quantization
- Assembly
- Egami.dll
A custom error-diffusion kernel for Kernel: how much of each pixel's error goes to which neighbours. Row 0 of Weights is the current row, with the current pixel at column Origin; the following rows are the rows below. Only entries to the right of the current pixel on row 0, and every entry below, may be non-zero, since the rest have been mapped already.
public sealed class ErrorDiffusionKernel
- Inheritance
-
ErrorDiffusionKernel
- Inherited Members
Examples
// A custom error-diffusion kernel: half the error to the right, a quarter down and a quarter down-left, at 80% strength,
// scanning every other row backwards.
ErrorDiffusionKernel kernel = new(new[,] { { 0, 0, 2 }, { 1, 1, 0 } }, divisor: 4, origin: 1);
photo.Apply(ops => ops.Quantize(new PaletteOptions { MaxColors = 8, Kernel = kernel, DitherStrength = 0.8f, Serpentine = true }), Ct);
Constructors
ErrorDiffusionKernel(int[,], int, int)
Creates a kernel.
public ErrorDiffusionKernel(int[,] weights, int divisor, int origin)
Parameters
weightsint[,]The weights, at most 8 rows and 16 columns; row 0 is the current row.
divisorintWhat the weights are divided by: their sum spreads the whole error, a larger divisor less of it.
originintThe column of
weightswhere the current pixel is.
Exceptions
- ArgumentNullException
weightsis null.- ArgumentException
The weights are empty, too large or negative, put weight on the current pixel or before it, or sum to more than the divisor.
- ArgumentOutOfRangeException
divisoris less than 1, ororiginis outside the columns.
Properties
Divisor
Gets the divisor.
public int Divisor { get; }
Property Value
Origin
Gets the column of the current pixel.
public int Origin { get; }
Property Value
Weights
Gets a copy of the weights.
public int[,] Weights { get; }
Property Value
- int[,]