0

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
Yevhen Kuzmovych
  • 10,940
  • 7
  • 28
  • 48
  • What PSNR value do you expect when MSE is 0? – Yevhen Kuzmovych Mar 16 '21 at 15:03
  • SNR and PSNR approach infinity as the noise approaches zero. Those measures are not suitable if there is a possibility of zero noise (which never happens in real life). – Cris Luengo Mar 16 '21 at 19:08
  • When the images are identical, I am getting MSE=0. For those identical images, what should be the ideal value for PSNR ? Should it be as high as infinity ?@YevhenKuzmovych – Bansari Vadgama Mar 17 '21 at 15:09

0 Answers0