All problems
Sharpen Filter
Problem
Sharpen a grayscale image with the 3x3 kernel [[0, -1, 0], [-1, 5, -1], [0, -1, 0]].
Apply valid-mode cross-correlation and return integer values. Constant regions are unchanged; no clamping is applied.
Test cases
case 1
in: [[[7,7,7],[7,7,7],[7,7,7]]]
expected: [[7]]
case 2
in: [[[0,0,0],[0,10,0],[0,0,0]]]
expected: [[50]]
case 3
in: [[[1,2,3],[4,5,6],[7,8,9]]]
expected: [[5]]
case 4
in: [[[1,1,1,1],[1,5,5,1],[1,5,5,1],[1,1,1,1]]]
expected: [[13,13],[13,13]]
Starter codePython
def sharpen(image):
# Your code here
pass4 test cases · run your code against them in the editor