# -*- coding: utf-8 -*-
"""
@File : 200113_等比例调整图像分辨率大小.py
@Time : 2020/1/13 13:38
@Author : Dontla
@Email : sxana@qq.com
@Software: PyCharm
"""
import cv2
def img_resize(image):
height, width = image.shape[0], image.shape[1]
# 设置新的图片分辨率框架
width_new = 1280
height_new = 720
# 判断图片的长宽比率
if width / height >= width_new / height_new:
img_new = cv2.resize(image, (width_new, int(height * width_new / width)))
else:
img_new = cv2.resize(image, (int(width * height_new / height), height_new))
return img_new
img = cv2.imread('lena_test.jpg')
img_new = img_resize(img)
print(img_new.shape)
cv2.imshow('win', img_new)
cv2.waitKey(0)
python opencv 等比例调整(缩放)图片分辨率大小代码 cv2.resize()
最新推荐文章于 2024-03-15 08:50:44 发布