遍历图像对计算psnr,ssim,IE

import os
import numpy as np
from scipy.misc import imread ,imresize
from PIL import Image
from skimage import color
from skimage.measure import compare_ssim, compare_psnr, compare_mse
from tqdm import tqdm
path1 = './A'
path2 = './B'

total_p = 0
total_s = 0

print('[***]calc...')
images = os.listdir(path1)
for image in tqdm(images):
    # image pair have same size

    img1 = imresize(imread(os.path.join(path1,image)),(576,720))
    # print(type(img1)) = numpy.ndarray
    img2 = imread(os.path.join(path2,'B'+image[1:]))
    # 断言尺寸不同则抛出异常    
    assert img1.size == img2.size ,\
	"image pair should have same size,check the img_size(w,h) "

    err = img1 - img2
    ie = np.mean(np.sqrt(np.sum(err * err, axis=2)))

    psnr = compare_psnr(img1,img2)
    ssim = compare_ssim(img1,img2,multichannel=1)
    n = len(images)
    # print(psnr,ssim)
    total_p += psnr
    total_s += ssim
    mean_p = total_p/n
    mean_s = total_s/n

print("avg_PSNR , avg_SSIM :","%.2f"% mean_p,",","%.3f"% mean_s)
print('Interpolation Error :',"%.2f"% ie)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值