其他分享
首页 > 其他分享> > OpenCV 图像金字塔

OpenCV 图像金字塔

作者:互联网

拉普拉斯金字塔构建

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.

标签:G3,G2,G1,imshow,cv2,OpenCV,图像,金字塔,pyrUp
来源: https://blog.csdn.net/weixin_57467874/article/details/118278813