Browse Source

Normalize parameter order.

pull/2797/head
James Jackson-South 1 year ago
parent
commit
3bd1efbbf8
  1. 8
      src/ImageSharp/Processing/Extensions/Convolution/BokehBlurExtensions.cs
  2. 4
      src/ImageSharp/Processing/Extensions/Convolution/BoxBlurExtensions.cs
  3. 124
      src/ImageSharp/Processing/Extensions/Convolution/DetectEdgesExtensions.cs
  4. 21
      src/ImageSharp/Processing/Extensions/Convolution/GaussianBlurExtensions.cs
  5. 28
      src/ImageSharp/Processing/Extensions/Convolution/GaussianSharpenExtensions.cs
  6. 17
      src/ImageSharp/Processing/Extensions/Convolution/MedianBlurExtensions.cs
  7. 12
      tests/ImageSharp.Tests/Processing/Convolution/DetectEdgesTest.cs
  8. 8
      tests/ImageSharp.Tests/Processing/Convolution/GaussianBlurTest.cs
  9. 8
      tests/ImageSharp.Tests/Processing/Convolution/GaussianSharpenTest.cs
  10. 6
      tests/ImageSharp.Tests/Processing/Convolution/MedianBlurTest.cs
  11. 3
      tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs
  12. 2
      tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianBlurTest.cs
  13. 2
      tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianSharpenTest.cs
  14. 2
      tests/ImageSharp.Tests/Processing/Processors/Convolution/MedianBlurTest.cs

8
src/ImageSharp/Processing/Extensions/Convolution/BokehBlurExtensions.cs

@ -44,13 +44,13 @@ public static class BokehBlurExtensions
/// Applies a bokeh blur to the image. /// Applies a bokeh blur to the image.
/// </summary> /// </summary>
/// <param name="source">The current image processing context.</param> /// <param name="source">The current image processing context.</param>
/// <param name="radius">The 'radius' value representing the size of the area to sample.</param>
/// <param name="components">The 'components' value representing the number of kernels to use to approximate the bokeh effect.</param>
/// <param name="gamma">The gamma highlight factor to use to emphasize bright spots in the source image</param>
/// <param name="rectangle"> /// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter. /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param> /// </param>
/// <param name="radius">The 'radius' value representing the size of the area to sample.</param>
/// <param name="components">The 'components' value representing the number of kernels to use to approximate the bokeh effect.</param>
/// <param name="gamma">The gamma highlight factor to use to emphasize bright spots in the source image</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext BokehBlur(this IImageProcessingContext source, int radius, int components, float gamma, Rectangle rectangle) public static IImageProcessingContext BokehBlur(this IImageProcessingContext source, Rectangle rectangle, int radius, int components, float gamma)
=> source.ApplyProcessor(new BokehBlurProcessor(radius, components, gamma), rectangle); => source.ApplyProcessor(new BokehBlurProcessor(radius, components, gamma), rectangle);
} }

4
src/ImageSharp/Processing/Extensions/Convolution/BoxBlurExtensions.cs

@ -44,10 +44,10 @@ public static class BoxBlurExtensions
/// Applies a box blur to the image. /// Applies a box blur to the image.
/// </summary> /// </summary>
/// <param name="source">The current image processing context.</param> /// <param name="source">The current image processing context.</param>
/// <param name="radius">The 'radius' value representing the size of the area to sample.</param>
/// <param name="rectangle"> /// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter. /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param> /// </param>
/// <param name="radius">The 'radius' value representing the size of the area to sample.</param>
/// <param name="borderWrapModeX"> /// <param name="borderWrapModeX">
/// The <see cref="BorderWrappingMode"/> to use when mapping the pixels outside of the border, in X direction. /// The <see cref="BorderWrappingMode"/> to use when mapping the pixels outside of the border, in X direction.
/// </param> /// </param>
@ -57,8 +57,8 @@ public static class BoxBlurExtensions
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext BoxBlur( public static IImageProcessingContext BoxBlur(
this IImageProcessingContext source, this IImageProcessingContext source,
int radius,
Rectangle rectangle, Rectangle rectangle,
int radius,
BorderWrappingMode borderWrapModeX, BorderWrappingMode borderWrapModeX,
BorderWrappingMode borderWrapModeY) BorderWrappingMode borderWrapModeY)
=> source.ApplyProcessor(new BoxBlurProcessor(radius, borderWrapModeX, borderWrapModeY), rectangle); => source.ApplyProcessor(new BoxBlurProcessor(radius, borderWrapModeX, borderWrapModeY), rectangle);

124
src/ImageSharp/Processing/Extensions/Convolution/DetectEdgesExtensions.cs

