How do I calculate the maximum signal to noise ratio (PSNR) in Python? Is there any library that can calculate PSNR for Image?
The steps for calculation of PSNR value of two images:
For details click here
import numpy import math import cv2 original = cv2.imread("original.png") contrast = cv2.imread("photoshopped.png",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)
If you have a replica of your signal (image) that is noise free, you can calculate the correlation coefficient which is directly related to SNR.
See my response here for specific details on determining the correlation coefficient and from that SNR:
In this context there is no "maximum SNR" but will be the SNR for your entire image, meaning the power of your desired signal relative to everything else (distortions).