这个问题涉及与信号重建的另一个问题相关的图像重建示例。我在两个示例中都有不同的问题,但可能存在潜在因素。
我尝试使用压缩感知重建图像,就像在 Coursera 的课程“数据分析的计算方法”中一样,并在此pdf(第 414 页)中进行了一些详细描述。顺便说一下,这是低分辨率图像:

但是,我有一个关于使用重建图像的问题,其中是原始图像,是表示图像和其系数的基础(在这种情况下,是离散余弦变换)。这就是我所做的,但我不完全确定它是否正确。
from PIL import Image
from scipy.fftpack import dct, idct
from sklearn.linear_model import Lasso
# Loading image in grayscale and obtaining its dimensions
im = Image.open('coffee-cup.jpg').convert('L')
nx, ny = im.shape
# Number of sample points used to reconstruct image
k = 1000
# Create a permutation from 1 to nx*ny and choose the first k numbers
Atest = zeros((nx, ny)).reshape(1, nx*ny)
r1 = permutation(arange(1, nx*ny))
r1k = r1[1:k+1]
# Suppose the first number in the permutation is 42. Then choose the 42th
# elements in a matrix full of zeros and change it to 1. Apply a discrete
# cosine transformation to this matrix, and add the result to other matrix
# Adelta as a new row.
Adelta = zeros((k, nx*ny))
for i, j in enumerate(r1k):
Atest[0,j] = 1
Adelta[i, :] = dct(Atest)
Atest[0, j] = 0
# Use the same permutation to sample the image to be reconstructed
image1 = im.reshape(nx*ny,1)
b = image1[r1k]
# Solve the optimization problem Adelta * x = b
lasso = Lasso(alpha=0.001)
lasso.fit(Adelta,b)
在此之后, lasso.coef_ 包含系数。这是我不确定的部分。我使用离散余弦变换对系数进行了变换。然而,Adelta 的构造似乎暗示了其他更详细的。然而,当我使用逆离散余弦变换 (IDCT) 和离散余弦变换 (DCT) 绘制重建图时,我得到的是:
recons2 = dct(lasso.coef_).reshape((nx,ny))
recons = idct(lasso.coef_).reshape((nx,ny))
fig = figure()
ax = fig.add_subplot(121)
ax2 = fig.add_subplot(122)
ax.imshow(recons)
ax2.imshow(recons2)

它工作得相当好,但请注意第一张图像(其中使用了 IDCT)表现更好。我会假设,如果有的话,DCT 是更合适的选择,因为至少我们在构建 Adelta 时使用了 DCT 的结果。这里的正确程序是什么?