@ -16,8 +16,8 @@ public static class DetectEdgesExtensions
/// </summary> /// </summary>
/// <param name="source">The current image processing context.</param> /// <param name="source">The current image processing context.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DetectEdges(this IImageProcessingContext source) => public static IImageProcessingContext DetectEdges(this IImageProcessingContext source)
DetectEdges(source, KnownEdgeDetectorKernels.Sobel); => DetectEdges(source, KnownEdgeDetectorKernels.Sobel);
/// <summary> /// <summary>
/// Detects any edges within the image. /// Detects any edges within the image.
@ -28,10 +28,8 @@ public static class DetectEdgesExtensions
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter. /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param> /// </param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DetectEdges( public static IImageProcessingContext DetectEdges(this IImageProcessingContext source, Rectangle rectangle)
this IImageProcessingContext source, => DetectEdges(source, rectangle, KnownEdgeDetectorKernels.Sobel);
Rectangle rectangle) =>
DetectEdges(source, KnownEdgeDetectorKernels.Sobel, rectangle);
/// <summary> /// <summary>
/// Detects any edges within the image operating in grayscale mode. /// Detects any edges within the image operating in grayscale mode.
@ -39,10 +37,8 @@ public static class DetectEdgesExtensions
/// <param name="source">The current image processing context.</param> /// <param name="source">The current image processing context.</param>
/// <param name="kernel">The 2D edge detector kernel.</param> /// <param name="kernel">The 2D edge detector kernel.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DetectEdges( public static IImageProcessingContext DetectEdges(this IImageProcessingContext source, EdgeDetector2DKernel kernel)
this IImageProcessingContext source, => DetectEdges(source, kernel, true);
EdgeDetector2DKernel kernel) =>
DetectEdges(source, kernel, true);
/// <summary> /// <summary>
/// Detects any edges within the image using a <see cref="EdgeDetector2DKernel"/>. /// Detects any edges within the image using a <see cref="EdgeDetector2DKernel"/>.
@ -57,49 +53,41 @@ public static class DetectEdgesExtensions
this IImageProcessingContext source, this IImageProcessingContext source,
EdgeDetector2DKernel kernel, EdgeDetector2DKernel kernel,
bool grayscale) bool grayscale)
{ => source.ApplyProcessor(new EdgeDetector2DProcessor(kernel, grayscale));
var processor = new EdgeDetector2DProcessor(kernel, grayscale);
source.ApplyProcessor(processor);
return source;
}
/// <summary> /// <summary>
/// Detects any edges within the image operating in grayscale mode. /// Detects any edges within the image operating in grayscale mode.
/// </summary> /// </summary>
/// <param name="source">The current image processing context.</param> /// <param name="source">The current image processing context.</param>
/// <param name="kernel">The 2D edge detector kernel.</param>
/// <param name="rectangle"> /// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter. /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param> /// </param>
/// <param name="kernel">The 2D edge detector kernel.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DetectEdges( public static IImageProcessingContext DetectEdges(
this IImageProcessingContext source, this IImageProcessingContext source,
EdgeDetector2DKernel kernel, Rectangle rectangle,
Rectangle rectangle) => EdgeDetector2DKernel kernel)
DetectEdges(source, kernel, true, rectangle); => DetectEdges(source, rectangle, kernel, true);
/// <summary> /// <summary>
/// Detects any edges within the image using a <see cref="EdgeDetector2DKernel"/>. /// Detects any edges within the image using a <see cref="EdgeDetector2DKernel"/>.
/// </summary> /// </summary>
/// <param name="source">The current image processing context.</param> /// <param name="source">The current image processing context.</param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="kernel">The 2D edge detector kernel.</param> /// <param name="kernel">The 2D edge detector kernel.</param>
/// <param name="grayscale"> /// <param name="grayscale">
/// Whether to convert the image to grayscale before performing edge detection. /// Whether to convert the image to grayscale before performing edge detection.
/// </param> /// </param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DetectEdges( public static IImageProcessingContext DetectEdges(
this IImageProcessingContext source, this IImageProcessingContext source,
Rectangle rectangle,
EdgeDetector2DKernel kernel, EdgeDetector2DKernel kernel,
bool grayscale, bool grayscale)
Rectangle rectangle) => source.ApplyProcessor(new EdgeDetector2DProcessor(kernel, grayscale), rectangle);
{
var processor = new EdgeDetector2DProcessor(kernel, grayscale);
source.ApplyProcessor(processor, rectangle);
return source;
}
/// <summary> /// <summary>
/// Detects any edges within the image operating in grayscale mode. /// Detects any edges within the image operating in grayscale mode.
@ -107,10 +95,8 @@ public static class DetectEdgesExtensions
/// <param name="source">The current image processing context.</param> /// <param name="source">The current image processing context.</param>
/// <param name="kernel">The edge detector kernel.</param> /// <param name="kernel">The edge detector kernel.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DetectEdges( public static IImageProcessingContext DetectEdges(this IImageProcessingContext source, EdgeDetectorKernel kernel)
this IImageProcessingContext source, => DetectEdges(source, kernel, true);
EdgeDetectorKernel kernel) =>
DetectEdges(source, kernel, true);
/// <summary> /// <summary>
/// Detects any edges within the image using a <see cref="EdgeDetectorKernel"/>. /// Detects any edges within the image using a <see cref="EdgeDetectorKernel"/>.
@ -125,66 +111,56 @@ public static class DetectEdgesExtensions
this IImageProcessingContext source, this IImageProcessingContext source,
EdgeDetectorKernel kernel, EdgeDetectorKernel kernel,
bool grayscale) bool grayscale)
{ => source.ApplyProcessor(new EdgeDetectorProcessor(kernel, grayscale));
var processor = new EdgeDetectorProcessor(kernel, grayscale);
source.ApplyProcessor(processor);
return source;
}
/// <summary> /// <summary>
/// Detects any edges within the image operating in grayscale mode. /// Detects any edges within the image operating in grayscale mode.
/// </summary> /// </summary>
/// <param name="source">The current image processing context.</param> /// <param name="source">The current image processing context.</param>
/// <param name="kernel">The edge detector kernel.</param>
/// <param name="rectangle"> /// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter. /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param> /// </param>
/// <param name="kernel">The edge detector kernel.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DetectEdges( public static IImageProcessingContext DetectEdges(
this IImageProcessingContext source, this IImageProcessingContext source,
EdgeDetectorKernel kernel, Rectangle rectangle,
Rectangle rectangle) => EdgeDetectorKernel kernel)
DetectEdges(source, kernel, true, rectangle); => DetectEdges(source, rectangle, kernel, true);
/// <summary> /// <summary>
/// Detects any edges within the image using a <see cref="EdgeDetectorKernel"/>. /// Detects any edges within the image using a <see cref="EdgeDetectorKernel"/>.
/// </summary> /// </summary>
/// <param name="source">The current image processing context.</param> /// <param name="source">The current image processing context.</param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="kernel">The edge detector kernel.</param> /// <param name="kernel">The edge detector kernel.</param>
/// <param name="grayscale"> /// <param name="grayscale">
/// Whether to convert the image to grayscale before performing edge detection. /// Whether to convert the image to grayscale before performing edge detection.
/// </param> /// </param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DetectEdges( public static IImageProcessingContext DetectEdges(
this IImageProcessingContext source, this IImageProcessingContext source,
Rectangle rectangle,
EdgeDetectorKernel kernel, EdgeDetectorKernel kernel,
bool grayscale, bool grayscale)
Rectangle rectangle) => source.ApplyProcessor(new EdgeDetectorProcessor(kernel, grayscale), rectangle);
{
var processor = new EdgeDetectorProcessor(kernel, grayscale);
source.ApplyProcessor(processor, rectangle);
return source;
}
/// <summary> /// <summary>
/// Detects any edges within the image operating in grayscale mode. /// Detects any edges within the image operating in grayscale mode.
/// </summary> /// </summary>
/// <param name="source">The current image processing context.</param> /// <param name="source">The current image processing context.</param>
/// <param name="kernel">Thecompass edge detector kernel.</param> /// <param name="kernel">The compass edge detector kernel.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DetectEdges( public static IImageProcessingContext DetectEdges(this IImageProcessingContext source, EdgeDetectorCompassKernel kernel)
this IImageProcessingContext source, => DetectEdges(source, kernel, true);
EdgeDetectorCompassKernel kernel) =>
DetectEdges(source, kernel, true);
/// <summary> /// <summary>
/// Detects any edges within the image using a <see cref="EdgeDetectorCompassKernel"/>. /// Detects any edges within the image using a <see cref="EdgeDetectorCompassKernel"/>.
/// </summary> /// </summary>
/// <param name="source">The current image processing context.</param> /// <param name="source">The current image processing context.</param>
/// <param name="kernel">Thecompass edge detector kernel.</param> /// <param name="kernel">The compass edge detector kernel.</param>
/// <param name="grayscale"> /// <param name="grayscale">
/// Whether to convert the image to grayscale before performing edge detection. /// Whether to convert the image to grayscale before performing edge detection.
/// </param> /// </param>
@ -193,47 +169,39 @@ public static class DetectEdgesExtensions
this IImageProcessingContext source, this IImageProcessingContext source,
EdgeDetectorCompassKernel kernel, EdgeDetectorCompassKernel kernel,
bool grayscale) bool grayscale)
{ => source.ApplyProcessor(new EdgeDetectorCompassProcessor(kernel, grayscale));
var processor = new EdgeDetectorCompassProcessor(kernel, grayscale);
source.ApplyProcessor(processor);
return source;
}
/// <summary> /// <summary>
/// Detects any edges within the image operating in grayscale mode. /// Detects any edges within the image operating in grayscale mode.
/// </summary> /// </summary>
/// <param name="source">The current image processing context.</param> /// <param name="source">The current image processing context.</param>
/// <param name="kernel">Thecompass edge detector kernel.</param>
/// <param name="rectangle"> /// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter. /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param> /// </param>
/// <param name="kernel">The compass edge detector kernel.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DetectEdges( public static IImageProcessingContext DetectEdges(
this IImageProcessingContext source, this IImageProcessingContext source,
EdgeDetectorCompassKernel kernel, Rectangle rectangle,
Rectangle rectangle) => EdgeDetectorCompassKernel kernel)
DetectEdges(source, kernel, true, rectangle); => DetectEdges(source, rectangle, kernel, true);
/// <summary> /// <summary>
/// Detects any edges within the image using a <see cref="EdgeDetectorCompassKernel"/>. /// Detects any edges within the image using a <see cref="EdgeDetectorCompassKernel"/>.
/// </summary> /// </summary>
/// <param name="source">The current image processing context.</param> /// <param name="source">The current image processing context.</param>
/// <param name="kernel">Thecompass edge detector kernel.</param>
/// <param name="grayscale">
/// Whether to convert the image to grayscale before performing edge detection.
/// </param>
/// <param name="rectangle"> /// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter. /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param> /// </param>
/// <param name="kernel">The compass edge detector kernel.</param>
/// <param name="grayscale">
/// Whether to convert the image to grayscale before performing edge detection.
/// </param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext DetectEdges( public static IImageProcessingContext DetectEdges(
this IImageProcessingContext source, this IImageProcessingContext source,
Rectangle rectangle,
EdgeDetectorCompassKernel kernel, EdgeDetectorCompassKernel kernel,
bool grayscale, bool grayscale)
Rectangle rectangle) => source.ApplyProcessor(new EdgeDetectorCompassProcessor(kernel, grayscale), rectangle);
{
var processor = new EdgeDetectorCompassProcessor(kernel, grayscale);
source.ApplyProcessor(processor, rectangle);
return source;
}
} }

