The shape attribute of the image matrix
represents the size of the image, and shape returns the tuple tuple. The first element represents the number of rows of the matrix, the second tuple represents the number of columns of the matrix, and the third element is 3, indicating that the pixel value consists of the three primary colors of light.
import cv2
import numpy as np
fn="baboon.jpg"
if __name__ == '__main__':
print 'load %s as ...' % fn
img = cv2.imread(fn)
sp = img.shape
print sp
sz1 = sp[0]#height(rows) of image
sz2 = sp[1]#width(colums) of image
sz3 = sp[2]#the pixels value is made up of three primary colors
print 'width: %d \nheight: %d \nnumber: %d' %(sz1,sz2,sz3)
运行结果:
加载baboon.jpg…
(512、512、3)宽度:512
身高:512年
数字:3 p>
div>
Read More:
- Extension of image edge by Python opencv
- Reading and saving opencv Python video
- Modify the screen resolution after installing Ubuntu 16.04 (xrandr: Failed to get size of gamma for output default)
- Configure Nvidia graphics card on ubuntu18.04 xrandr Failed to get size of gamma for output default
- Get picture captcha with Python + Chrome
- How to use C # to get image format without system. Drawing. Common
- Copying a param with shape torch. Size ([262, 2048]), parameter size does not match
- VTK cultivation 26: basic operation of image_ Three dimensional image slice extraction
- Error reporting of OpenCV and Darknet under Python 2.7
- Solution of OpenCV library import error in Python 3
- ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 256,
- Get the current date in Python
- Ueditor paste word image and upload image file automatically
- Anaconda installation opencv Python error solution
- Installing opencv Python in docker container
- Ant Design upload listtype = “picture card” realizes multi image upload and click preview image encapsulation
- Python uses the priority queue to get the maximum k elements