拉普拉斯金字塔后的重建图像与原始图像不一样

Reconstructed Image after Laplacian Pyramid Not the same as original image

我正在将 RGB 图像转换为 YCbCr,然后想为其计算拉普拉斯金字塔。颜色转换后,我正在尝试使用 OpenCV 的图像金字塔教程中给出的代码来找到图像的拉普拉斯金字塔,然后重建原始图像。但是,如果我将代码中的级别数增加到更高的数字,比如 10,则重建图像(转换回 RGB 后)看起来与原始图像不一样(图像看起来模糊 - 请参见下文 link 以获得准确的图像)。我不确定为什么会这样。是级别增加时发生还是代码有问题?

frame = cv2.cvtColor(frame_RGB, cv2.COLOR_BGR2YCR_CB)
height = 10
Gauss = frame.copy()
gpA = [Gauss]
for i in xrange(height):
    Gauss = cv2.pyrDown(Gauss)
    gpA.append(Gauss)

lbImage = [gpA[height-1]]

for j in xrange(height-1,0,-1):
    GE = cv2.pyrUp(gpA[j])
    L = cv2.subtract(gpA[j-1],GE)
    lbImage.append(L)

ls_ = lbImage[0]     
for j in range(1,height,1):
    ls_ = cv2.pyrUp(ls_)
    ls_ = cv2.add(ls_,lbImage[j])

ls_ = cv2.cvtColor(ls_, cv2.COLOR_YCR_CB2BGR)                
cv2.imshow("Pyramid reconstructed Image",ls_)
cv2.waitKey(0)

作为参考,请查看重建图像和原始图像。

Reconstructed Image

Original Image

pyrDown 模糊图像并对其进行缩减采样,丢失一些信息。保存的金字塔层级(此处gpA[])包含越来越小的图像矩阵,但不保留被拒绝的信息细节(高频的)。

因此重建图像无法显示所有原始细节

来自教程: Note: When we reduce the size of an image, we are actually losing information of the image.

不要使用 np.add()np.substract()。他们进行剪裁。使用直接 - 和 + 矩阵运算符。换句话说,使用:

L = gpA[j-1] - GE

而不是:

L = cv2.subtract(gpA[j-1],GE)