Skip to content
DeepForgeby svx
All problems
MediumComputer Visioncv-097

Image PSNR

Problem

Compute the peak signal-to-noise ratio between two same-shaped images in decibels.

Return 10 * log10(max_value^2 / MSE) rounded to 4 decimal places, where MSE is the mean squared pixel error. Return 0.0 when the images are identical.

Test cases

case 1
in: [[[1,2],[3,4]],[[1,1],[3,6]],255]
expected: 47.1617
case 2
in: [[[0]],[[1]],7]
expected: 16.902
case 3
in: [[[1,2],[3,4]],[[1,2],[3,4]],255]
expected: 0
case 4
in: [[[10,20]],[[12,18]],255]
expected: 42.1102
Starter codePython
def image_psnr(a, b, max_value):
    # Your code here
    pass

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