Image Pyramid
Image pyramid is used for machine vision and image compression. The pyramid of an image is a series of pyramids arranged in a gradually decreasing resolution and is derived from the same collection of original images. It is obtained by cascading down sampling until it reaches Only a certain termination condition stops sampling.
The bottom of the image pyramid is the high-resolution representation to be processed, and the top is the approximation of the low-resolution. The higher the level, the smaller the image and the lower the resolution.
sampling:
up_img = cv.pyrUp(img) # 上采样
down_img = cv.pyrDown(img) # 下采样
Implementation code:
import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt
# 图片加载
img = cv.imread('img/img2.jpeg')
# 采样
up_img = cv.pyrUp(img) # 上采样
down_img = cv.pyrDown(img) # 下采样
print(up_img.shape) # (2160, 3840, 3)
print(down_img.shape) # (540, 960, 3)
print(img.shape) # (1080, 1920, 3)
# 图像显示
cv.imshow('enlarge',up_img)
cv.imshow('shrink',down_img)
cv.imshow('original',img)
cv.waitKey(0)
cv Xiaobai, hope the boss will give pointers