diff --git a/src/Magick.NET/Native/MagickImage.cs b/src/Magick.NET/Native/MagickImage.cs index 694ab636e3..b401dbf4e7 100644 --- a/src/Magick.NET/Native/MagickImage.cs +++ b/src/Magick.NET/Native/MagickImage.cs @@ -229,7 +229,7 @@ public static class X64 [DllImport(NativeLibrary.X64Name, CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr MagickImage_AdaptiveSharpen(IntPtr Instance, double radius, double sigma, UIntPtr channels, out IntPtr exception); [DllImport(NativeLibrary.X64Name, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr MagickImage_AdaptiveThreshold(IntPtr Instance, UIntPtr width, UIntPtr height, double bias, out IntPtr exception); + public static extern IntPtr MagickImage_AdaptiveThreshold(IntPtr Instance, UIntPtr width, UIntPtr height, double bias, UIntPtr channels, out IntPtr exception); [DllImport(NativeLibrary.X64Name, CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr MagickImage_AddNoise(IntPtr Instance, UIntPtr noiseType, double attenuate, UIntPtr channels, out IntPtr exception); [DllImport(NativeLibrary.X64Name, CallingConvention = CallingConvention.Cdecl)] @@ -560,7 +560,7 @@ public static class X64 [DllImport(NativeLibrary.X64Name, CallingConvention = CallingConvention.Cdecl)] public static extern void MagickImage_Texture(IntPtr Instance, IntPtr image, out IntPtr exception); [DllImport(NativeLibrary.X64Name, CallingConvention = CallingConvention.Cdecl)] - public static extern void MagickImage_Threshold(IntPtr Instance, double threshold, out IntPtr exception); + public static extern void MagickImage_Threshold(IntPtr Instance, double threshold, UIntPtr channels, out IntPtr exception); [DllImport(NativeLibrary.X64Name, CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr MagickImage_Thumbnail(IntPtr Instance, IntPtr geometry, out IntPtr exception); [DllImport(NativeLibrary.X64Name, CallingConvention = CallingConvention.Cdecl)] @@ -779,7 +779,7 @@ public static class X86 [DllImport(NativeLibrary.X86Name, CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr MagickImage_AdaptiveSharpen(IntPtr Instance, double radius, double sigma, UIntPtr channels, out IntPtr exception); [DllImport(NativeLibrary.X86Name, CallingConvention = CallingConvention.Cdecl)] - public static extern IntPtr MagickImage_AdaptiveThreshold(IntPtr Instance, UIntPtr width, UIntPtr height, double bias, out IntPtr exception); + public static extern IntPtr MagickImage_AdaptiveThreshold(IntPtr Instance, UIntPtr width, UIntPtr height, double bias, UIntPtr channels, out IntPtr exception); [DllImport(NativeLibrary.X86Name, CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr MagickImage_AddNoise(IntPtr Instance, UIntPtr noiseType, double attenuate, UIntPtr channels, out IntPtr exception); [DllImport(NativeLibrary.X86Name, CallingConvention = CallingConvention.Cdecl)] @@ -1110,7 +1110,7 @@ public static class X86 [DllImport(NativeLibrary.X86Name, CallingConvention = CallingConvention.Cdecl)] public static extern void MagickImage_Texture(IntPtr Instance, IntPtr image, out IntPtr exception); [DllImport(NativeLibrary.X86Name, CallingConvention = CallingConvention.Cdecl)] - public static extern void MagickImage_Threshold(IntPtr Instance, double threshold, out IntPtr exception); + public static extern void MagickImage_Threshold(IntPtr Instance, double threshold, UIntPtr channels, out IntPtr exception); [DllImport(NativeLibrary.X86Name, CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr MagickImage_Thumbnail(IntPtr Instance, IntPtr geometry, out IntPtr exception); [DllImport(NativeLibrary.X86Name, CallingConvention = CallingConvention.Cdecl)] @@ -2810,7 +2810,7 @@ public void AdaptiveSharpen(double radius, double sigma, Channels channels) CheckException(exception, result); Instance = result; } - public void AdaptiveThreshold(int width, int height, double bias) + public void AdaptiveThreshold(int width, int height, double bias, Channels channels) { IntPtr exception = IntPtr.Zero; IntPtr result; @@ -2818,13 +2818,13 @@ public void AdaptiveThreshold(int width, int height, double bias) if (NativeLibrary.Is64Bit) #endif #if PLATFORM_x64 || PLATFORM_AnyCPU - result = NativeMethods.X64.MagickImage_AdaptiveThreshold(Instance, (UIntPtr)width, (UIntPtr)height, bias, out exception); + result = NativeMethods.X64.MagickImage_AdaptiveThreshold(Instance, (UIntPtr)width, (UIntPtr)height, bias, (UIntPtr)channels, out exception); #endif #if PLATFORM_AnyCPU else #endif #if PLATFORM_x86 || PLATFORM_AnyCPU - result = NativeMethods.X86.MagickImage_AdaptiveThreshold(Instance, (UIntPtr)width, (UIntPtr)height, bias, out exception); + result = NativeMethods.X86.MagickImage_AdaptiveThreshold(Instance, (UIntPtr)width, (UIntPtr)height, bias, (UIntPtr)channels, out exception); #endif CheckException(exception, result); Instance = result; @@ -5948,20 +5948,20 @@ public void Texture(IMagickImage image) #endif CheckException(exception); } - public void Threshold(double threshold) + public void Threshold(double threshold, Channels channels) { IntPtr exception = IntPtr.Zero; #if PLATFORM_AnyCPU if (NativeLibrary.Is64Bit) #endif #if PLATFORM_x64 || PLATFORM_AnyCPU - NativeMethods.X64.MagickImage_Threshold(Instance, threshold, out exception); + NativeMethods.X64.MagickImage_Threshold(Instance, threshold, (UIntPtr)channels, out exception); #endif #if PLATFORM_AnyCPU else #endif #if PLATFORM_x86 || PLATFORM_AnyCPU - NativeMethods.X86.MagickImage_Threshold(Instance, threshold, out exception); + NativeMethods.X86.MagickImage_Threshold(Instance, threshold, (UIntPtr)channels, out exception); #endif CheckException(exception); } diff --git a/src/Magick.NET/Native/MagickImage.json b/src/Magick.NET/Native/MagickImage.json index 1eed483540..b18cbd6198 100644 --- a/src/Magick.NET/Native/MagickImage.json +++ b/src/Magick.NET/Native/MagickImage.json @@ -364,6 +364,10 @@ { "name": "bias", "type": "double" + }, + { + "name": "channels", + "type": "Channels" } ] }, @@ -2615,6 +2619,10 @@ { "name": "threshold", "type": "double" + }, + { + "name": "channels", + "type": "Channels" } ] }, diff --git a/src/Magick.NET/Shared/IMagickImage.cs b/src/Magick.NET/Shared/IMagickImage.cs index b70424859f..6e3c2bc3f6 100644 --- a/src/Magick.NET/Shared/IMagickImage.cs +++ b/src/Magick.NET/Shared/IMagickImage.cs @@ -407,6 +407,16 @@ public partial interface IMagickImage : IEquatable, IComparableThrown when an error is raised by ImageMagick. void AdaptiveThreshold(int width, int height); + /// + /// Local adaptive threshold image. + /// http://www.dai.ed.ac.uk/HIPR2/adpthrsh.htm. + /// + /// The width of the pixel neighborhood. + /// The height of the pixel neighborhood. + /// The channel(s) that should be thresholded. + /// Thrown when an error is raised by ImageMagick. + void AdaptiveThreshold(int width, int height, Channels channels); + /// /// Local adaptive threshold image. /// http://www.dai.ed.ac.uk/HIPR2/adpthrsh.htm. @@ -417,6 +427,17 @@ public partial interface IMagickImage : IEquatable, IComparableThrown when an error is raised by ImageMagick. void AdaptiveThreshold(int width, int height, double bias); + /// + /// Local adaptive threshold image. + /// http://www.dai.ed.ac.uk/HIPR2/adpthrsh.htm. + /// + /// The width of the pixel neighborhood. + /// The height of the pixel neighborhood. + /// Constant to subtract from pixel neighborhood mean (+/-)(0-QuantumRange). + /// The channel(s) that should be thresholded. + /// Thrown when an error is raised by ImageMagick. + void AdaptiveThreshold(int width, int height, double bias, Channels channels); + /// /// Local adaptive threshold image. /// http://www.dai.ed.ac.uk/HIPR2/adpthrsh.htm. @@ -427,6 +448,17 @@ public partial interface IMagickImage : IEquatable, IComparableThrown when an error is raised by ImageMagick. void AdaptiveThreshold(int width, int height, Percentage biasPercentage); + /// + /// Local adaptive threshold image. + /// http://www.dai.ed.ac.uk/HIPR2/adpthrsh.htm. + /// + /// The width of the pixel neighborhood. + /// The height of the pixel neighborhood. + /// Constant to subtract from pixel neighborhood mean. + /// The channel(s) that should be thresholded. + /// Thrown when an error is raised by ImageMagick. + void AdaptiveThreshold(int width, int height, Percentage biasPercentage, Channels channels); + /// /// Add noise to image with the specified noise type. /// diff --git a/src/Magick.NET/Shared/MagickImage.cs b/src/Magick.NET/Shared/MagickImage.cs index 497b1641b0..f50c5ceb9f 100644 --- a/src/Magick.NET/Shared/MagickImage.cs +++ b/src/Magick.NET/Shared/MagickImage.cs @@ -1022,7 +1022,27 @@ public void AdaptiveResize(MagickGeometry geometry) /// The width of the pixel neighborhood. /// The height of the pixel neighborhood. /// Thrown when an error is raised by ImageMagick. - public void AdaptiveThreshold(int width, int height) => AdaptiveThreshold(width, height, 0); + public void AdaptiveThreshold(int width, int height) => AdaptiveThreshold(width, height, 0, ImageMagick.Channels.All); + + /// + /// Local adaptive threshold image. + /// http://www.dai.ed.ac.uk/HIPR2/adpthrsh.htm. + /// + /// The width of the pixel neighborhood. + /// The height of the pixel neighborhood. + /// The channel(s) that should be thresholded. + /// Thrown when an error is raised by ImageMagick. + public void AdaptiveThreshold(int width, int height, Channels channels) => AdaptiveThreshold(width, height, 0, channels); + + /// + /// Local adaptive threshold image. + /// http://www.dai.ed.ac.uk/HIPR2/adpthrsh.htm. + /// + /// The width of the pixel neighborhood. + /// The height of the pixel neighborhood. + /// Constant to subtract from pixel neighborhood mean (+/-)(0-QuantumRange). + /// Thrown when an error is raised by ImageMagick. + public void AdaptiveThreshold(int width, int height, double bias) => AdaptiveThreshold(width, height, bias, ImageMagick.Channels.All); /// /// Local adaptive threshold image. @@ -1031,8 +1051,19 @@ public void AdaptiveResize(MagickGeometry geometry) /// The width of the pixel neighborhood. /// The height of the pixel neighborhood. /// Constant to subtract from pixel neighborhood mean (+/-)(0-QuantumRange). + /// The channel(s) that should be thresholded. + /// Thrown when an error is raised by ImageMagick. + public void AdaptiveThreshold(int width, int height, double bias, Channels channels) => _nativeInstance.AdaptiveThreshold(width, height, bias, channels); + + /// + /// Local adaptive threshold image. + /// http://www.dai.ed.ac.uk/HIPR2/adpthrsh.htm. + /// + /// The width of the pixel neighborhood. + /// The height of the pixel neighborhood. + /// Constant to subtract from pixel neighborhood mean. /// Thrown when an error is raised by ImageMagick. - public void AdaptiveThreshold(int width, int height, double bias) => _nativeInstance.AdaptiveThreshold(width, height, bias); + public void AdaptiveThreshold(int width, int height, Percentage biasPercentage) => AdaptiveThreshold(width, height, biasPercentage.ToQuantum(), ImageMagick.Channels.All); /// /// Local adaptive threshold image. @@ -1041,8 +1072,9 @@ public void AdaptiveResize(MagickGeometry geometry) /// The width of the pixel neighborhood. /// The height of the pixel neighborhood. /// Constant to subtract from pixel neighborhood mean. + /// The channel(s) that should be thresholded. /// Thrown when an error is raised by ImageMagick. - public void AdaptiveThreshold(int width, int height, Percentage biasPercentage) => AdaptiveThreshold(width, height, biasPercentage.ToQuantum()); + public void AdaptiveThreshold(int width, int height, Percentage biasPercentage, Channels channels) => AdaptiveThreshold(width, height, biasPercentage.ToQuantum(), channels); /// /// Add noise to image with the specified noise type. @@ -5580,7 +5612,15 @@ public void Texture(IMagickImage image) /// /// The threshold percentage. /// Thrown when an error is raised by ImageMagick. - public void Threshold(Percentage percentage) => _nativeInstance.Threshold(percentage.ToQuantum()); + public void Threshold(Percentage percentage) => Threshold(percentage, ImageMagick.Channels.All); + + /// + /// Threshold image. + /// + /// The threshold percentage. + /// The channel(s) that should be thresholded. + /// Thrown when an error is raised by ImageMagick. + public void Threshold(Percentage percentage, Channels channels) => _nativeInstance.Threshold(percentage.ToQuantum(), channels); /// /// Resize image to thumbnail size.