高斯金字塔
向下采样 将偶数行和列去除 例:400x400变为200x200 每次处理后为原图1/4
import cv2
import numpy as np
img = cv2.imread('./lena.jpg')
print(img.shape)
#下采样会丢失原图信息
dst = cv2.pyrDown(img)
print(dst.shape)
dst2 = cv2.pyrDown(dst)
print(dst2.shape)
#上采样
dst3 = cv2.pyrUp(dst)
print(dst3.shape)
cv2.imshow('img',img)
cv2.imshow('dst',dst)
cv2.imshow('dst2',dst2)
cv2.imshow('dst3',dst3)
cv2.waitKey(0)
cv2.destroyALLWindows()
拉普拉斯金字塔
拉普拉斯=原图-两次高斯后图像(先缩小在放大)
import cv2
import numpy as np
img = cv2.imread('./lena.jpg')
#先缩小
dst = cv2.pyrDown(img)
#再放大
dst = cv2.pyrUp(dst)
#第0层
lap0 = img - dst
dst1 = cv2.pyrDown(dst)
dst1 = cv2.pyrUp(dst1)
#第一层
lap1 = dst - dst1
cv2.imshow('img',np.hstack((img,lap0,lap1)))
cv2.waitKey(0)
cv2.destroyALLWindows()