diff --git a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessorHelpers.cs b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessorHelpers.cs
index ebda2eb079..37adaf5402 100644
--- a/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessorHelpers.cs
+++ b/src/ImageSharp/Processing/Processors/Convolution/ConvolutionProcessorHelpers.cs
@@ -9,6 +9,7 @@ internal static class ConvolutionProcessorHelpers
/// Kernel radius is calculated using the minimum viable value.
/// See .
///
+ /// The weight of the blur.
internal static int GetDefaultGaussianRadius(float sigma)
=> (int)MathF.Ceiling(sigma * 3);
@@ -16,9 +17,11 @@ internal static class ConvolutionProcessorHelpers
/// Create a 1 dimensional Gaussian kernel using the Gaussian G(x) function.
///
/// The convolution kernel.
+ /// The kernel size.
+ /// The weight of the blur.
internal static float[] CreateGaussianBlurKernel(int size, float weight)
{
- var kernel = new float[size];
+ float[] kernel = new float[size];
float sum = 0F;
float midpoint = (size - 1) / 2F;
@@ -44,9 +47,11 @@ internal static class ConvolutionProcessorHelpers
/// Create a 1 dimensional Gaussian kernel using the Gaussian G(x) function
///
/// The convolution kernel.
+ /// The kernel size.
+ /// The weight of the blur.
internal static float[] CreateGaussianSharpenKernel(int size, float weight)
{
- var kernel = new float[size];
+ float[] kernel = new float[size];
float sum = 0;
diff --git a/tests/ImageSharp.Tests/Processing/Processors/Convolution/ConvolutionProcessorHelpersTest.cs b/tests/ImageSharp.Tests/Processing/Processors/Convolution/ConvolutionProcessorHelpersTest.cs
index 740bdddafd..574c983710 100644
--- a/tests/ImageSharp.Tests/Processing/Processors/Convolution/ConvolutionProcessorHelpersTest.cs
+++ b/tests/ImageSharp.Tests/Processing/Processors/Convolution/ConvolutionProcessorHelpersTest.cs
@@ -1,73 +1,70 @@
// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
-using System;
using SixLabors.ImageSharp.Processing.Processors.Convolution;
-using Xunit;
-namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution
+namespace SixLabors.ImageSharp.Tests.Processing.Processors.Convolution;
+
+[GroupOutput("Convolution")]
+public class ConvolutionProcessorHelpersTest
{
- [GroupOutput("Convolution")]
- public class ConvolutionProcessorHelpersTest
+ [Theory]
+ [InlineData(3)]
+ [InlineData(5)]
+ [InlineData(9)]
+ [InlineData(22)]
+ [InlineData(33)]
+ [InlineData(80)]
+ public void VerifyGaussianKernelDecomposition(int radius)
{
- [Theory]
- [InlineData(3)]
- [InlineData(5)]
- [InlineData(9)]
- [InlineData(22)]
- [InlineData(33)]
- [InlineData(80)]
- public void VerifyGaussianKernelDecomposition(int radius)
- {
- int kernelSize = (radius * 2) + 1;
- float sigma = radius / 3F;
- float[] kernel = ConvolutionProcessorHelpers.CreateGaussianBlurKernel(kernelSize, sigma);
- DenseMatrix matrix = DotProduct(kernel, kernel);
+ int kernelSize = (radius * 2) + 1;
+ float sigma = radius / 3F;
+ float[] kernel = ConvolutionProcessorHelpers.CreateGaussianBlurKernel(kernelSize, sigma);
+ DenseMatrix matrix = DotProduct(kernel, kernel);
- bool result = matrix.TryGetLinearlySeparableComponents(out float[] row, out float[] column);
+ bool result = matrix.TryGetLinearlySeparableComponents(out float[] row, out float[] column);
- Assert.True(result);
- Assert.NotNull(row);
- Assert.NotNull(column);
- Assert.Equal(row.Length, matrix.Rows);
- Assert.Equal(column.Length, matrix.Columns);
+ Assert.True(result);
+ Assert.NotNull(row);
+ Assert.NotNull(column);
+ Assert.Equal(row.Length, matrix.Rows);
+ Assert.Equal(column.Length, matrix.Columns);
- float[,] dotProduct = DotProduct(row, column);
+ float[,] dotProduct = DotProduct(row, column);
- for (int y = 0; y < column.Length; y++)
+ for (int y = 0; y < column.Length; y++)
+ {
+ for (int x = 0; x < row.Length; x++)
{
- for (int x = 0; x < row.Length; x++)
- {
- Assert.True(Math.Abs(matrix[y, x] - dotProduct[y, x]) < 0.0001F);
- }
+ Assert.True(Math.Abs(matrix[y, x] - dotProduct[y, x]) < 0.0001F);
}
}
+ }
- [Fact]
- public void VerifyNonSeparableMatrix()
- {
- bool result = LaplacianKernels.LaplacianOfGaussianXY.TryGetLinearlySeparableComponents(
- out float[] row,
- out float[] column);
+ [Fact]
+ public void VerifyNonSeparableMatrix()
+ {
+ bool result = LaplacianKernels.LaplacianOfGaussianXY.TryGetLinearlySeparableComponents(
+ out float[] row,
+ out float[] column);
- Assert.False(result);
- Assert.Null(row);
- Assert.Null(column);
- }
+ Assert.False(result);
+ Assert.Null(row);
+ Assert.Null(column);
+ }
- private static DenseMatrix DotProduct(float[] row, float[] column)
- {
- float[,] matrix = new float[column.Length, row.Length];
+ private static DenseMatrix DotProduct(float[] row, float[] column)
+ {
+ float[,] matrix = new float[column.Length, row.Length];
- for (int x = 0; x < row.Length; x++)
+ for (int x = 0; x < row.Length; x++)
+ {
+ for (int y = 0; y < column.Length; y++)
{
- for (int y = 0; y < column.Length; y++)
- {
- matrix[y, x] = row[x] * column[y];
- }
+ matrix[y, x] = row[x] * column[y];
}
-
- return matrix;
}
+
+ return matrix;
}
}