From d4a8944cfe6e003311c93633382c45469b3dc61a Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Thu, 19 Dec 2024 23:22:41 +0100 Subject: [PATCH] Moved MeanShift to IMagickImageCreateOperations. --- src/Magick.NET.Core/IMagickImage.cs | 28 ------------------- .../IMagickImageCreateOperations.cs | 28 +++++++++++++++++++ src/Magick.NET/MagickImage.CloneMutator.cs | 12 ++++++++ src/Magick.NET/MagickImage.cs | 22 +++++++++++---- src/Magick.NET/Native/MagickImage.cs | 3 +- 5 files changed, 58 insertions(+), 35 deletions(-) diff --git a/src/Magick.NET.Core/IMagickImage.cs b/src/Magick.NET.Core/IMagickImage.cs index 9ed955bad1..245c90f0cc 100644 --- a/src/Magick.NET.Core/IMagickImage.cs +++ b/src/Magick.NET.Core/IMagickImage.cs @@ -1309,34 +1309,6 @@ public partial interface IMagickImage : IMagickImageCreateOperations, IDisposabl /// Thrown when an error is raised by ImageMagick. void Lower(uint size); - /// - /// Delineate arbitrarily shaped clusters in the image. - /// - /// The width and height of the pixels neighborhood. - void MeanShift(uint size); - - /// - /// Delineate arbitrarily shaped clusters in the image. - /// - /// The width and height of the pixels neighborhood. - /// The color distance. - void MeanShift(uint size, Percentage colorDistance); - - /// - /// Delineate arbitrarily shaped clusters in the image. - /// - /// The width of the pixels neighborhood. - /// The height of the pixels neighborhood. - void MeanShift(uint width, uint height); - - /// - /// Delineate arbitrarily shaped clusters in the image. - /// - /// The width of the pixels neighborhood. - /// The height of the pixels neighborhood. - /// The color distance. - void MeanShift(uint width, uint height, Percentage colorDistance); - /// /// Filter image by replacing each pixel component with the median color in a circular neighborhood. /// diff --git a/src/Magick.NET.Core/IMagickImageCreateOperations.cs b/src/Magick.NET.Core/IMagickImageCreateOperations.cs index bb8c88e63d..09a93ddbcb 100644 --- a/src/Magick.NET.Core/IMagickImageCreateOperations.cs +++ b/src/Magick.NET.Core/IMagickImageCreateOperations.cs @@ -696,6 +696,34 @@ public interface IMagickImageCreateOperations /// Thrown when an error is raised by ImageMagick. void Magnify(); + /// + /// Delineate arbitrarily shaped clusters in the image. + /// + /// The width and height of the pixels neighborhood. + void MeanShift(uint size); + + /// + /// Delineate arbitrarily shaped clusters in the image. + /// + /// The width and height of the pixels neighborhood. + /// The color distance. + void MeanShift(uint size, Percentage colorDistance); + + /// + /// Delineate arbitrarily shaped clusters in the image. + /// + /// The width of the pixels neighborhood. + /// The height of the pixels neighborhood. + void MeanShift(uint width, uint height); + + /// + /// Delineate arbitrarily shaped clusters in the image. + /// + /// The width of the pixels neighborhood. + /// The height of the pixels neighborhood. + /// The color distance. + void MeanShift(uint width, uint height, Percentage colorDistance); + /// /// Resize image to specified size. /// diff --git a/src/Magick.NET/MagickImage.CloneMutator.cs b/src/Magick.NET/MagickImage.CloneMutator.cs index 54532ac4dc..08a1ee4a08 100644 --- a/src/Magick.NET/MagickImage.CloneMutator.cs +++ b/src/Magick.NET/MagickImage.CloneMutator.cs @@ -386,6 +386,18 @@ public void LiquidRescale(Percentage percentageWidth, Percentage percentageHeigh public void Magnify() => SetResult(NativeMagickImage.Magnify()); + public void MeanShift(uint size) + => MeanShift(size, size); + + public void MeanShift(uint size, Percentage colorDistance) + => MeanShift(size, size, colorDistance); + + public void MeanShift(uint width, uint height) + => MeanShift(width, height, new Percentage(10)); + + public void MeanShift(uint width, uint height, Percentage colorDistance) + => SetResult(NativeMagickImage.MeanShift(width, height, PercentageHelper.ToQuantum(nameof(colorDistance), colorDistance))); + public void LiquidRescale(Percentage percentageWidth, Percentage percentageHeight, double deltaX, double rigidity) { var geometry = new MagickGeometry(percentageWidth, percentageHeight); diff --git a/src/Magick.NET/MagickImage.cs b/src/Magick.NET/MagickImage.cs index d429d0c0b8..511fa3ca39 100644 --- a/src/Magick.NET/MagickImage.cs +++ b/src/Magick.NET/MagickImage.cs @@ -4057,7 +4057,7 @@ public void Lower(uint size) /// /// Thrown when an error is raised by ImageMagick. public void Magnify() - { + { using var mutator = new Mutator(_nativeInstance); mutator.Magnify(); } @@ -4067,7 +4067,10 @@ public void Magnify() /// /// The width and height of the pixels neighborhood. public void MeanShift(uint size) - => MeanShift(size, size); + { + using var mutator = new Mutator(_nativeInstance); + mutator.MeanShift(size); + } /// /// Delineate arbitrarily shaped clusters in the image. @@ -4075,7 +4078,10 @@ public void MeanShift(uint size) /// The width and height of the pixels neighborhood. /// The color distance. public void MeanShift(uint size, Percentage colorDistance) - => MeanShift(size, size, colorDistance); + { + using var mutator = new Mutator(_nativeInstance); + mutator.MeanShift(size, colorDistance); + } /// /// Delineate arbitrarily shaped clusters in the image. @@ -4083,7 +4089,10 @@ public void MeanShift(uint size, Percentage colorDistance) /// The width of the pixels neighborhood. /// The height of the pixels neighborhood. public void MeanShift(uint width, uint height) - => MeanShift(width, height, new Percentage(10)); + { + using var mutator = new Mutator(_nativeInstance); + mutator.MeanShift(width, height); + } /// /// Delineate arbitrarily shaped clusters in the image. @@ -4092,7 +4101,10 @@ public void MeanShift(uint width, uint height) /// The height of the pixels neighborhood. /// The color distance. public void MeanShift(uint width, uint height, Percentage colorDistance) - => _nativeInstance.MeanShift(width, height, PercentageHelper.ToQuantum(nameof(colorDistance), colorDistance)); + { + using var mutator = new Mutator(_nativeInstance); + mutator.MeanShift(width, height, colorDistance); + } /// /// Filter image by replacing each pixel component with the median color in a circular neighborhood. diff --git a/src/Magick.NET/Native/MagickImage.cs b/src/Magick.NET/Native/MagickImage.cs index 82100382f7..d892d17f82 100644 --- a/src/Magick.NET/Native/MagickImage.cs +++ b/src/Magick.NET/Native/MagickImage.cs @@ -520,8 +520,7 @@ private unsafe sealed partial class NativeMagickImage : NativeInstance, INativeM public partial IntPtr Magnify(); [Throws] - [SetInstance] - public partial void MeanShift(nuint width, nuint height, double colorDistance); + public partial IntPtr MeanShift(nuint width, nuint height, double colorDistance); [Throws] [SetInstance]