All problems
Difference of Gaussians
Problem
Compute the difference of two Gaussian blurs.
Apply a normalized 3x3 Gaussian kernel for sigma1 and sigma2 with valid-mode cross-correlation, subtract the second response from the first, and round to 4 decimal places. The output shape is (H - 2) x (W - 2).
Hint
Normalize each kernel by its own sum before subtracting the responses.
Test cases
case 1
in: [[[6,6,6],[6,6,6],[6,6,6]],0.5,1]
expected: [[0]]
case 2
in: [[[0,0,0],[0,10,0],[0,0,0]],0.5,1]
expected: [[4.1517]]
case 3
in: [[[1,2,3],[4,5,6],[7,8,9]],1,2]
expected: [[0]]
case 4
in: [[[1,1,1,1,1],[1,5,5,5,1],[1,5,9,5,1],[1,5,5,5,1],[1,1,1,1,1]],0.8,1.5]
expected: [[0.2495,0.301,0.2495],[0.301,0.4989,0.301],[0.2495,0.301,0.2495]]
Starter codePython
def difference_of_gaussians(image, sigma1, sigma2):
# Your code here
pass4 test cases · run your code against them in the editor