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:
- Solve the problem that better scroll lateral scrolling has no effect
- Tensorflow image random_ There seems to be something wrong with the shift function
- Converting PDF file to JPG image in Ubuntu
- JavaScript to achieve image rotation effect
- Build your own resnet18 network and load torch vision’s own weight
- Error debug in box2d createfixture Error:R6025 pure Virtual function call solution
- OpenGL Usage Summary (including problems encountered and solutions)
- Android get screen width and height and get control width and height
- Simple license plate recognition based on Halcon
- The sparse matrix of R language is too large to be used as.matrix
- Read in wannier90 output file hr.dat to construct real space Hamiltonian to calculate Fermi surface
- Get picture captcha with Python + Chrome
- Format control of cout cout.width () and cout.fill ()
- Python — using Matplotlib to draw histogram
- How to use Latex to Write Matrices
- Several ways to center elements horizontally and vertically
- In tensorflow tf.reduce_ Mean function
- Extension of image edge by Python opencv
- Flutter solves the problem of incorrect use of parent datawidget and boundary constraint
- Python ValueError: only 2 non-keyword arguments accepted