图像质量评价指标:SSIM

SSIM(Structural Similarity),结构相似性,是一种衡量两幅图像相似度的指标。该指标首先由德州大学奥斯丁分校的图像和视频工程实验室(Laboratory for Image and Video Engineering)提出。SSIM使用的两张图像中,一张为未经压缩的无失真图像,另一张为失真后的图像。

修改的地方只有以下两行 street和python1是创建的directory各存放50张图片

image_path1 = "street/"+i+".png"
image_path2 = "python1/"+i+".png"

python实现

from skimage.metrics import peak_signal_noise_ratio
from skimage.metrics import structural_similarity
import skimage.io as io


for i in range(1, 51):
    i = str(i)
    image_path1 = "street/"+i+".png"

    image_path2 = "python1/"+i+".png"

    # 因为是张彩色图片所以截取出一个通道
    image1 = io.imread(image_path1)[..., 0]
    image2 = io.imread(image_path2)[..., 0]

    psnr_val = peak_signal_noise_ratio(image1, image2)
    ssim_val = structural_similarity(image1, image2, win_size=11, gaussian_weights=True, multichannel=False,
                                     data_range=255, K1=0.01, K2=0.03, sigma=1.5)

    # print("ssim_val",i, ssim_val)
    print(ssim_val)

你可能感兴趣的:(python,人工智能,计算机视觉,python,人工智能)