图像相似性评价指标(SSIM、MSE、PSNR)简单介绍及计算方法

本文详细介绍如何在Python中利用skimage库计算SSIM(结构相似性)、MSE(均方误差)和PSNR(峰值信噪比)来评估图像的相似度。通过实例展示如何读取图片并计算这些常用指标,帮助理解图像生成质量的评价标准。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

图像相似性评价指标

对于图像生成质量的通用性评价指标主要有SSIM、MSE、PSNR。

SSIM(结构相似性)

结构相似性(Structrual Similarity Index Metric,SSIM)是用来评估两幅图像之间的相似水平,对于图像x和y,其结构相似性的计算公式如下:
在这里插入图片描述
其中,SSIM的范围为0-1,值越接近1,说明图像越相似。

MSE(均方误差)

均方误差(Mean Squared Error,MSE)是用来评估修复后的图像I与原始图像K之间像素级别上的差异程度,MSE计算公式如下:
在这里插入图片描述
其中, M为图像I的像素总数,N为图像K的像素总数。MSE值越小,说明图像越相似。

PSNR(峰值信噪比 )

峰值信噪比(Peak Signal to Noise Ration,PSNR)是用来评价噪声水平或图像失真的客观评价指标,其计算公式如下:
在这里插入图片描述
其中,MSE为两张图像的均方误差, 为图像中像素最大值。PSNR越大说明失真越少,生成图像的质量越好。

使用python进行计算

// 导入库函数
from skimage.measure import compare_ssim, compare_psnr, compare_mse
import cv2

def getSSIM(img1, img2):
	return compare_ssim(img1, img2, multichannel=True)  # 对于多通道图像(RGBHSV)关键词multichannel要设置为True

def getPSNR(img1, img2):
	return compare_psnr(img1, img2)

def getMSE(img1, img2):
	return compare_mse(img1, img2)

if __name__=='main':
	img1 = cv2.imread(r'')
	img2 = cv2.imread(r'')
	
	getSSIM(img1, img2)
	getPSNR(img1, img2)
	getMSE(img1, img2)
Group Linux, also known as "Linux distributions," refers to the various operating system distributions built upon the Linux kernel, which is an open-source and free software project developed by Linus Torvalds in 1991. These distributions are created by different teams around the world and offer a user-friendly interface, pre-installed software packages, and customization options tailored to meet the needs of different users and use cases. Some popular examples of Linux distributions include: 1. Ubuntu: A widely-used distribution known for its simplicity and frequent updates. It's based on Debian and popular among both beginners and professionals. 2. Red Hat Enterprise Linux (RHEL): Primarily designed for enterprise environments, it's known for its stability and support. RHEL derivatives like CentOS and Fedora are also widely used. 3. Debian: One of the oldest and most stable distributions, Debian is the foundation for many other distributions like Ubuntu. 4. CentOS: A community-supported version of Red Hat Enterprise Linux, offering a long-term support cycle. 5. Arch Linux: A lightweight and highly customizable distribution that encourages users to manage their systems manually. 6. Android: Although not technically a traditional Linux distribution, it uses a Linux kernel for its mobile operating system. Each distribution has its own package manager, desktop environments (like GNOME, KDE, or XFCE), and community support. Users can choose based on their requirements, hardware compatibility, and familiarity with the software stack.
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值