All problems
Image MSE
Problem
Compute the mean squared error between two same-shaped grayscale images.
For every pixel accumulate (a - b)^2 and divide by the number of pixels, rounding the result to 4 decimal places. The images are non-empty and have equal shapes.
Hint
Square every pixel difference before averaging.
Test cases
case 1
in: [[[1,2],[3,4]],[[1,1],[3,6]]]
expected: 1.25
case 2
in: [[[1,2],[3,4]],[[1,2],[3,4]]]
expected: 0
case 3
in: [[[5]],[[3]]]
expected: 4
Starter codePython
def image_mse(a, b):
# Your code here
pass3 test cases · run your code against them in the editor