import cv2
img = cv2.imread('flower.jpg',1) # 参数1 图片名 参数2 中的1 代表彩色,0代表灰色图像
Info = img.shape #图片的信息
print(Info)
cv2.imshow('img',img)
Height = Info[0] # 图片的宽度
Width = Info[1] #图片的高度
Mode = Info[2] #图片的组成rgb
print(Width,Height,Mode)
dstWidth = int(Width*0.5) #在缩放图像中,像素必须是整数,图片整体缩小一半
dstHeight = int(Height*0.5)
dstImg = cv2.resize(img,(dstWidth,dstHeight)) #重新定义图片大小
cv2.imshow('image',dstImg) #显示图片,参数1 窗口名称,参数2 图片名称
cv2.waitKey(0)
07_图片的缩放
最新推荐文章于 2024-07-16 03:35:10 发布