Skip to content

Commit

Permalink
Moved MeanShift to IMagickImageCreateOperations.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Dec 19, 2024
1 parent fc39901 commit d4a8944
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 35 deletions.
28 changes: 0 additions & 28 deletions src/Magick.NET.Core/IMagickImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1309,34 +1309,6 @@ public partial interface IMagickImage : IMagickImageCreateOperations, IDisposabl
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Lower(uint size);

/// <summary>
/// Delineate arbitrarily shaped clusters in the image.
/// </summary>
/// <param name="size">The width and height of the pixels neighborhood.</param>
void MeanShift(uint size);

/// <summary>
/// Delineate arbitrarily shaped clusters in the image.
/// </summary>
/// <param name="size">The width and height of the pixels neighborhood.</param>
/// <param name="colorDistance">The color distance.</param>
void MeanShift(uint size, Percentage colorDistance);

/// <summary>
/// Delineate arbitrarily shaped clusters in the image.
/// </summary>
/// <param name="width">The width of the pixels neighborhood.</param>
/// <param name="height">The height of the pixels neighborhood.</param>
void MeanShift(uint width, uint height);

/// <summary>
/// Delineate arbitrarily shaped clusters in the image.
/// </summary>
/// <param name="width">The width of the pixels neighborhood.</param>
/// <param name="height">The height of the pixels neighborhood.</param>
/// <param name="colorDistance">The color distance.</param>
void MeanShift(uint width, uint height, Percentage colorDistance);

/// <summary>
/// Filter image by replacing each pixel component with the median color in a circular neighborhood.
/// </summary>
Expand Down
28 changes: 28 additions & 0 deletions src/Magick.NET.Core/IMagickImageCreateOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,34 @@ public interface IMagickImageCreateOperations
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
void Magnify();

/// <summary>
/// Delineate arbitrarily shaped clusters in the image.
/// </summary>
/// <param name="size">The width and height of the pixels neighborhood.</param>
void MeanShift(uint size);

/// <summary>
/// Delineate arbitrarily shaped clusters in the image.
/// </summary>
/// <param name="size">The width and height of the pixels neighborhood.</param>
/// <param name="colorDistance">The color distance.</param>
void MeanShift(uint size, Percentage colorDistance);

/// <summary>
/// Delineate arbitrarily shaped clusters in the image.
/// </summary>
/// <param name="width">The width of the pixels neighborhood.</param>
/// <param name="height">The height of the pixels neighborhood.</param>
void MeanShift(uint width, uint height);

/// <summary>
/// Delineate arbitrarily shaped clusters in the image.
/// </summary>
/// <param name="width">The width of the pixels neighborhood.</param>
/// <param name="height">The height of the pixels neighborhood.</param>
/// <param name="colorDistance">The color distance.</param>
void MeanShift(uint width, uint height, Percentage colorDistance);

/// <summary>
/// Resize image to specified size.
/// <para />
Expand Down
12 changes: 12 additions & 0 deletions src/Magick.NET/MagickImage.CloneMutator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 17 additions & 5 deletions src/Magick.NET/MagickImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4057,7 +4057,7 @@ public void Lower(uint size)
/// </summary>
/// <exception cref="MagickException">Thrown when an error is raised by ImageMagick.</exception>
public void Magnify()
{
{
using var mutator = new Mutator(_nativeInstance);
mutator.Magnify();
}
Expand All @@ -4067,23 +4067,32 @@ public void Magnify()
/// </summary>
/// <param name="size">The width and height of the pixels neighborhood.</param>
public void MeanShift(uint size)
=> MeanShift(size, size);
{
using var mutator = new Mutator(_nativeInstance);
mutator.MeanShift(size);
}

/// <summary>
/// Delineate arbitrarily shaped clusters in the image.
/// </summary>
/// <param name="size">The width and height of the pixels neighborhood.</param>
/// <param name="colorDistance">The color distance.</param>
public void MeanShift(uint size, Percentage colorDistance)
=> MeanShift(size, size, colorDistance);
{
using var mutator = new Mutator(_nativeInstance);
mutator.MeanShift(size, colorDistance);
}

/// <summary>
/// Delineate arbitrarily shaped clusters in the image.
/// </summary>
/// <param name="width">The width of the pixels neighborhood.</param>
/// <param name="height">The height of the pixels neighborhood.</param>
public void MeanShift(uint width, uint height)
=> MeanShift(width, height, new Percentage(10));
{
using var mutator = new Mutator(_nativeInstance);
mutator.MeanShift(width, height);
}

/// <summary>
/// Delineate arbitrarily shaped clusters in the image.
Expand All @@ -4092,7 +4101,10 @@ public void MeanShift(uint width, uint height)
/// <param name="height">The height of the pixels neighborhood.</param>
/// <param name="colorDistance">The color distance.</param>
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);
}

/// <summary>
/// Filter image by replacing each pixel component with the median color in a circular neighborhood.
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 @@ -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]
Expand Down

0 comments on commit d4a8944

Please sign in to comment.