简体   繁体   中英

OpenCV: What is the dimension of the array representing a BGR image?

According to documentation , a BGR image is represented this way in OpenCV:

图片描述
(source: opencv.org )

My question: what is the dimension of the array displayed by this picture ?

From the docs

Image properties include number of rows, columns and channels, type of image data, number of pixels etc.

Shape of image is accessed by img.shape. It returns a tuple of number of rows, columns and channels (if image is color):

>>> print img.shape
(342, 548, 3)

Note

If image is grayscale, tuple returned contains only number of rows and columns. So it is a good method to check if loaded image is grayscale or color image.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM