All problems
Frame Differencing
Problem
Compare two consecutive grayscale frames pixel by pixel.
Return 255 where abs(curr - prev) is strictly greater than threshold and 0 otherwise. Both frames have the same shape.
Test cases
case 1
in: [[[0,100],[200,255]],[[0,120],[150,255]],10]
expected: [[0,255],[255,0]]
case 2
in: [[[5,5]],[[15,5]],9]
expected: [[255,0]]
case 3
in: [[[1,2],[3,4]],[[1,2],[3,4]],0]
expected: [[0,0],[0,0]]
Starter codePython
def frame_diff(prev, curr, threshold):
# Your code here
pass3 test cases · run your code against them in the editor