PSNR
def psnr(src, target, k=8):
src = np.float32(src)
target = np.float32(target)
fmax = 2 ** 8 - 1
try:
mse = np.square(src - target)
except:
print('diffent shapes, please check!')
return
mean = np.mean(mse)
psnr = 10 * np.log10(np.square(fmax) / mean)
print("PSNR:",psnr)
return psnr
SSIM
from skimage.measure import compare_psnr,compare_ssim
psnr = compare_psnr(img,img2)
ssim = compare_ssim(img,img,multichannel=True)
HS