The function calculates 1-D Gaussian kernel, which is array of Gaussian function's values in the [-r, r] range of x value, where r=floor(size/2).
public static double[] Kernel(double sigmaSquared, int size) { // check for evem size and for out of range if (((size % 2) == 0) || (size < 3)) throw new ArgumentOutOfRangeException("size", "Kernel size must be odd and higher than 2."); int r = size / 2; double[] kernel = new double[size]; for (int x = -r, i = 0; i < size; x++, i++) kernel[i] = Gaussian(sigmaSquared, x); return kernel; }