Skip to content

Unexpected artefacts when quantizing images #2469

@BrentCoxEscentual

Description

@BrentCoxEscentual

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

ImageSharp version

3.0.1

Other ImageSharp packages and versions

NA

Environment (Operating system, version and so on)

Windows, Linux

.NET Framework version

6

Description

We are currently experiencing strange artifacts when quantizing images.

Steps to Reproduce

Load image.
Quantize the image using KnownQuantizers.Wu
The saved output will have unexpected artifacts.

Below is a test program I created to replicate the problem. It does not happen on all images only on some. I have attached a image that it happens on. If you compare the original to the quantized version you will note a grey triangular artifact from right of centre to the right middle of the image.

using SixLabors.ImageSharp.Formats.Png;

using (var i = Image.Load("Orig.png"))
{
    i.Mutate(x => x.Quantize(KnownQuantizers.Wu));
    await i.SaveAsPngAsync("Resized.png", new PngEncoder()
    {
        CompressionLevel = PngCompressionLevel.BestCompression,
    });
}

Original Image
Orig
Quantized Image
Resized

Images

Orig
Resized

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions