文章目录
1.光谱重建论文:In Defense of Shallow Learned Spectral Reconstruction from RGB Images
1.1Anchored Neighborhood Regression for Fast Example-Based Super-Resolution
A+算法介绍
1.1.1首先介绍下Neighbor embedding approaches(NE)
- 首先有一个数据库,数据库包含低分辨率图像的像素或特征,和对应高分辨率图像的像素或者提取的特征
- 输入低分辨率的patch,提取特征,找到数据库中的K近邻,并根据距离计算weight
- 将weight应用到对应的高分辨率的patch, 加权得到 高分辨率的patch
- 主要就是K近邻插值
1.1.2.然后介绍下 Sparse coding approaches(SC)
- 一般情况下使用K-SVD方法建立 低分辨率字典和对应的高分辨率字典
- 输入低分辨率图像,然后OMP方法计算 低分辨率字典的weight
- weight应用到低分辨率字典对应的高分辨率字典,得到高分辨率图像
和NE方法是类似的,只不过从 直接 由样本表示 变为了 用字典表示。
1.1.3.提出的方法
公式3表示 输入的低分辨率patch yF, 用附近的邻域 patch NL 加权表示
加权系数有公式4得到
高分辨率patch 则有公式5得到。
同理如果不是直接用example-based patch, 而是用字典,就是公式6和7
那么实际使用的时候是怎样的流程呢?
训练的时候,
- 首先K-SVD计算 低分辨率字典和高分辨率字典
- 然后每个字典原子的K个邻域构建Dh, Dl, 并最终计算为PG(根据公式7)
在测试的时候,
- 输入低分辨率patch 找到最相近的 字典原子,文章中只找一个原子dj
- 根据dj查找 对应的PG
- PG与低分辨率patch 相乘得到 高分辨率patch(根据公式6)
4.patch 的特征选择有很多种
选取patch的特征:
减去均值,除以标准差
一阶和二阶导数
一阶和二阶导数,并应用PCA降维
normalized HR patches 通过 HR - bicubic LR 得到
1.2 论文Sparse recovery of hyperspectral signal from natural rgb images.
本文是对论文B. Arad and O. Ben-Shahar. Sparse recovery of hyperspectral signal from natural rgb images. In European Conference on Computer Vision, pages 19–34. Springer, 2016.的改进
Arad的论文的主要方法如下图:
1.3.本论文的方法
主要是结合论文 Sparse recovery of hyperspectral signal from natural rgb images
和论文 Anchored Neighborhood Regression for Fast Example-Based Super-Resolution
训练的时候:
- k-svd得到 hsr dict
- hsr data 和 hsr dict 通过 lsr projection(比如cie1964 color matching function) 转换为 lsr data和 lsr dict
- normalize , 为每个dict atom 找到 c 个nearest neighbors, 并计算论文中的P
测试的时候
每个rgb pixel找到最近的dict atom, 和对应的 P相乘
2.奇异值分解SVD
https://www.cnblogs.com/endlesscoding/p/10033527.html
概念
示例
code
"""
熟悉和了解svd的使用:https://www.cnblogs.com/endlesscoding/p/10033527.html
"""
import cv2
import numpy as np
from matplotlib import pyplot as plt
def svd_sample():
mat = np.array([[1,5,7,6,1],
[2,1,10,4,4],
[3,6,7,5,2]])
U,Sigma,VT = np.linalg.svd(mat)
print('U: ',U)
print('VT: ', VT)
print('Sigma: ', Sigma) # 特征值可以看作反应矩阵信息内容的大小
print("U是列单位正交矩阵,U@UT:", np.round(U@U.T,2))
print("VT是行单位正交矩阵,V@VT:", np.round(VT.T @ VT,2))
def svd_sample_img(file, mode=1):
"""
对图像进行svd分解 和 重建
mode=0, 读取灰度图
mode=1, 读取彩色图
:return:
"""
img = cv2.imread(file, mode)
if mode == 1:
img = img[..., ::-1]
s = img.shape
img2 = img.reshape(s[0], -1)
# 奇异值分解
U, sigma, VT = np.linalg.svd(img2)
print(U.shape, VT.shape, sigma.shape)
# 取前60个奇异值
sval_nums = 60
img_restruct1 = (U[:, 0:sval_nums]).dot(np.diag(sigma[0:sval_nums])).dot(VT[0:sval_nums, :])
img_restruct1 = img_restruct1.reshape(*img.shape)
img_restruct1 = np.clip(img_restruct1, 0, 255).astype(np.uint8)
# 取前120个奇异值
sval_nums = 120
img_restruct2 = (U[:, 0:sval_nums]).dot(np.diag(sigma[0:sval_nums])).dot(VT[0:sval_nums, :])
img_restruct2 = img_restruct2.reshape(*img.shape)
img_restruct2 = np.clip(img_restruct2, 0, 255).astype(np.uint8)
# 将图片显示出来看一下,对比下效果
fig, ax = plt.subplots(1, 3, figsize=(24, 32))
if mode:
ax[0].imshow(img)
ax[0].set(title="src")
ax[1].imshow(img_restruct1)
ax[1].set(title="nums of sigma = 60")
ax[2].imshow(img_restruct2)
ax[2].set(title="nums of sigma = 120")
plt.show()
else:
ax[0].imshow(img, cmap='gray')
ax[0].set(title="src")
ax[1].imshow(img_restruct1, cmap='gray')
ax[1].set(title="nums of sigma = 60")
ax[2].imshow(img_restruct2, cmap='gray')
ax