对比图像
像素间一一对比
- 示例,注意要进行正向和反向对比(应该是因为cv2.subtract相减负数可能被设置为0了?)
def mse(img1, img2):
h, w, _ = img1.shape
## need to compare in two ways
diff1 = cv2.subtract(img1, img2)
err1 = np.sum(diff1**2)
diff2 = cv2.subtract(img2, img1)
err2 = np.sum(diff2**2)
err = max(err1, err2)
return err/(float(h*w))