常用评价指标及其Python实现

更新时间:2023-06-17 09:39:02 阅读: 评论:0

常⽤评价指标及其Python实现
⾼光谱图像重构评价指标及其Python实现
⾼光谱图像重构的评价指标通常有三项。其中部分指标从普通图像变化⽽来,部分指标只有⾼光谱图像独有。本⽂拟从以下两个⾓度介绍⾼光谱图像评价指标,并列出基于Python语⾔的skimage库的对应实现⽅法。
1)从普通图像重构评价指标到⾼光谱图像重构评价指标
2)从普通图像重构评价指标代码到⾼光谱图像重构评价指标代码
⼀、MSE
爱鸟护鸟的宣传语MSE计算两组数据的均⽅误差,是最常⽤的评价相似度的准则,包括但不限于图像、信号。
Skimage库中对应的函数原型:
Parameters:im1, im2 : ndarray Image. Any dimensionality.
Returns:m : float
The mean-squared error (MSE) metric.
想要测度其他距离,参考compare_nrm函数
⼆、PSNR与MPSNR
1. PSNR
PSNR全称是Compute the peak signal to noi ratio。⽤于计算原始图像与重构图像之间的峰值信噪⽐。在图像超分辨率等任务中尤为常⽤,如同错误率之于分类任务,PSNR是图像重构任务事实上的基准评价准则。
Parameters:im_true : ndarray
Ground-truth image.
im_test : ndarray
Test image.
data_range : int
The data range of the input image (distance between minimum and maximum possible values). By default, this is estimated from the image data-type.
野性的思维
Returns:psnr : float
The PSNR metric.
2. MPSNR
MPSNR⽤于计算两幅⾼光谱图像之间的平均峰值信噪⽐。MPSNR计算⽅法很简单,只需要分别计算不同波段的PSNR,取均值就可以了。
1 def mpsnr(x_true, x_pred):
2    """
3
4    :param x_true: ⾼光谱图像:格式:(H, W, C)
5    :param x_pred: ⾼光谱图像:格式:(H, W, C)
6    :return: 计算原始⾼光谱数据与重构⾼光谱数据的均⽅误差
7    References
8    ----------
9    .. [1] en.wikipedia/wiki/Peak_signal-to-noi_ratio
10    """
消防安全宣传日
11    n_bands = x_true.shape[2]
12    p = [compare_psnr(x_true[:, :, k], x_pred[:, :, k], dynamic_range=np.max(x_true[:, :, k])) for k in range(n_bands)]
13    an(p)
三、SSIM与MSSIM
1. SSIM⽤于计算两幅图像之间的平均结构相似度。
Parameters:X, Y : ndarray
Image. Any dimensionality.
win_size : int or None
The side-length of the sliding window ud in comparison. Must be an odd value. If gaussian_weights is True, this is ignored and the window size will depend on sigma.
gradient : bool, optional
If True, also return the gradient.
data_range : int, optional
The data range of the input image (distance between minimum and maximum possible values). By d
efault, this is estimated from the image data-type.
multichannel : bool, optional
报告会If True, treat the last dimension of the array as channels. Similarity calculations are done independently for each channel then averaged.
gaussian_weights : bool, optional
If True, each patch has its mean and variance spatially weighted by a normalized Gaussian kernel of width sigma=1.5.
full : bool, optional
If True, return the full structural similarity image instead of the mean value.
Returns:mssim : float
The mean structural similarity over the image.
grad : ndarray
The gradient of the structural similarity index between X and Y . This is only returned if gradient is t to True.
S : ndarray
夺俸The full SSIM image. This is only returned if full is t to True.
Other Parameters:
u_sample_covariance : bool
if True, normalize covariances by N-1 rather than, N where N is the number of pixels within the sliding
window.
K1 : float
algorithm parameter, K1 (small constant, e )
K2 : float
algorithm parameter, K2 (small constant, e )
sigma : float
大钟亭sigma for the Gaussian when gaussian_weights is True.
2. MSSIM
MSSIM⽤于计算两幅⾼光谱图像之间的平均结构相似度。MSSIM计算⽅法很简单,只需要分别计算不同波段的SSIM指数,取均值就可以了。
1 def mssim(x_true,x_pred):
2    """
3        :param x_true: ⾼光谱图像:格式:(H, W, C)
4        :param x_pred: ⾼光谱图像:格式:(H, W, C)
丰乐亭游春其一5        :return: 计算原始⾼光谱数据与重构⾼光谱数据的结构相似度
6    """
7    SSIM = compare_ssim(X=x_true, Y=x_pred, multichannel=True)
8    return SSIM
四、SAM
SAM这个概念只存在于多/⾼光谱图像,普通图像没有这个概念。SAM⼜称光谱⾓相似度,⽤于度量原始⾼光谱数据与重构⾼光谱数据之间的光谱相似度。
1 def sam(x_true, x_pred):
花生馅汤圆2    """
3    :param x_true: ⾼光谱图像:格式:(H, W, C)
4    :param x_pred: ⾼光谱图像:格式:(H, W, C)
5    :return: 计算原始⾼光谱数据与重构⾼光谱数据的光谱⾓相似度
6    """
7    asrt x_true.ndim ==3 and x_true.shape == x_pred.shape
8    sam_rad = np.zeros(x_pred.shape[0, 1])
9    for x in range(x_true.shape[0]):
10        for y in range(x_true.shape[1]):
11            tmp_pred = x_pred[x, y].ravel()
12            tmp_true = x_true[x, y].ravel()
13            sam_rad[x, y] = np.arccos(tmp_pred / (norm(tmp_pred) * tmp_true / norm(tmp_true)))
14    sam_deg = an() * 180 / np.pi
15    return sam_deg
五、相关资料
0. ⽂中⽤到的代码
1. ⽂中提到的函数的⽂档
2. PSNR维基百科链接
3. SSIM参考⽂献

本文发布于:2023-06-17 09:39:02,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1042307.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:图像   光谱   重构   评价   指标   数据
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图