Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/Magick.NET/MagickImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ public void AdaptiveSharpen(double radius, double sigma, Channels channels)
/// <param name="height">The height of the pixel neighborhood.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public void AdaptiveThreshold(int width, int height)
=> AdaptiveThreshold(width, height, 0, ImageMagick.Channels.Undefined);
=> AdaptiveThreshold(width, height, 0.0, ImageMagick.Channels.Undefined);

/// <summary>
/// Local adaptive threshold image.
Expand All @@ -1105,7 +1105,7 @@ public void AdaptiveThreshold(int width, int height)
/// <param name="channels">The channel(s) that should be thresholded.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public void AdaptiveThreshold(int width, int height, Channels channels)
=> AdaptiveThreshold(width, height, 0, channels);
=> AdaptiveThreshold(width, height, 0.0, channels);

/// <summary>
/// Local adaptive threshold image.
Expand All @@ -1128,7 +1128,11 @@ public void AdaptiveThreshold(int width, int height, double bias)
/// <param name="channels">The channel(s) that should be thresholded.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public void AdaptiveThreshold(int width, int height, double bias, Channels channels)
=> _nativeInstance.AdaptiveThreshold(width, height, bias, channels);
{
Throw.IfNegative(nameof(width), width);
Throw.IfNegative(nameof(height), height);
_nativeInstance.AdaptiveThreshold(width, height, bias, channels);
}

/// <summary>
/// Local adaptive threshold image.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET.
// Licensed under the Apache License, Version 2.0.

using System;
using ImageMagick;
using Xunit;

Expand All @@ -10,6 +11,20 @@ public partial class MagickImageTests
{
public class TheAdaptiveThresholdMethod
{
[Fact]
public void ShouldThrowExceptionWhenWidthIsNegative()
{
using var image = new MagickImage(Files.MagickNETIconPNG);
Assert.Throws<ArgumentException>("width", () => image.AdaptiveThreshold(-1, 10, 0.0, Channels.Red));
}

[Fact]
public void ShouldThrowExceptionWhenHeightIsNegative()
{
using var image = new MagickImage(Files.MagickNETIconPNG);
Assert.Throws<ArgumentException>("height", () => image.AdaptiveThreshold(10, -1, 0.0, Channels.Red));
}

[Fact]
public void ShouldThresholdTheImage()
{
Expand Down