ValueError: operands could not be broadcast together with shapes (194,259,3) (600,800,3) I got ValueError: operands could not be broadcast together with shapes (194,259,3) (600,800,3) with the below code:
import numpy 
import math
import cv2
original = cv2.imread(&quot;original.png&quot;)
contrast = cv2.imread(&quot;compressed.png&quot;,1)
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))

d=psnr(original,contrast)
print(d)

What was the problem with the implementation?
It sounds like the error is indicating that the two images aren't the same size.  So you can't subtract them point for point.