namespace NodePipeline.Application.ImageProcessing;

public static class GaussianKernel
{
    public static float[] Create(int radius)
    {
        var size = radius * 2 + 1;
        var kernel = new float[size];
        var sigma = radius / 2f;
        float sum = 0;

        for (var i = 0; i < size; i++)
        {
            var x = i - radius;
            kernel[i] = (float)Math.Exp(-(x * x) / (2 * sigma * sigma));
            sum += kernel[i];
        }

        for (var i = 0; i < size; i++) kernel[i] /= sum;

        return kernel;
    }
}