What should be the value of PSNR(Peak Signal to Noise Ratio) be when MSE(Mean Square Error) is 0 ? I am getting error when rmse = 0. So , what changes could be done to improve and get the psnr value even when rmse is zero ?
Following is my code for calculating PSNR in Python.
The following function will calculate psnr
def PSNR(firstImage,secondImage):
target_data = firstImage.astype(float)
ref_data = secondImage.astype(float)
diff = ref_data - target_data
diff = diff.flatten('C')
rmse = math.sqrt(np.mean(diff ** 2.))
psnrResultValue = 20 * math.log10(255. / rmse)
print("PSNR:", + psnrResultValue)
return psnrResultValue