当前位置:网站首页>图像超分辨率评价指标
图像超分辨率评价指标
2022-07-27 05:13:00 【Mr_health】
参考文章:https://zhuanlan.zhihu.com/p/50757421
https://blog.csdn.net/weixin_36815313/article/details/108531674



实现方式有两种
- skimage.measure.compare_ssim
sk_psnr = skimage.measure.compare_psnr(im1, im2, 255)
print(sk_psnr )- 手动实现
def calculate_psnr(img1, img2):
# img1 and img2 have range [0, 255]
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))以上两种方式的计算结果一致。
一般来说,MSE越小,则PSNR 越大,代表着图像质量越好。
- PSNR高于40dB说明图像质量极好(即非常接近原始图像)
- 在30-40dB通常表示图像质量是好的(即失真可以察觉但可以接受)
- 在20-30dB说明图像质量差
- 低于20dB图像不可接受

对于三通道的图像,对每个通道分别求ssim值,之后求平均,最大值为1.0
实现方式有两种
- skimage.measure.compare_ssim
sk_ssim = measure.compare_ssim(img1, img2, gaussian_weights = True,multichannel = True, data_range=255)
print(sk_ssim )- 手动实现
def calculate_ssim(img1, img2):
'''calculate SSIM
the same outputs as MATLAB's
img1, img2: [0, 255]
'''
if not img1.shape == img2.shape:
raise ValueError('Input images must have the same dimensions.')
if img1.ndim == 2:
return ssim(img1, img2)
elif img1.ndim == 3:
if img1.shape[2] == 3:
ssims = []
for i in range(3):
ssims.append(ssim(img1, img2))
return np.array(ssims).mean()
elif img1.shape[2] == 1:
return ssim(np.squeeze(img1), np.squeeze(img2))
else:
raise ValueError('Wrong input image dimensions.')
def ssim(img1, img2):
C1 = (0.01 * 255)**2
C2 = (0.03 * 255)**2
img1 = img1.astype(np.float64)
img2 = img2.astype(np.float64)
kernel = cv2.getGaussianKernel(11, 1.5)
window = np.outer(kernel, kernel.transpose())
mu1 = cv2.filter2D(img1, -1, window)[5:-5, 5:-5] # valid
mu2 = cv2.filter2D(img2, -1, window)[5:-5, 5:-5]
mu1_sq = mu1**2
mu2_sq = mu2**2
mu1_mu2 = mu1 * mu2
sigma1_sq = cv2.filter2D(img1**2, -1, window)[5:-5, 5:-5] - mu1_sq
sigma2_sq = cv2.filter2D(img2**2, -1, window)[5:-5, 5:-5] - mu2_sq
sigma12 = cv2.filter2D(img1 * img2, -1, window)[5:-5, 5:-5] - mu1_mu2
ssim_map = ((2 * mu1_mu2 + C1) * (2 * sigma12 + C2)) / ((mu1_sq + mu2_sq + C1) *
(sigma1_sq + sigma2_sq + C2))
return ssim_map.mean()
以上两种方式的计算结果基本一致。
SSIM,Structural Similarity,结构相似性. 也是衡量两幅图片相似性的指标.
结构相似性的基本原理是,认为自然图像时高度结构化的,即相邻像素间具有很强的关联性,而这种关联性表达了场景中物体的结构信息. 人类视觉系统对于图像已经具有很强的理解与信息抽取能力,所以在衡量图像质量时,结构性失真是很重要的考量
边栏推荐
- Gbase 8C - SQL reference 5 full text search
- GBASE 8C——SQL参考 5 全文检索
- Day 15. Deep learning radiomics can predict axillary lymphnode status in early-stage breast cancer
- 3.分类问题---手写数字识别初体验
- GBASE 8C——SQL参考6 sql语法(10)
- Day10. Work organization and mental health problems in PhD students
- GBase 8c技术特点
- Jenkins build image automatic deployment
- 4.张量数据类型和创建Tensor
- 2020年PHP中级面试知识点及答案
猜你喜欢

4. Tensor data type and creation tensor

Seektiger's okaleido has a big move. Will the STI of ecological pass break out?

MySQL如何执行查询语句

数字图像处理 第一章 绪论

If you encounter oom online, how to solve it?

The LAF protocol elephant of defi 2.0 may be one of the few profit-making means in your bear market

5. Indexing and slicing

14.实例-多分类问题

Numpy基础学习

Digital image processing Chapter 2 fundamentals of digital image
随机推荐
2021中大厂php+go面试题(1)
18.卷积神经网络
「中高级试题」:MVCC实现原理是什么?
The LAF protocol elephant of defi 2.0 may be one of the few profit-making means in your bear market
7.合并与分割
Social media user level psychological stress detection based on deep neural network
12.优化问题实战
Digital image processing -- Chapter 9 morphological image processing
Day 15. Deep learning radiomics can predict axillary lymphnode status in early-stage breast cancer
Day 4.Social Data Sentiment Analysis: Detection of Adolescent Depression Signals
Numpy basic learning
GBASE 8C——SQL参考6 sql语法(10)
GBase 8c核心技术
19.上下采样与BatchNorm
Read and understand the advantages of the LAAS scheme of elephant swap
Uboot supports LCD and HDMI to display different logo images
1. Introduction to pytorch
Day 17.The role of news sentiment in oil futures returns and volatility forecasting
Day 8.Developing Simplified Chinese Psychological Linguistic Analysis Dictionary for Microblog
Emoji表情符号用于文本情感分析-Improving sentiment analysis accuracy with emoji embedding