代码拉取完成,页面将自动刷新
import math
import numpy as np
def compute_psnr(img1, img2):
img1 = img1.astype(np.float64) / 255.
img2 = img2.astype(np.float64) / 255.
mse = np.mean((img1 - img2) ** 2)
if mse == 0:
return "Same Image"
return 10 * math.log10(1. / mse)
if __name__ == '__main__':
import cv2
im_dir = 'test_data/image'
im_s2_dir = 'result_compare/sigma2'
im_s5_dir = 'result_compare/sigma5'
im_s10_dir = 'result_compare/sigma10'
im_name = 'Alley.png'
im_path = 'test_data/image/Alley.png'
im_1st_path = 'result_compare/sigma2/Alley_s2_cpp_1st_P39.781.png'
im_2nd_path = 'result_compare/sigma2/Alley_s2_cpp_2nd_P44.582.png'
im_1st_path = 'result_compare/sigma2/Alley_s2_py_1st_P44.369.png'
im_2nd_path = 'result_compare/sigma2/Alley_s2_py_2nd_P44.62.png'
img0 = cv2.imread(im_path, cv2.IMREAD_GRAYSCALE)
img1 = cv2.imread(im_1st_path, cv2.IMREAD_GRAYSCALE)
img2 = cv2.imread(im_2nd_path, cv2.IMREAD_GRAYSCALE)
psnr1 = compute_psnr(img0, img1)
psnr2 = compute_psnr(img0, img2)
print('img and img_basic PSNR: ', psnr1)
print('img and img_denoised PSNR: ', psnr2)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。