From cb4c521f4c730f69a84d85656805d5d74ee4eb2e Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Thu, 2 Jan 2025 18:05:45 +0100 Subject: [PATCH] Moved WaveletDenoise to IMagickImageCreateOperations. --- src/Magick.NET.Core/IMagickImage.cs | 13 ------------ .../IMagickImageCreateOperations.cs | 13 ++++++++++++ ...gickImageCreateOperations{TQuantumType}.cs | 13 ++++++++++++ .../IMagickImage{TQuantumType}.cs | 13 ------------ src/Magick.NET/MagickImage.CloneMutator.cs | 12 +++++++++++ src/Magick.NET/MagickImage.cs | 20 +++++++++++++++---- src/Magick.NET/Native/MagickImage.cs | 5 ++--- 7 files changed, 56 insertions(+), 33 deletions(-) diff --git a/src/Magick.NET.Core/IMagickImage.cs b/src/Magick.NET.Core/IMagickImage.cs index cf3552ccf0..5f49a03aba 100644 --- a/src/Magick.NET.Core/IMagickImage.cs +++ b/src/Magick.NET.Core/IMagickImage.cs @@ -2220,19 +2220,6 @@ public partial interface IMagickImage : IMagickImageCreateOperations, IDisposabl /// Thrown when an error is raised by ImageMagick. void Trim(Percentage percentBackground); - /// - /// Removes noise from the image using a wavelet transform. - /// - /// The threshold for smoothing. - void WaveletDenoise(Percentage thresholdPercentage); - - /// - /// Removes noise from the image using a wavelet transform. - /// - /// The threshold for smoothing. - /// Attenuate the smoothing threshold. - void WaveletDenoise(Percentage thresholdPercentage, double softness); - /// /// Apply a white balancing to an image according to a grayworld assumption in the LAB colorspace. /// diff --git a/src/Magick.NET.Core/IMagickImageCreateOperations.cs b/src/Magick.NET.Core/IMagickImageCreateOperations.cs index 2f37e1772b..0fef1ce4d9 100644 --- a/src/Magick.NET.Core/IMagickImageCreateOperations.cs +++ b/src/Magick.NET.Core/IMagickImageCreateOperations.cs @@ -1278,4 +1278,17 @@ public interface IMagickImageCreateOperations /// The length of the wave. /// Thrown when an error is raised by ImageMagick. void Wave(PixelInterpolateMethod method, double amplitude, double length); + + /// + /// Removes noise from the image using a wavelet transform. + /// + /// The threshold for smoothing. + void WaveletDenoise(Percentage thresholdPercentage); + + /// + /// Removes noise from the image using a wavelet transform. + /// + /// The threshold for smoothing. + /// Attenuate the smoothing threshold. + void WaveletDenoise(Percentage thresholdPercentage, double softness); } diff --git a/src/Magick.NET.Core/IMagickImageCreateOperations{TQuantumType}.cs b/src/Magick.NET.Core/IMagickImageCreateOperations{TQuantumType}.cs index a2d2957a29..38d71ee5ee 100644 --- a/src/Magick.NET.Core/IMagickImageCreateOperations{TQuantumType}.cs +++ b/src/Magick.NET.Core/IMagickImageCreateOperations{TQuantumType}.cs @@ -133,4 +133,17 @@ public interface IMagickImageCreateOperations : IMagickImageCreate /// A color value used for tinting. /// Thrown when an error is raised by ImageMagick. void Tint(IMagickGeometry opacity, IMagickColor color); + + /// + /// Removes noise from the image using a wavelet transform. + /// + /// The threshold for smoothing. + void WaveletDenoise(TQuantumType threshold); + + /// + /// Removes noise from the image using a wavelet transform. + /// + /// The threshold for smoothing. + /// Attenuate the smoothing threshold. + void WaveletDenoise(TQuantumType threshold, double softness); } diff --git a/src/Magick.NET.Core/IMagickImage{TQuantumType}.cs b/src/Magick.NET.Core/IMagickImage{TQuantumType}.cs index 1d239b0368..a40786d39b 100644 --- a/src/Magick.NET.Core/IMagickImage{TQuantumType}.cs +++ b/src/Magick.NET.Core/IMagickImage{TQuantumType}.cs @@ -926,17 +926,4 @@ public partial interface IMagickImage : IMagickImageCreateOperatio /// The unique colors of an image. /// Thrown when an error is raised by ImageMagick. IMagickImage? UniqueColors(); - - /// - /// Removes noise from the image using a wavelet transform. - /// - /// The threshold for smoothing. - void WaveletDenoise(TQuantumType threshold); - - /// - /// Removes noise from the image using a wavelet transform. - /// - /// The threshold for smoothing. - /// Attenuate the smoothing threshold. - void WaveletDenoise(TQuantumType threshold, double softness); } diff --git a/src/Magick.NET/MagickImage.CloneMutator.cs b/src/Magick.NET/MagickImage.CloneMutator.cs index aa145ec1f1..3a645d653f 100644 --- a/src/Magick.NET/MagickImage.CloneMutator.cs +++ b/src/Magick.NET/MagickImage.CloneMutator.cs @@ -722,6 +722,18 @@ public void Wave() public void Wave(PixelInterpolateMethod method, double amplitude, double length) => SetResult(NativeMagickImage.Wave(method, amplitude, length)); + public void WaveletDenoise(QuantumType threshold) + => WaveletDenoise(threshold, 0.0); + + public void WaveletDenoise(QuantumType threshold, double softness) + => SetResult(NativeMagickImage.WaveletDenoise(threshold, softness)); + + public void WaveletDenoise(Percentage thresholdPercentage) + => WaveletDenoise(PercentageHelper.ToQuantumType(nameof(thresholdPercentage), thresholdPercentage)); + + public void WaveletDenoise(Percentage thresholdPercentage, double softness) + => WaveletDenoise(PercentageHelper.ToQuantumType(nameof(thresholdPercentage), thresholdPercentage), softness); + protected virtual void SetResult(IntPtr result) { if (_result != IntPtr.Zero) diff --git a/src/Magick.NET/MagickImage.cs b/src/Magick.NET/MagickImage.cs index 73c0cd7830..ee5b106dcc 100644 --- a/src/Magick.NET/MagickImage.cs +++ b/src/Magick.NET/MagickImage.cs @@ -6965,7 +6965,10 @@ public void Wave(PixelInterpolateMethod method, double amplitude, double length) /// /// The threshold for smoothing. public void WaveletDenoise(QuantumType threshold) - => WaveletDenoise(threshold, 0.0); + { + using var mutator = new Mutator(_nativeInstance); + mutator.WaveletDenoise(threshold); + } /// /// Removes noise from the image using a wavelet transform. @@ -6973,14 +6976,20 @@ public void WaveletDenoise(QuantumType threshold) /// The threshold for smoothing. /// Attenuate the smoothing threshold. public void WaveletDenoise(QuantumType threshold, double softness) - => _nativeInstance.WaveletDenoise(threshold, softness); + { + using var mutator = new Mutator(_nativeInstance); + mutator.WaveletDenoise(threshold, softness); + } /// /// Removes noise from the image using a wavelet transform. /// /// The threshold for smoothing. public void WaveletDenoise(Percentage thresholdPercentage) - => WaveletDenoise(PercentageHelper.ToQuantumType(nameof(thresholdPercentage), thresholdPercentage)); + { + using var mutator = new Mutator(_nativeInstance); + mutator.WaveletDenoise(thresholdPercentage); + } /// /// Removes noise from the image using a wavelet transform. @@ -6988,7 +6997,10 @@ public void WaveletDenoise(Percentage thresholdPercentage) /// The threshold for smoothing. /// Attenuate the smoothing threshold. public void WaveletDenoise(Percentage thresholdPercentage, double softness) - => WaveletDenoise(PercentageHelper.ToQuantumType(nameof(thresholdPercentage), thresholdPercentage), softness); + { + using var mutator = new Mutator(_nativeInstance); + mutator.WaveletDenoise(thresholdPercentage, softness); + } /// /// Apply a white balancing to an image according to a grayworld assumption in the LAB colorspace. diff --git a/src/Magick.NET/Native/MagickImage.cs b/src/Magick.NET/Native/MagickImage.cs index 48a9e3ad29..ca1bf07b85 100644 --- a/src/Magick.NET/Native/MagickImage.cs +++ b/src/Magick.NET/Native/MagickImage.cs @@ -790,11 +790,10 @@ private unsafe sealed partial class NativeMagickImage : NativeInstance, INativeM public partial IntPtr Wave(PixelInterpolateMethod method, double amplitude, double length); [Throws] - public partial void WhiteBalance(); + public partial IntPtr WaveletDenoise(double threshold, double softness); [Throws] - [SetInstance] - public partial void WaveletDenoise(double threshold, double softness); + public partial void WhiteBalance(); [Throws] public partial void WhiteThreshold(string threshold, Channels channels);