Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion src/Magick.NET.Core/IMagickImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,8 @@ Interlace Interlace
/// Applies a non-linear, edge-preserving, and noise-reducing smoothing filter.
/// </summary>
/// <param name="width">The width of the neighborhood in pixels.</param>
/// <param name="height">The height of the neighborhood in pixels.</param>\
/// <param name="height">The height of the neighborhood in pixels.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void BilateralBlur(int width, int height);

/// <summary>
Expand All @@ -569,6 +570,7 @@ Interlace Interlace
/// <param name="height">The height of the neighborhood in pixels.</param>
/// <param name="intensitySigma">The sigma in the intensity space.</param>
/// <param name="spatialSigma">The sigma in the coordinate space.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void BilateralBlur(int width, int height, double intensitySigma, double spatialSigma);

/// <summary>
Expand Down
16 changes: 8 additions & 8 deletions src/Magick.NET/MagickImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1312,29 +1312,29 @@ public void AutoThreshold(AutoThresholdMethod method)
/// <summary>
/// Applies a non-linear, edge-preserving, and noise-reducing smoothing filter.
/// </summary>
/// <param name="width">The width of the neighborhood in pixels (> 0).</param>
/// <param name="height">The height of the neighborhood in pixels (> 0).</param>
/// <param name="width">The width of the neighborhood in pixels.</param>
/// <param name="height">The height of the neighborhood in pixels.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public void BilateralBlur(int width, int height)
{
Throw.IfFalse(nameof(width), width > 1, "The width must be > 1");
Throw.IfFalse(nameof(height), height > 1, "The height must be > 1");
Throw.IfNegative(nameof(width), width);
Throw.IfNegative(nameof(height), height);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a newline after the Thow's? I do that in the rest of the library.

p.s. I missed that in your other pr...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️

var intensitySigma = Math.Sqrt((width * width) + (height * height));
BilateralBlur(width, height, intensitySigma, intensitySigma * 0.25);
}

/// <summary>
/// Applies a non-linear, edge-preserving, and noise-reducing smoothing filter.
/// </summary>
/// <param name="width">The width of the neighborhood in pixels (> 0).</param>
/// <param name="height">The height of the neighborhood in pixels (> 0).</param>
/// <param name="width">The width of the neighborhood in pixels.</param>
/// <param name="height">The height of the neighborhood in pixels.</param>
/// <param name="intensitySigma">The sigma in the intensity space.</param>
/// <param name="spatialSigma">The sigma in the coordinate space.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public void BilateralBlur(int width, int height, double intensitySigma, double spatialSigma)
{
Throw.IfFalse(nameof(width), width > 1, "The width must be > 1");
Throw.IfFalse(nameof(height), height > 1, "The height must be > 1");
Throw.IfNegative(nameof(width), width);
Throw.IfNegative(nameof(height), height);
_nativeInstance.BilateralBlur(width, height, intensitySigma, spatialSigma);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@ public partial class MagickImageTests
public class TheBilateralBlurMethod
{
[Fact]
public void ShouldThrowExceptionWhenWidthIsLessThanOne()
public void ShouldThrowExceptionWhenWidthIsNegative()
{
using var image = new MagickImage(Files.NoisePNG);
Assert.Throws<ArgumentException>("width", () => image.BilateralBlur(1, 2));
Assert.Throws<ArgumentException>("width", () => image.BilateralBlur(-1, 2));
}

[Fact]
public void ShouldThrowExceptionWhenWidthIsLessThanOneWithLowAndHigh()
public void ShouldThrowExceptionWhenWidthIsNegativeThanOneWithLowAndHigh()
{
using var image = new MagickImage(Files.NoisePNG);
Assert.Throws<ArgumentException>("width", () => image.BilateralBlur(1, 2, 0.1, 0.1));
Assert.Throws<ArgumentException>("width", () => image.BilateralBlur(-1, 2, 0.1, 0.1));
}

[Fact]
public void ShouldThrowExceptionWhenHeightIsLessThanOne()
public void ShouldThrowExceptionWhenHeightIsNegative()
{
using var image = new MagickImage(Files.NoisePNG);
Assert.Throws<ArgumentException>("height", () => image.BilateralBlur(2, 1));
Assert.Throws<ArgumentException>("height", () => image.BilateralBlur(2, -1));
}

[Fact]
public void ShouldThrowExceptionWhenHeightIsLessThanOneWithLowAndHigh()
public void ShouldThrowExceptionWhenHeightIsNegativeWithLowAndHigh()
{
using var image = new MagickImage(Files.NoisePNG);
Assert.Throws<ArgumentException>("height", () => image.BilateralBlur(2, 1, 0.1, 0.1));
Assert.Throws<ArgumentException>("height", () => image.BilateralBlur(2, -1, 0.1, 0.1));
}

[Fact]
Expand Down