21
src/ImageSharp/Processing/Extensions/Convolution/GaussianBlurExtensions.cs

@ -32,22 +32,25 @@ public static class GaussianBlurExtensions
/// Applies a Gaussian blur to the image. /// Applies a Gaussian blur to the image.
/// </summary> /// </summary>
/// <param name="source">The current image processing context.</param> /// <param name="source">The current image processing context.</param>
/// <param name="sigma">The 'sigma' value representing the weight of the blur.</param>
/// <param name="rectangle"> /// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter. /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param> /// </param>
/// <param name="sigma">The 'sigma' value representing the weight of the blur.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext GaussianBlur(this IImageProcessingContext source, float sigma, Rectangle rectangle) public static IImageProcessingContext GaussianBlur(
this IImageProcessingContext source,
Rectangle rectangle,
float sigma)
=> source.ApplyProcessor(new GaussianBlurProcessor(sigma), rectangle); => source.ApplyProcessor(new GaussianBlurProcessor(sigma), rectangle);
/// <summary> /// <summary>
/// Applies a Gaussian blur to the image. /// Applies a Gaussian blur to the image.
/// </summary> /// </summary>
/// <param name="source">The current image processing context.</param> /// <param name="source">The current image processing context.</param>
/// <param name="sigma">The 'sigma' value representing the weight of the blur.</param>
/// <param name="rectangle"> /// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter. /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param> /// </param>
/// <param name="sigma">The 'sigma' value representing the weight of the blur.</param>
/// <param name="borderWrapModeX"> /// <param name="borderWrapModeX">
/// The <see cref="BorderWrappingMode"/> to use when mapping the pixels outside of the border, in X direction. /// The <see cref="BorderWrappingMode"/> to use when mapping the pixels outside of the border, in X direction.
/// </param> /// </param>
@ -55,9 +58,11 @@ public static class GaussianBlurExtensions
/// The <see cref="BorderWrappingMode"/> to use when mapping the pixels outside of the border, in Y direction. /// The <see cref="BorderWrappingMode"/> to use when mapping the pixels outside of the border, in Y direction.
/// </param> /// </param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext GaussianBlur(this IImageProcessingContext source, float sigma, Rectangle rectangle, BorderWrappingMode borderWrapModeX, BorderWrappingMode borderWrapModeY) public static IImageProcessingContext GaussianBlur(
{ this IImageProcessingContext source,
GaussianBlurProcessor processor = new(sigma, borderWrapModeX, borderWrapModeY); Rectangle rectangle,
return source.ApplyProcessor(processor, rectangle); float sigma,
} BorderWrappingMode borderWrapModeX,
BorderWrappingMode borderWrapModeY)
=> source.ApplyProcessor(new GaussianBlurProcessor(sigma, borderWrapModeX, borderWrapModeY), rectangle);
} }

