要查看OpenCV中图片的尺寸,可以使用cv2.imread()
函数读取图像,并使用shape
属性查看其尺寸,示例如下:
import cv2
# 读取图像
img = cv2.imread('image.jpg')
# 获取图像尺寸
height, width, channels = img.shape
print('图像宽度为:', width)
print('图像高度为:', height)
print('图像通道数为:', channels)
这段代码将输出图像的宽度、高度和通道数。其中shape
属性返回一个元组,其中包含了图像的行数