图像分析之图像金字塔
# - 高斯金字塔 import cv2 # opencv读取的格式是BGR import numpy as np import matplotlib.pyplot as plt # Matplotlib是RGB img=cv2.imread("cat.jpg") cv2.imshow('img', img) print(img.shape) # 放大两倍 up=cv2.pyrUp(img) cv2.imshow('img2', up) print (up.shape) # 缩小两倍 down=cv2.pyrDown(img) cv2.imshow('img3', down) print (down.shape) cv2.waitKey() cv2.destroyAllWindows()
# 拉普拉斯金字塔 import cv2 # opencv读取的格式是BGR import numpy as np import matplotlib.pyplot as plt # Matplotlib是RGB img=cv2.imread("cat.jpg") cv2.imshow('img', img) print(img.shape) down=cv2.pyrDown(img) down_up=cv2.pyrUp(down) l_1=img-down_up cv2.imshow('l_1', l_1) cv2.waitKey() cv2.destroyAllWindows()