28
src/ImageSharp/Processing/Extensions/Convolution/GaussianSharpenExtensions.cs

@ -16,8 +16,8 @@ public static class GaussianSharpenExtensions
/// </summary> /// </summary>
/// <param name="source">The current image processing context.</param> /// <param name="source">The current image processing context.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext GaussianSharpen(this IImageProcessingContext source) => public static IImageProcessingContext GaussianSharpen(this IImageProcessingContext source)
source.ApplyProcessor(new GaussianSharpenProcessor()); => source.ApplyProcessor(new GaussianSharpenProcessor());
/// <summary> /// <summary>
/// Applies a Gaussian sharpening filter to the image. /// Applies a Gaussian sharpening filter to the image.
@ -25,32 +25,32 @@ public static class GaussianSharpenExtensions
/// <param name="source">The current image processing context.</param> /// <param name="source">The current image processing context.</param>
/// <param name="sigma">The 'sigma' value representing the weight of the blur.</param> /// <param name="sigma">The 'sigma' value representing the weight of the blur.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext GaussianSharpen(this IImageProcessingContext source, float sigma) => public static IImageProcessingContext GaussianSharpen(this IImageProcessingContext source, float sigma)
source.ApplyProcessor(new GaussianSharpenProcessor(sigma)); => source.ApplyProcessor(new GaussianSharpenProcessor(sigma));
/// <summary> /// <summary>
/// Applies a Gaussian sharpening filter to the image. /// Applies a Gaussian sharpening filter to the image.
/// </summary> /// </summary>
/// <param name="source">The current image processing context.</param> /// <param name="source">The current image processing context.</param>
/// <param name="sigma">The 'sigma' value representing the weight of the blur.</param>
/// <param name="rectangle"> /// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter. /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param> /// </param>
/// <param name="sigma">The 'sigma' value representing the weight of the blur.</param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext GaussianSharpen( public static IImageProcessingContext GaussianSharpen(
this IImageProcessingContext source, this IImageProcessingContext source,
float sigma, Rectangle rectangle,
Rectangle rectangle) => float sigma) =>
source.ApplyProcessor(new GaussianSharpenProcessor(sigma), rectangle); source.ApplyProcessor(new GaussianSharpenProcessor(sigma), rectangle);
/// <summary> /// <summary>
/// Applies a Gaussian sharpening filter to the image. /// Applies a Gaussian sharpening filter to the image.
/// </summary> /// </summary>
/// <param name="source">The current image processing context.</param> /// <param name="source">The current image processing context.</param>
/// <param name="sigma">The 'sigma' value representing the weight of the blur.</param>
/// <param name="rectangle"> /// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter. /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param> /// </param>
/// <param name="sigma">The 'sigma' value representing the weight of the blur.</param>
/// <param name="borderWrapModeX"> /// <param name="borderWrapModeX">
/// The <see cref="BorderWrappingMode"/> to use when mapping the pixels outside of the border, in X direction. /// The <see cref="BorderWrappingMode"/> to use when mapping the pixels outside of the border, in X direction.
/// </param> /// </param>
@ -58,9 +58,11 @@ public static class GaussianSharpenExtensions
/// The <see cref="BorderWrappingMode"/> to use when mapping the pixels outside of the border, in Y direction. /// The <see cref="BorderWrappingMode"/> to use when mapping the pixels outside of the border, in Y direction.
/// </param> /// </param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext GaussianSharpen(this IImageProcessingContext source, float sigma, Rectangle rectangle, BorderWrappingMode borderWrapModeX, BorderWrappingMode borderWrapModeY) public static IImageProcessingContext GaussianSharpen(
{ this IImageProcessingContext source,
var processor = new GaussianSharpenProcessor(sigma, borderWrapModeX, borderWrapModeY); Rectangle rectangle,
return source.ApplyProcessor(processor, rectangle); float sigma,
} BorderWrappingMode borderWrapModeX,
BorderWrappingMode borderWrapModeY)
=> source.ApplyProcessor(new GaussianSharpenProcessor(sigma, borderWrapModeX, borderWrapModeY), rectangle);
} }

