Tip
See the Examples section of the static properties for more examples.
public sealed class OrderedDitherer : IDitherer
Public NotInheritable Class OrderedDitherer
Implements IDitherer
public ref class OrderedDitherer sealed : IDitherer
[<SealedAttribute>]
type OrderedDitherer =
class
interface IDitherer
end
The constructor can be used to create an ordered ditherer using a custom matrix.
Use the static properties to obtain an instance with a predefined pattern. For the best results use the Bayer8x8 or BlueNoise properties. Or you can use the DottedHalftone property for artistic results.
The OrderedDitherer class offers a very fast dithering technique based on an ordered pattern specified in a matrix of bytes. The more different values the matrix has the more number of different patterns can be mapped to the shades of the original pixels. While quantizing lighter and lighter colors, the different patterns appear in the order of the values in the specified matrix.
The following table demonstrates the effect of the dithering:
Original image | Quantized image |
---|---|
|
|
|
|
Unlike in case of the ErrorDiffusionDitherer, ordered dithering does not adjust strength to the quantization error of a pixel but simply uses the specified matrix values based on pixel coordinates to determine the quantized result. Therefore, a strength can be specified (see the constructor and the ConfigureStrength method), whose ideal value depends on the colors that a quantizer can return. If the strength is too low, then banding may appear in the result in place of gradients in the original image; whereas if the strength is too high, then dithering patterns may appear even in colors without quantization error (overdithering).
Every static property in the OrderedDitherer returns an instance with auto strength, meaning that strength will be calibrated for each dithering session so that neither the black, nor the white colors will suffer from overdithering in the result.
Auto strength can use different calibration strategies. The default strategy is usually correct if the quantizer returns evenly distributed colors. Otherwise, you can apply the Interpolated auto strength mode by the ConfigureAutoStrengthMode method that calibrates the strength both for the black and white colors and uses a dynamic strength to each pixel based on its brightness. If none of the auto strength modes provide the desired result you can obtain an OrderedDitherer instance with custom strength by the ConfigureStrength method.
The following table demonstrates the effect of different strengths:
Original image | Quantized image |
---|---|
|
|
OrderedDitherer | Initializes a new instance of the OrderedDitherer class using the specified matrix and strength. |
Bayer2x2 | Gets an OrderedDitherer using the standard Bayer 2x2 matrix. |
Bayer3x3 | Gets an OrderedDitherer using the standard Bayer 3x3 matrix. |
Bayer4x4 | Gets an OrderedDitherer using the standard Bayer 4x4 matrix. |
Bayer8x8 | Gets an OrderedDitherer using the standard Bayer 8x8 matrix. |
BlueNoise | Gets an OrderedDitherer using a fixed 64x64 blue noise pattern of 256 different values. |
DottedHalftone | Gets an OrderedDitherer using a 8x8 matrix of a dotted halftone pattern. |
ConfigureAutoStrengthMode |
Gets a new OrderedDitherer instance that uses auto strength using the specified autoStrengthMode.
See the Remarks section of the ConfigureStrength method for details and image examples. |
ConfigureStrength | Gets a new OrderedDitherer instance that has the specified dithering strength. |
InitializeAsync |
Gets an IDitheringSession instance potentially asynchronously that can be used to dither the result of the specified IQuantizingSession
applied to the specified source.
If ditherer is a known ditherer that can be evaluated quickly, then this method might be executed synchronously.
This method is available in.NET Framework 4.0 and above. (Defined by DithererExtensions) |