拉普拉斯金字塔构建
G0 = cv2.imread("lena.bmp")
cv2.imshow("input image",G0)
G1=cv2.pyrDown(G0)
G2=cv2.pyrDown(G1)
G3=cv2.pyrDown(G2)
G4=cv2.pyrDown(G3)
L0 = cv2.subtract(G0,cv2.pyrUp(G1))
L1 = cv2.subtract(G1,cv2.pyrUp(G2))
L2 = cv2.subtract(G2,cv2.pyrUp(G3))
L3 = cv2.subtract(G3,cv2.pyrUp(G4))
cv2.imshow("G1",G1)
cv2.imshow("G2",G2)
cv2.imshow("G3",G3)
cv2.imshow("G4",G4)
cv2.waitKey(0)
cv2.destroyAllWindows()
原图
G1
G2
G3
G4
使用拉普拉斯金字塔恢复高分辨图片
l3=cv2.pyrUp(G4)
l2=cv2.pyrUp(l3)
l1=cv2.pyrUp(l2)
l0=cv2.pyrUp(l1)
G00=L0+cv2.pyrUp(G1)
cv2.imshow("l0",l0)
cv2.imshow("G00",G00)
cv2.imshow("input image",G0)
cv2.waitKey(0)
cv2.destroyAllWindows()
原始图像先后经过向上,向下采样后虽图片大小样子都恢复到了原来的样子,但其实他的像素值已经发生了改变是不可逆的。
案例@ Fu Xianjun. All Rights Reserved.