用作记录,以备不时之需:
from skimage.measure import compare_ssim
def psnr(img1, img2):
assert img1.dtype == img2.dtype == np.uint8, 'np.uint8 is supposed.'
img1 = img1.astype(np.float64)
img2 = img2.astype(np.float64)
mse = np.mean((img1 - img2)**2)
if mse == 0:
return float('inf')
return 20 * math.log10(255.0 / math.sqrt(mse))
def ssim(img1, img2, multichannel=False):
assert img1.dtype == img2.dtype == np.uint8, 'np.uint8 is supposed.'
return compare_ssim(img1, img2, multichannel=multichannel)

该博客介绍了两种常用的图像质量评估方法:Peak Signal-to-Noise Ratio (PSNR)和Structural Similarity Index (SSIM)。通过Python代码展示了如何计算这两个指标,适用于图像处理和计算机视觉领域的质量分析。
11万+

被折叠的 条评论
为什么被折叠?



