Note
This method always returns a new ErrorDiffusionDitherer instance instead of changing the error diffusion mode of the original one.
This is required for the static properties so they can return a cached instance.
public ErrorDiffusionDitherer ConfigureErrorDiffusionMode(
bool? byBrightness
)
Public Function ConfigureErrorDiffusionMode (
byBrightness As Boolean?
) As ErrorDiffusionDitherer
public:
ErrorDiffusionDitherer^ ConfigureErrorDiffusionMode(
Nullable<bool> byBrightness
)
member ConfigureErrorDiffusionMode :
byBrightness : Nullable<bool> -> ErrorDiffusionDitherer
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 following table demonstrates the effect of different strategies:
Original image | Quantized image |
---|---|
|
|
|
|
// getting a predefined ditherer that disperses quantization error by brightness:
IDitherer ditherer = ErrorDiffusionDitherer.FloydSteinberg.ConfigureErrorDiffusionMode(byBrightness: true);