Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-024

Laplacian Filter

Problem

Apply the 3x3 Laplacian kernel [[0, 1, 0], [1, -4, 1], [0, 1, 0]] to a grayscale image.

Use valid-mode cross-correlation and return integer values. Constant regions produce 0 and central differences are negative.

Test cases

case 1
in: [[[4,4,4],[4,4,4],[4,4,4]]]
expected: [[0]]
case 2
in: [[[0,0,0],[0,5,0],[0,0,0]]]
expected: [[-20]]
case 3
in: [[[1,2,3],[4,5,6],[7,8,9]]]
expected: [[0]]
Starter codePython
def laplacian(image):
    # Your code here
    pass

3 test cases · run your code against them in the editor