ErrorDiffusionDithererConfigureProcessingDirection Method

KGy SOFT Drawing Libraries Help
Gets a new ErrorDiffusionDitherer instance that has the specified processing direction.
See the Remarks section for details.

Namespace:  KGySoft.Drawing.Imaging
Assembly:  KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 5.1.0
Syntax

public ErrorDiffusionDitherer ConfigureProcessingDirection(
	bool serpentine
)

Parameters

serpentine
Type: SystemBoolean
 to process odd lines right-to-left and even lines left-to-right;  to process all lines left-to-right.

Return Value

Type: ErrorDiffusionDitherer
A new ErrorDiffusionDitherer instance that has the specified processing direction.
Remarks

Note Note
This method always returns a new ErrorDiffusionDitherer instance instead of changing the processing direction of the original one. This is required for the static properties so they can return a cached instance.

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).

The following table demonstrates the effect of different processing directions:

Original imageQuantized image

Test image "Cameraman"
Original test image "Cameraman"

Test image "Cameraman" with black and white palette, using Floyd-Steinberg dithering with raster processing
Quantizing with black and white palette and Floyd-Steinberg dithering, using raster processing. The ripple effect is clearly visible on the coat.

Test image "Cameraman" with black and white palette, using Floyd-Steinberg dithering with serpentine processing
Quantizing with black and white palette and Floyd-Steinberg dithering, using serpentine processing. The ripple effect is gone.

Examples

The following example demonstrates how to specify the processing direction for a predefined filter:
C#
// getting a predefined ditherer with serpentine processing:
IDitherer ditherer = ErrorDiffusionDitherer.FloydSteinberg.ConfigureProcessingDirection(serpentine: true);
See Also

Reference