17
src/ImageSharp/Processing/Extensions/Convolution/MedianBlurExtensions.cs

@ -20,21 +20,28 @@ public static class MedianBlurExtensions
/// Whether the filter is applied to alpha as well as the color channels. /// Whether the filter is applied to alpha as well as the color channels.
/// </param> /// </param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext MedianBlur(this IImageProcessingContext source, int radius, bool preserveAlpha) public static IImageProcessingContext MedianBlur(
this IImageProcessingContext source,
int radius,
bool preserveAlpha)
=> source.ApplyProcessor(new MedianBlurProcessor(radius, preserveAlpha)); => source.ApplyProcessor(new MedianBlurProcessor(radius, preserveAlpha));
/// <summary> /// <summary>
/// Applies a median blur on the image. /// Applies a median blur on the image.
/// </summary> /// </summary>
/// <param name="source">The current image processing context.</param> /// <param name="source">The current image processing context.</param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <param name="radius">The radius of the area to find the median for.</param> /// <param name="radius">The radius of the area to find the median for.</param>
/// <param name="preserveAlpha"> /// <param name="preserveAlpha">
/// Whether the filter is applied to alpha as well as the color channels. /// Whether the filter is applied to alpha as well as the color channels.
/// </param> /// </param>
/// <param name="rectangle">
/// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
/// </param>
/// <returns>The <see cref="IImageProcessingContext"/>.</returns> /// <returns>The <see cref="IImageProcessingContext"/>.</returns>
public static IImageProcessingContext MedianBlur(this IImageProcessingContext source, int radius, bool preserveAlpha, Rectangle rectangle) public static IImageProcessingContext MedianBlur(
this IImageProcessingContext source,
Rectangle rectangle,
int radius,
bool preserveAlpha)
=> source.ApplyProcessor(new MedianBlurProcessor(radius, preserveAlpha), rectangle); => source.ApplyProcessor(new MedianBlurProcessor(radius, preserveAlpha), rectangle);
} }

