See the Remarks section for details and some image examples.
KGySoft.Drawing.ImagingErrorDiffusionDitherer
Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 5.3.0
The ErrorDiffusionDitherer type exposes the following members.
Name | Description | |
---|---|---|
![]() ![]() | ErrorDiffusionDitherer |
Initializes a new instance of the ErrorDiffusionDitherer class using the specified matrix, divisor and matrixFirstPixelIndex.
See the Examples section for some examples. |
Name | Description | |
---|---|---|
![]() ![]() ![]() | Atkinson |
Gets an ErrorDiffusionDitherer instance using the filter used by the Apple programmer Bill Atkinson.
Uses a 4x3 matrix of only 6 effective values, and propagates only the 75% of the quantization error, which may cause
total loss of details of light and dark areas (result may seem under- or overexposed) whereas midtones have higher contrast
and preserve details better.
See the Examples section for some examples. |
![]() ![]() ![]() | Burkes |
Gets an ErrorDiffusionDitherer instance using the filter proposed by D. Burkes in 1988.
Uses a 5x2 matrix, which is actually the same as the first two lines of the matrix used by the Stucki filter.
See the Examples section for some examples. |
![]() ![]() ![]() | FloydSteinberg |
Gets an ErrorDiffusionDitherer instance using the original filter proposed by Floyd and Steinberg in 1975 when they came out with the idea of error diffusion dithering.
Uses a small, 3x2 matrix so the processing is somewhat faster than by the other alternatives.
See the Examples section for some examples. |
![]() ![]() ![]() | JarvisJudiceNinke |
Gets an ErrorDiffusionDitherer instance using the filter proposed by Jarvis, Judice and Ninke in 1976.
Uses a 5x3 matrix so the processing is slower than by the original Floyd-Steinberg filter but distributes errors in a wider range.
See the Examples section for some examples. |
![]() ![]() ![]() | Sierra2 |
Gets an ErrorDiffusionDitherer instance using the two-line filter proposed by Frankie Sierra in 1990.
Uses a 5x2 matrix so this somewhat faster than the three-line version and still provides a similar quality.
See the Examples section for some examples. |
![]() ![]() ![]() | Sierra3 |
Gets an ErrorDiffusionDitherer instance using the three-line filter proposed by Frankie Sierra in 1989.
Uses a 5x3 matrix so this is the slowest Sierra filter but this disperses errors to the furthest among them.
See the Examples section for some examples. |
![]() ![]() ![]() | SierraLite |
Gets an ErrorDiffusionDitherer instance using a small two-line filter proposed by Frankie Sierra.
Uses a 3x2 matrix so it has the same performance as the Floyd-Steinberg algorithm and also produces a quite similar result.
See the Examples section for some examples. |
![]() ![]() ![]() | StevensonArce |
Gets an ErrorDiffusionDitherer instance using the hexagonal filter proposed by Stevenson and Arce in 1985.
Uses a fairly large, 7x4 matrix, but due to the hexagonal arrangement of the coefficients the processing performance is comparable to a rectangular 5x3 matrix.
See the Examples section for some examples. |
![]() ![]() ![]() | Stucki |
Gets an ErrorDiffusionDitherer instance using the filter proposed by P. Stucki in 1981.
Uses a 5x3 matrix so the processing is slower than by the original Floyd-Steinberg filter but distributes errors in a wider range.
See the Examples section for some examples. |
Name | Description | |
---|---|---|
![]() ![]() | ConfigureErrorDiffusionMode |
Gets a new ErrorDiffusionDitherer instance that has the specified error diffusion mode.
See the Remarks section for details. |
![]() ![]() | ConfigureProcessingDirection |
Gets a new ErrorDiffusionDitherer instance that has the specified processing direction.
See the Remarks section for details. |
The constructor can be used to create an error diffusion ditherer using a custom matrix.
Use the static properties to obtain an instance with predefined parameters.
The ErrorDiffusionDitherer class uses an adaptive dithering technique, which disperses the quantization error of each pixels to the neighboring ones. Thereby the strength of the dithering is automatically adjusted by the algorithm itself, which provides good results also for palettes with uneven color distribution (which is not the case for ordered dithering, for example).
As the dithered result of a pixel depends on the already processed pixels, the ErrorDiffusionDitherer does not support parallel processing, which makes it slower than most of the other dithering methods.
The following table demonstrates the effect of the dithering:
Original image | Quantized image |
---|---|
|
|
|
|
Calculation of the quantization error may happen in two ways. The publicly available algorithms usually calculate the error for each color channels, which usually provides good results with color palettes. However, when quantizing color images with a black and white or grayscale palette, this approach may fail. For example, if the quantizer returns black for a fully saturated blue pixel, the quantization error is zero on the red and green channels and 100% on the blue channel. The problem is that this error cannot be propagated to the neighboring pixels if they have the same color because adding any more blue to already fully saturated blue pixels will not change anything. Therefore, the ErrorDiffusionDitherer can propagate quantization error by brightness based on human perception, which is more appropriate for palettes with grayscale colors. The ErrorDiffusionDitherer tries to auto detect the strategy for each dithering session but this can be overridden by the ConfigureErrorDiffusionMode method.
The following table demonstrates the effect of different strategies:
Original image | Quantized image |
---|---|
|
|
|
|
A typical artifact of error diffusion dithering is a ripple effect, which often appears in homogeneous areas of the dithered image. This is due to the fact that most filters propagate quantization errors mostly to right and down, whereas pixels are processed left-to-right in each line while lines are scanned top-down (raster processing). The ripple effect can be reduced if every second line is processed in the opposite direction (serpentine processing). You can use the ConfigureProcessingDirection method to obtain an ErrorDiffusionDitherer with serpentine processing mode, which processes even lines left-to-right and odd lines right-to-left.
The following table demonstrates the effect of different processing directions:
Original image | Quantized image |
---|---|
|
|
![]() |
---|
See the Examples section of the static properties for more examples. |