All problems
Gaussian Blur
Problem
Blur a grayscale image with a Gaussian kernel.
Build the normalized Gaussian kernel for the given odd size and sigma using the same formula as Gaussian kernel generation, then apply valid-mode cross-correlation. Round each output value to 4 decimal places.
Hint
Generate and normalize the weights first, then run a sliding-window sum.
Test cases
case 1
in: [[[5,5,5],[5,5,5],[5,5,5]],3,1]
expected: [[5]]
case 2
in: [[[1,2,3],[4,5,6],[7,8,9]],3,1]
expected: [[5]]
case 3
in: [[[1,1,1,1],[1,5,5,1],[1,5,5,1],[1,1,1,1]],3,1]
expected: [[3.1079,3.1079],[3.1079,3.1079]]
Starter codePython
def gaussian_blur(image, size, sigma):
# Your code here
pass3 test cases · run your code against them in the editor