File size: 204 Bytes
d4b77ac
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
import numpy
import math


def psnr(img1, img2):
    mse = numpy.mean( (img1 - img2) ** 2 )
    if mse == 0:
        return 100
    PIXEL_MAX = 255.0
    return 20 * math.log10(PIXEL_MAX / math.sqrt(mse))