All problems
Keypoint Local Max
Problem
Keep only strict local maxima of a response map.
A pixel is kept with its value rounded to 4 decimals when it is strictly greater than all 8 neighbors and strictly greater than threshold; border pixels are always 0.
Hint
Strict comparisons reject plateaus, so equal neighbors kill the keypoint.
Test cases
case 1
in: [[[0,0,0],[0,9,0],[0,0,0]],5]
expected: [[0,0,0],[0,9,0],[0,0,0]]
case 2
in: [[[1,2,1],[2,9,2],[1,2,1]],5]
expected: [[0,0,0],[0,9,0],[0,0,0]]
case 3
in: [[[0,0,0],[0,9,9],[0,9,9]],5]
expected: [[0,0,0],[0,0,0],[0,0,0]]
case 4
in: [[[0,0,0],[0,4,0],[0,0,0]],5]
expected: [[0,0,0],[0,0,0],[0,0,0]]
Starter codePython
def keypoint_local_max(response, threshold):
# Your code here
pass4 test cases · run your code against them in the editor