小编cse*_*cse的帖子

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

我正在将 RGB 图像转换为 YCbCr,然后想要计算相同的拉普拉斯金字塔。颜色转换后,我正在尝试使用 OpenCV 图像金字塔教程中给出的代码来找到图像的拉普拉斯金字塔,然后重建原始图像。但是,如果我将代码中的级别数增加到更高的数字,例如 10,那么重建的图像(转换回 RGB 后)看起来与原始图像不一样(图像看起来模糊 - 请参阅下面的链接准确的图像)。我不知道为什么会发生这种情况。当级别增加时是否会发生这种情况,或者代码中有什么问题?

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)
Run Code Online (Sandbox Code Playgroud)

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

重建图像

原始图像

python opencv image image-processing

4
推荐指数
1
解决办法
3875
查看次数

标签 统计

image ×1

image-processing ×1

opencv ×1

python ×1