Skip to content

Commit

Permalink
Moved CannyEdge to IMagickImageCreateOperations.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Nov 11, 2024
1 parent d3c1bbe commit bbdf723
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 20 deletions.
16 changes: 0 additions & 16 deletions src/Magick.NET.Core/IMagickImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,22 +369,6 @@ public partial interface IMagickImage : IMagickImageCreateOperations, IDisposabl
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void BrightnessContrast(Percentage brightness, Percentage contrast, Channels channels);

/// <summary>
/// Uses a multi-stage algorithm to detect a wide range of edges in images.
/// </summary>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void CannyEdge();

/// <summary>
/// Uses a multi-stage algorithm to detect a wide range of edges in images.
/// </summary>
/// <param name="radius">The radius of the gaussian smoothing filter.</param>
/// <param name="sigma">The sigma of the gaussian smoothing filter.</param>
/// <param name="lower">Percentage of edge pixels in the lower threshold.</param>
/// <param name="upper">Percentage of edge pixels in the upper threshold.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void CannyEdge(double radius, double sigma, Percentage lower, Percentage upper);

/// <summary>
/// Charcoal effect image (looks like charcoal sketch).
/// </summary>
Expand Down
16 changes: 16 additions & 0 deletions src/Magick.NET.Core/IMagickImageCreateOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,22 @@ public interface IMagickImageCreateOperations
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Border(Percentage percentage);

/// <summary>
/// Uses a multi-stage algorithm to detect a wide range of edges in images.
/// </summary>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void CannyEdge();

/// <summary>
/// Uses a multi-stage algorithm to detect a wide range of edges in images.
/// </summary>
/// <param name="radius">The radius of the gaussian smoothing filter.</param>
/// <param name="sigma">The sigma of the gaussian smoothing filter.</param>
/// <param name="lower">Percentage of edge pixels in the lower threshold.</param>
/// <param name="upper">Percentage of edge pixels in the upper threshold.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void CannyEdge(double radius, double sigma, Percentage lower, Percentage upper);

/// <summary>
/// Resize image to specified size.
/// <para />
Expand Down
6 changes: 6 additions & 0 deletions src/Magick.NET/MagickImage.CloneMutator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ public void Border(uint width, uint height)
public void Border(Percentage percentage)
=> Border((uint)(NativeMagickImage.Width_Get() * percentage), (uint)(NativeMagickImage.Height_Get() * percentage));

public void CannyEdge()
=> CannyEdge(0.0, 1.0, new Percentage(10), new Percentage(30));

public void CannyEdge(double radius, double sigma, Percentage lower, Percentage upper)
=> SetResult(NativeMagickImage.CannyEdge(radius, sigma, lower.ToDouble() / 100, upper.ToDouble() / 100));

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

Expand Down
10 changes: 8 additions & 2 deletions src/Magick.NET/MagickImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,10 @@ public void BrightnessContrast(Percentage brightness, Percentage contrast, Chann
/// </summary>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public void CannyEdge()
=> CannyEdge(0.0, 1.0, new Percentage(10), new Percentage(30));
{
using var mutator = new Mutator(_nativeInstance);
mutator.CannyEdge();
}

/// <summary>
/// Uses a multi-stage algorithm to detect a wide range of edges in images.
Expand All @@ -1451,7 +1454,10 @@ public void CannyEdge()
/// <param name="upper">Percentage of edge pixels in the upper threshold.</param>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public void CannyEdge(double radius, double sigma, Percentage lower, Percentage upper)
=> _nativeInstance.CannyEdge(radius, sigma, lower.ToDouble() / 100, upper.ToDouble() / 100);
{
using var mutator = new Mutator(_nativeInstance);
mutator.CannyEdge(radius, sigma, lower, upper);
}

/// <summary>
/// Charcoal effect image (looks like charcoal sketch).
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 @@ -281,8 +281,7 @@ private unsafe sealed partial class NativeMagickImage : NativeInstance, INativeM
public partial void BrightnessContrast(double brightness, double contrast, Channels channels);

[Throws]
[SetInstance]
public partial void CannyEdge(double radius, double sigma, double lower, double upper);
public partial IntPtr CannyEdge(double radius, double sigma, double lower, double upper);

public partial nuint ChannelOffset(PixelChannel channel);

Expand Down

0 comments on commit bbdf723

Please sign in to comment.