3-2 图片缩放1

图片的缩放顾名思义就是改变图片的宽度和高度。


# 1 load 2 info 宽度高度 3 resize 4 check
import cv2
img = cv2.imread('image0.jpg',1)
imgInfo = img.shape
print(imgInfo)
height = imgInfo[0]
width = imgInfo[1]
mode = imgInfo[2]
# 1 放大 缩小 2 等比例 非 2:3
dstHeight = int(height*0.5)
dstWidth = int(width*0.5)
#最近临域插值 双线性插值 像素关系重采样 立方插值
dst = cv2.resize(img,(dstWidth,dstHeight))
cv2.imshow('image',dst)
cv2.waitKey(0)

原文地址:https://www.cnblogs.com/ZHONGZHENHUA/p/9671711.html