Skip to content

AdaptiveThresholdProcessor throws IndexOutOfRangeException #2217

Description

@mjeanrichard

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

2.1.3

Other ImageSharp packages and versions

none

Environment (Operating system, version and so on)

Windows 10

.NET Framework version

.net 6

Description

The attached image produces a IndexOutOfRangeException when mutated with the AdaptiveThresholdProcessor.
It might be because the Image is black and white already?

Steps to Reproduce

  1. Create a new console application
  2. Add the attached image as embedded resource
  3. Put the following code in Program.cs
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors.Binarization;

Stream? stream = typeof(Program).Assembly.GetManifestResourceStream("ConsoleApp1.TestImage.png");
Image<Rgba32> image = await Image.LoadAsync<Rgba32>(stream);
AdaptiveThresholdProcessor p = new();

image.Mutate(i => i.ApplyProcessor(p));
  1. Run

Images

TestImage

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions