Skip to content

Commit bbdf723

Browse files
committed
Moved CannyEdge to IMagickImageCreateOperations.
1 parent d3c1bbe commit bbdf723

File tree

5 files changed

+31
-20
lines changed

5 files changed

+31
-20
lines changed

src/Magick.NET.Core/IMagickImage.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -369,22 +369,6 @@ public partial interface IMagickImage : IMagickImageCreateOperations, IDisposabl
369369
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
370370
void BrightnessContrast(Percentage brightness, Percentage contrast, Channels channels);
371371

372-
/// <summary>
373-
/// Uses a multi-stage algorithm to detect a wide range of edges in images.
374-
/// </summary>
375-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
376-
void CannyEdge();
377-
378-
/// <summary>
379-
/// Uses a multi-stage algorithm to detect a wide range of edges in images.
380-
/// </summary>
381-
/// <param name="radius">The radius of the gaussian smoothing filter.</param>
382-
/// <param name="sigma">The sigma of the gaussian smoothing filter.</param>
383-
/// <param name="lower">Percentage of edge pixels in the lower threshold.</param>
384-
/// <param name="upper">Percentage of edge pixels in the upper threshold.</param>
385-
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
386-
void CannyEdge(double radius, double sigma, Percentage lower, Percentage upper);
387-
388372
/// <summary>
389373
/// Charcoal effect image (looks like charcoal sketch).
390374
/// </summary>

src/Magick.NET.Core/IMagickImageCreateOperations.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,22 @@ public interface IMagickImageCreateOperations
275275
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
276276
void Border(Percentage percentage);
277277

278+
/// <summary>
279+
/// Uses a multi-stage algorithm to detect a wide range of edges in images.
280+
/// </summary>
281+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
282+
void CannyEdge();
283+
284+
/// <summary>
285+
/// Uses a multi-stage algorithm to detect a wide range of edges in images.
286+
/// </summary>
287+
/// <param name="radius">The radius of the gaussian smoothing filter.</param>
288+
/// <param name="sigma">The sigma of the gaussian smoothing filter.</param>
289+
/// <param name="lower">Percentage of edge pixels in the lower threshold.</param>
290+
/// <param name="upper">Percentage of edge pixels in the upper threshold.</param>
291+
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
292+
void CannyEdge(double radius, double sigma, Percentage lower, Percentage upper);
293+
278294
/// <summary>
279295
/// Resize image to specified size.
280296
/// <para />

src/Magick.NET/MagickImage.CloneMutator.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ public void Border(uint width, uint height)
141141
public void Border(Percentage percentage)
142142
=> Border((uint)(NativeMagickImage.Width_Get() * percentage), (uint)(NativeMagickImage.Height_Get() * percentage));
143143

144+
public void CannyEdge()
145+
=> CannyEdge(0.0, 1.0, new Percentage(10), new Percentage(30));
146+
147+
public void CannyEdge(double radius, double sigma, Percentage lower, Percentage upper)
148+
=> SetResult(NativeMagickImage.CannyEdge(radius, sigma, lower.ToDouble() / 100, upper.ToDouble() / 100));
149+
144150
public void Resize(uint width, uint height)
145151
=> Resize(new MagickGeometry(width, height));
146152

src/Magick.NET/MagickImage.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,10 @@ public void BrightnessContrast(Percentage brightness, Percentage contrast, Chann
14401440
/// </summary>
14411441
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
14421442
public void CannyEdge()
1443-
=> CannyEdge(0.0, 1.0, new Percentage(10), new Percentage(30));
1443+
{
1444+
using var mutator = new Mutator(_nativeInstance);
1445+
mutator.CannyEdge();
1446+
}
14441447

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

14561462
/// <summary>
14571463
/// Charcoal effect image (looks like charcoal sketch).

src/Magick.NET/Native/MagickImage.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,7 @@ private unsafe sealed partial class NativeMagickImage : NativeInstance, INativeM
281281
public partial void BrightnessContrast(double brightness, double contrast, Channels channels);
282282

283283
[Throws]
284-
[SetInstance]
285-
public partial void CannyEdge(double radius, double sigma, double lower, double upper);
284+
public partial IntPtr CannyEdge(double radius, double sigma, double lower, double upper);
286285

287286
public partial nuint ChannelOffset(PixelChannel channel);
288287

0 commit comments

Comments
 (0)