Skip to content

Commit

Permalink
Moved BilateralBlur to IMagickImageCreateOperations.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Nov 9, 2024
1 parent fda09a0 commit 4f72fcc
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 23 deletions.
18 changes: 0 additions & 18 deletions src/Magick.NET.Core/IMagickImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,24 +331,6 @@ public partial interface IMagickImage : IMagickImageCreateOperations, IDisposabl
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
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.</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(uint width, uint height);

/// <summary>
/// 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="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(uint width, uint height, double intensitySigma, double spatialSigma);

/// <summary>
/// Forces all pixels below the threshold into black while leaving all pixels at or above
/// the threshold unchanged.
Expand Down
18 changes: 18 additions & 0 deletions src/Magick.NET.Core/IMagickImageCreateOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,24 @@ public interface IMagickImageCreateOperations
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void AutoOrient();

/// <summary>
/// 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>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void BilateralBlur(uint width, uint height);

/// <summary>
/// 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="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(uint width, uint height, double intensitySigma, double spatialSigma);

/// <summary>
/// Resize image to specified size.
/// <para />
Expand Down
9 changes: 9 additions & 0 deletions src/Magick.NET/MagickImage.CloneMutator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ public void AffineTransform(IDrawableAffine affineMatrix)
public void AutoOrient()
=> SetResult(NativeMagickImage.AutoOrient());

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

public void BilateralBlur(uint width, uint height, double intensitySigma, double spatialSigma)
=> SetResult(NativeMagickImage.BilateralBlur(width, height, intensitySigma, spatialSigma));

public void Resize(uint width, uint height)
=> Resize(new MagickGeometry(width, height));

Expand Down
9 changes: 6 additions & 3 deletions src/Magick.NET/MagickImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1270,8 +1270,8 @@ public void AutoThreshold(AutoThresholdMethod method)
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public void BilateralBlur(uint width, uint height)
{
var intensitySigma = Math.Sqrt((width * width) + (height * height));
BilateralBlur(width, height, intensitySigma, intensitySigma * 0.25);
using var mutator = new Mutator(_nativeInstance);
mutator.BilateralBlur(width, height);
}

/// <summary>
Expand All @@ -1283,7 +1283,10 @@ public void BilateralBlur(uint width, uint height)
/// <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(uint width, uint height, double intensitySigma, double spatialSigma)
=> _nativeInstance.BilateralBlur(width, height, intensitySigma, spatialSigma);
{
using var mutator = new Mutator(_nativeInstance);
mutator.BilateralBlur(width, height, intensitySigma, spatialSigma);
}

/// <summary>
/// Forces all pixels below the threshold into black while leaving all pixels at or above
Expand Down
3 changes: 1 addition & 2 deletions src/Magick.NET/Native/MagickImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ private unsafe sealed partial class NativeMagickImage : NativeInstance, INativeM
public partial void AutoThreshold(AutoThresholdMethod method);

[Throws]
[SetInstance]
public partial void BilateralBlur(nuint width, nuint height, double intensitySigma, double spatialSigma);
public partial IntPtr BilateralBlur(nuint width, nuint height, double intensitySigma, double spatialSigma);

[Throws]
public partial void BlackThreshold(string threshold, Channels channels);
Expand Down

0 comments on commit 4f72fcc

Please sign in to comment.