首页 > 编程语言 > 详细

python --- opencv 图片的缩放

时间:2021-05-23 17:08:15      阅读:16      评论:0      收藏:0      [点我收藏+]
import cv2
img = cv2.imread(‘123.png‘,1)  #读取彩色图片
imgInfo = img.shape  #shape属性获取图片的宽,高以及每个像素点的组成方式,一般是3(b,g,r)
#print(imgInfo) 例(736, 1366, 3)
height = imgInfo[0] #图片的高度
width  = imgInfo[1] #图片的宽度
mode = imgInfo[2]  #像素点的组成方式

#设置新的宽高 这里以缩小0.5为例,等比例缩小
new_height = int(height*0.5) 
new_width = int(width*0.5)

new_img = cv2.resize(img,(new_width,new_height)) #1.要缩放的图片,2.设置缩放后的宽高
cv2.imshow(‘new‘,new_img)
cv2.waitKey(0)

python --- opencv 图片的缩放

原文:https://www.cnblogs.com/0errors/p/14801423.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!