一、代码部分
代码如下(示例):
#•高斯金字塔+拉普拉斯金字塔
import cv2 #opencv BGR
import matplotlib.pyplot as plt #包导入
import numpy as np
def cv_show(img,name):
cv2.imshow(name,img)
cv2.waitKey()
cv2.destroyAllWindows()
img=cv2.imread("C:/Users/akaak/Pictures/OpenCV/AM.png")
cv_show(img,'img')
print (img.shape)
up=cv2.pyrUp(img)#向上采样(放大)
cv_show(up,'up')
print (up.shape)
down=cv2.pyrDown(img)#向下采样(缩小)
cv_show(down,'down')
print (down.shape)
up2=cv2.pyrUp(up)#两次放大
cv_show(up2,'up2')
print (up2.shape)
up=cv2.pyrUp(img)#两次缩小
up_down=cv2.pyrDown(up)
cv_show(up_down,'up_down')
cv_show(np.hstack((img,up_down)),'up_down')#两次缩小与原图
up=cv2.pyrUp(img)#拉普拉斯金字塔
up_down=cv2.pyrDown(up)
cv_show(img-up_down,'img-up_down')
# down=cv2.pyrDown(img)#拉普拉斯金字塔
# down_up=cv2.pyrUp(down)
# l_1=img-down_up
# cv_show(l_1,'l_1')
二、运行结果
总结
高斯金字塔+拉普拉斯金字塔