什么是图像金字塔?
向上采样 :cv.pyrUp(img)
向下采样 : cv.pyrDown(img)
代码实现
import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt
#图像的读取
img = cv.imread("lena.png")
#进行图像采样
up_img = cv.pyrUp(img) #上采样
down_img = cv.pyrDown(img) #下采样
#图像显示
cv.imshow("enlarge",up_img)
cv.imshow("original",img)
cv.imshow("shrink",down_img)
cv.waitKey(0)
cv.destroyWindow()