Build a Gaussian Blur Kernel
Problem statement
Return a centered k × k Gaussian blur kernel with standard deviation sigma.
For offsets x,y from the center, use a value proportional to exp(-(x²+y²)/(2·sigma²)), then normalize all entries so their sum is 1.
Function
gaussianKernel(k: int, sigma: double) → double[][]Examples
Example 1
k = 3sigma = 1.0return = [[0.07511360795411151,0.12384140315297397,0.07511360795411151],[0.12384140315297397,0.2041799555716581,0.12384140315297397],[0.07511360795411151,0.12384140315297397,0.07511360795411151]]The center has the greatest weight and the normalized matrix sums to one.
Constraints
1 <= k <= 31andkis odd.0.1 <= sigma <= 20.- Results use absolute tolerance
1e-9.