Skip to content

Commit 32996b4

Browse files
committed
No longer throw an argument exception for a negative bias value in AdaptiveThreshold (#1717)
1 parent 51320b7 commit 32996b4

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/Magick.NET/MagickImage.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,11 +1030,7 @@ public void AdaptiveThreshold(uint width, uint height, double bias)
10301030
/// <param name="channels">The channel(s) that should be thresholded.</param>
10311031
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
10321032
public void AdaptiveThreshold(uint width, uint height, double bias, Channels channels)
1033-
{
1034-
Throw.IfNegative(nameof(bias), bias);
1035-
1036-
_nativeInstance.AdaptiveThreshold(width, height, bias, channels);
1037-
}
1033+
=> _nativeInstance.AdaptiveThreshold(width, height, bias, channels);
10381034

10391035
/// <summary>
10401036
/// Local adaptive threshold image.

tests/Magick.NET.Tests/MagickImageTests/TheAdaptiveThresholdMethod.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,29 @@ public partial class MagickImageTests
1111
{
1212
public class TheAdaptiveThresholdMethod
1313
{
14+
#if !Q16HDRI
1415
[Fact]
15-
public void ShouldThrowExceptionWhenBiasIsNegative()
16+
public void ShouldThrowExceptionWhenBiasPercentagetIsNegative()
1617
{
1718
using var image = new MagickImage(Files.MagickNETIconPNG);
18-
Assert.Throws<ArgumentException>("bias", () => image.AdaptiveThreshold(10, 10, -1, Channels.Red));
19+
Assert.Throws<ArgumentException>("biasPercentage", () => image.AdaptiveThreshold(10, 10, new Percentage(-1), Channels.Red));
1920
}
20-
21-
#if !Q16HDRI
21+
#else
2222
[Fact]
23-
public void ShouldThrowExceptionWhenBiasPercentagetIsNegative()
23+
public void ShouldNotThrowExceptionWhenBiasPercentagetIsNegative()
2424
{
2525
using var image = new MagickImage(Files.MagickNETIconPNG);
26-
Assert.Throws<ArgumentException>("biasPercentage", () => image.AdaptiveThreshold(10, 10, new Percentage(-1), Channels.Red));
26+
image.AdaptiveThreshold(10, 10, new Percentage(-1), Channels.Red);
2727
}
2828
#endif
2929

30+
[Fact]
31+
public void ShouldAllowNegativeBiasValue()
32+
{
33+
using var image = new MagickImage(Files.MagickNETIconPNG);
34+
image.AdaptiveThreshold(10, 10, -1, Channels.Red);
35+
}
36+
3037
[Fact]
3138
public void ShouldThresholdTheImage()
3239
{

0 commit comments

Comments
 (0)