12
tests/ImageSharp.Tests/Processing/Convolution/DetectEdgesTest.cs

@ -59,7 +59,7 @@ public class DetectEdgesTest : BaseImageOperationsExtensionTest
[MemberData(nameof(EdgeDetector2DKernelData))] [MemberData(nameof(EdgeDetector2DKernelData))]
public void DetectEdges_Rect_EdgeDetector2DProcessor_DefaultGrayScale_Set(EdgeDetector2DKernel kernel, bool _) public void DetectEdges_Rect_EdgeDetector2DProcessor_DefaultGrayScale_Set(EdgeDetector2DKernel kernel, bool _)
{ {
this.operations.DetectEdges(kernel, this.rect); this.operations.DetectEdges(this.rect, kernel);
EdgeDetector2DProcessor processor = this.Verify<EdgeDetector2DProcessor>(this.rect); EdgeDetector2DProcessor processor = this.Verify<EdgeDetector2DProcessor>(this.rect);
Assert.True(processor.Grayscale); Assert.True(processor.Grayscale);
@ -81,7 +81,7 @@ public class DetectEdgesTest : BaseImageOperationsExtensionTest
[MemberData(nameof(EdgeDetector2DKernelData))] [MemberData(nameof(EdgeDetector2DKernelData))]
public void DetectEdges_Rect_EdgeDetector2DProcessorSet(EdgeDetector2DKernel kernel, bool grayscale) public void DetectEdges_Rect_EdgeDetector2DProcessorSet(EdgeDetector2DKernel kernel, bool grayscale)
{ {
this.operations.DetectEdges(kernel, grayscale, this.rect); this.operations.DetectEdges(this.rect, kernel, grayscale);
EdgeDetector2DProcessor processor = this.Verify<EdgeDetector2DProcessor>(this.rect); EdgeDetector2DProcessor processor = this.Verify<EdgeDetector2DProcessor>(this.rect);
Assert.Equal(grayscale, processor.Grayscale); Assert.Equal(grayscale, processor.Grayscale);
@ -114,7 +114,7 @@ public class DetectEdgesTest : BaseImageOperationsExtensionTest
[MemberData(nameof(EdgeDetectorKernelData))] [MemberData(nameof(EdgeDetectorKernelData))]
public void DetectEdges_Rect_EdgeDetectorProcessor_DefaultGrayScale_Set(EdgeDetectorKernel kernel, bool _) public void DetectEdges_Rect_EdgeDetectorProcessor_DefaultGrayScale_Set(EdgeDetectorKernel kernel, bool _)
{ {
this.operations.DetectEdges(kernel, this.rect); this.operations.DetectEdges(this.rect, kernel);
EdgeDetectorProcessor processor = this.Verify<EdgeDetectorProcessor>(this.rect); EdgeDetectorProcessor processor = this.Verify<EdgeDetectorProcessor>(this.rect);
Assert.True(processor.Grayscale); Assert.True(processor.Grayscale);
@ -136,7 +136,7 @@ public class DetectEdgesTest : BaseImageOperationsExtensionTest
[MemberData(nameof(EdgeDetectorKernelData))] [MemberData(nameof(EdgeDetectorKernelData))]
public void DetectEdges_Rect_EdgeDetectorProcessorSet(EdgeDetectorKernel kernel, bool grayscale) public void DetectEdges_Rect_EdgeDetectorProcessorSet(EdgeDetectorKernel kernel, bool grayscale)
{ {
this.operations.DetectEdges(kernel, grayscale, this.rect); this.operations.DetectEdges(this.rect, kernel, grayscale);
EdgeDetectorProcessor processor = this.Verify<EdgeDetectorProcessor>(this.rect); EdgeDetectorProcessor processor = this.Verify<EdgeDetectorProcessor>(this.rect);
Assert.Equal(grayscale, processor.Grayscale); Assert.Equal(grayscale, processor.Grayscale);
@ -167,7 +167,7 @@ public class DetectEdgesTest : BaseImageOperationsExtensionTest
[MemberData(nameof(EdgeDetectorCompassKernelData))] [MemberData(nameof(EdgeDetectorCompassKernelData))]
public void DetectEdges_Rect_EdgeDetectorCompassProcessor_DefaultGrayScale_Set(EdgeDetectorCompassKernel kernel, bool _) public void DetectEdges_Rect_EdgeDetectorCompassProcessor_DefaultGrayScale_Set(EdgeDetectorCompassKernel kernel, bool _)
{ {
this.operations.DetectEdges(kernel, this.rect); this.operations.DetectEdges(this.rect, kernel);
EdgeDetectorCompassProcessor processor = this.Verify<EdgeDetectorCompassProcessor>(this.rect); EdgeDetectorCompassProcessor processor = this.Verify<EdgeDetectorCompassProcessor>(this.rect);
Assert.True(processor.Grayscale); Assert.True(processor.Grayscale);
@ -189,7 +189,7 @@ public class DetectEdgesTest : BaseImageOperationsExtensionTest
[MemberData(nameof(EdgeDetectorCompassKernelData))] [MemberData(nameof(EdgeDetectorCompassKernelData))]
public void DetectEdges_Rect_EdgeDetectorCompassProcessorSet(EdgeDetectorCompassKernel kernel, bool grayscale) public void DetectEdges_Rect_EdgeDetectorCompassProcessorSet(EdgeDetectorCompassKernel kernel, bool grayscale)
{ {
this.operations.DetectEdges(kernel, grayscale, this.rect); this.operations.DetectEdges(this.rect, kernel, grayscale);
EdgeDetectorCompassProcessor processor = this.Verify<EdgeDetectorCompassProcessor>(this.rect); EdgeDetectorCompassProcessor processor = this.Verify<EdgeDetectorCompassProcessor>(this.rect);
Assert.Equal(grayscale, processor.Grayscale); Assert.Equal(grayscale, processor.Grayscale);

8
tests/ImageSharp.Tests/Processing/Convolution/GaussianBlurTest.cs

@ -13,7 +13,7 @@ public class GaussianBlurTest : BaseImageOperationsExtensionTest
public void GaussianBlur_GaussianBlurProcessorDefaultsSet() public void GaussianBlur_GaussianBlurProcessorDefaultsSet()
{ {
this.operations.GaussianBlur(); this.operations.GaussianBlur();
var processor = this.Verify<GaussianBlurProcessor>(); GaussianBlurProcessor processor = this.Verify<GaussianBlurProcessor>();
Assert.Equal(3f, processor.Sigma); Assert.Equal(3f, processor.Sigma);
} }
@ -22,7 +22,7 @@ public class GaussianBlurTest : BaseImageOperationsExtensionTest
public void GaussianBlur_amount_GaussianBlurProcessorDefaultsSet() public void GaussianBlur_amount_GaussianBlurProcessorDefaultsSet()
{ {
this.operations.GaussianBlur(0.2f); this.operations.GaussianBlur(0.2f);
var processor = this.Verify<GaussianBlurProcessor>(); GaussianBlurProcessor processor = this.Verify<GaussianBlurProcessor>();
Assert.Equal(.2f, processor.Sigma); Assert.Equal(.2f, processor.Sigma);
} }
@ -30,8 +30,8 @@ public class GaussianBlurTest : BaseImageOperationsExtensionTest
[Fact] [Fact]
public void GaussianBlur_amount_rect_GaussianBlurProcessorDefaultsSet() public void GaussianBlur_amount_rect_GaussianBlurProcessorDefaultsSet()
{ {
this.operations.GaussianBlur(0.6f, this.rect); this.operations.GaussianBlur(this.rect, 0.6f);
var processor = this.Verify<GaussianBlurProcessor>(this.rect); GaussianBlurProcessor processor = this.Verify<GaussianBlurProcessor>(this.rect);
Assert.Equal(.6f, processor.Sigma); Assert.Equal(.6f, processor.Sigma);
} }

8
tests/ImageSharp.Tests/Processing/Convolution/GaussianSharpenTest.cs

@ -13,7 +13,7 @@ public class GaussianSharpenTest : BaseImageOperationsExtensionTest
public void GaussianSharpen_GaussianSharpenProcessorDefaultsSet() public void GaussianSharpen_GaussianSharpenProcessorDefaultsSet()
{ {
this.operations.GaussianSharpen(); this.operations.GaussianSharpen();
var processor = this.Verify<GaussianSharpenProcessor>(); GaussianSharpenProcessor processor = this.Verify<GaussianSharpenProcessor>();
Assert.Equal(3f, processor.Sigma); Assert.Equal(3f, processor.Sigma);
} }
@ -22,7 +22,7 @@ public class GaussianSharpenTest : BaseImageOperationsExtensionTest
public void GaussianSharpen_amount_GaussianSharpenProcessorDefaultsSet() public void GaussianSharpen_amount_GaussianSharpenProcessorDefaultsSet()
{ {
this.operations.GaussianSharpen(0.2f); this.operations.GaussianSharpen(0.2f);
var processor = this.Verify<GaussianSharpenProcessor>(); GaussianSharpenProcessor processor = this.Verify<GaussianSharpenProcessor>();
Assert.Equal(.2f, processor.Sigma); Assert.Equal(.2f, processor.Sigma);
} }
@ -30,8 +30,8 @@ public class GaussianSharpenTest : BaseImageOperationsExtensionTest
[Fact] [Fact]
public void GaussianSharpen_amount_rect_GaussianSharpenProcessorDefaultsSet() public void GaussianSharpen_amount_rect_GaussianSharpenProcessorDefaultsSet()
{ {
this.operations.GaussianSharpen(0.6f, this.rect); this.operations.GaussianSharpen(this.rect, 0.6f);
var processor = this.Verify<GaussianSharpenProcessor>(this.rect); GaussianSharpenProcessor processor = this.Verify<GaussianSharpenProcessor>(this.rect);
Assert.Equal(.6f, processor.Sigma); Assert.Equal(.6f, processor.Sigma);
} }

6
tests/ImageSharp.Tests/Processing/Convolution/MedianBlurTest.cs

@ -13,7 +13,7 @@ public class MedianBlurTest : BaseImageOperationsExtensionTest
public void Median_radius_MedianProcessorDefaultsSet() public void Median_radius_MedianProcessorDefaultsSet()
{ {
this.operations.MedianBlur(3, true); this.operations.MedianBlur(3, true);
var processor = this.Verify<MedianBlurProcessor>(); MedianBlurProcessor processor = this.Verify<MedianBlurProcessor>();
Assert.Equal(3, processor.Radius); Assert.Equal(3, processor.Radius);
Assert.True(processor.PreserveAlpha); Assert.True(processor.PreserveAlpha);
@ -22,8 +22,8 @@ public class MedianBlurTest : BaseImageOperationsExtensionTest
[Fact] [Fact]
public void Median_radius_rect_MedianProcessorDefaultsSet() public void Median_radius_rect_MedianProcessorDefaultsSet()
{ {
this.operations.MedianBlur(5, false, this.rect); this.operations.MedianBlur(this.rect, 5, false);
var processor = this.Verify<MedianBlurProcessor>(this.rect); MedianBlurProcessor processor = this.Verify<MedianBlurProcessor>(this.rect);
Assert.Equal(5, processor.Radius); Assert.Equal(5, processor.Radius);
Assert.False(processor.PreserveAlpha); Assert.False(processor.PreserveAlpha);

3
tests/ImageSharp.Tests/Processing/Processors/Convolution/BokehBlurTest.cs

@ -3,7 +3,6 @@
using System.Globalization; using System.Globalization;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats; using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing; using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors.Convolution; using SixLabors.ImageSharp.Processing.Processors.Convolution;
@ -165,7 +164,7 @@ public class BokehBlurTest
{ {
Size size = x.GetCurrentSize(); Size size = x.GetCurrentSize();
Rectangle bounds = new(10, 10, size.Width / 2, size.Height / 2); Rectangle bounds = new(10, 10, size.Width / 2, size.Height / 2);
x.BokehBlur(value.Radius, value.Components, value.Gamma, bounds); x.BokehBlur(bounds, value.Radius, value.Components, value.Gamma);
}, },
testOutputDetails: value.ToString(), testOutputDetails: value.ToString(),
ImageComparer.TolerantPercentage(0.05f), ImageComparer.TolerantPercentage(0.05f),

2
tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianBlurTest.cs

@ -12,5 +12,5 @@ public class GaussianBlurTest : Basic1ParameterConvolutionTests
protected override void Apply(IImageProcessingContext ctx, int value) => ctx.GaussianBlur(value); protected override void Apply(IImageProcessingContext ctx, int value) => ctx.GaussianBlur(value);
protected override void Apply(IImageProcessingContext ctx, int value, Rectangle bounds) => protected override void Apply(IImageProcessingContext ctx, int value, Rectangle bounds) =>
ctx.GaussianBlur(value, bounds); ctx.GaussianBlur(bounds, value);
} }

2
tests/ImageSharp.Tests/Processing/Processors/Convolution/GaussianSharpenTest.cs

@ -12,5 +12,5 @@ public class GaussianSharpenTest : Basic1ParameterConvolutionTests
protected override void Apply(IImageProcessingContext ctx, int value) => ctx.GaussianSharpen(value); protected override void Apply(IImageProcessingContext ctx, int value) => ctx.GaussianSharpen(value);
protected override void Apply(IImageProcessingContext ctx, int value, Rectangle bounds) => protected override void Apply(IImageProcessingContext ctx, int value, Rectangle bounds) =>
ctx.GaussianSharpen(value, bounds); ctx.GaussianSharpen(bounds, value);
} }

2
tests/ImageSharp.Tests/Processing/Processors/Convolution/MedianBlurTest.cs

@ -12,5 +12,5 @@ public class MedianBlurTest : Basic1ParameterConvolutionTests
protected override void Apply(IImageProcessingContext ctx, int value) => ctx.MedianBlur(value, true); protected override void Apply(IImageProcessingContext ctx, int value) => ctx.MedianBlur(value, true);
protected override void Apply(IImageProcessingContext ctx, int value, Rectangle bounds) => protected override void Apply(IImageProcessingContext ctx, int value, Rectangle bounds) =>
ctx.MedianBlur(value, true, bounds); ctx.MedianBlur(bounds, value, true);
} }

Loading…
Cancel
Save