In [1]:
import cv2
In [2]:
im = cv2.imread('data/src/lena.jpg')
In [3]:
print(type(im))
In [4]:
print(im.shape)
print(type(im.shape))
In [5]:
h, w, c = im.shape
print('width: ', w)
print('height: ', h)
print('channel:', c)
In [6]:
h, w, _ = im.shape
print('width: ', w)
print('height:', h)
In [7]:
print('width: ', im.shape[1])
print('height:', im.shape[0])
In [8]:
print(im.shape[1::-1])
In [9]:
im_gray = cv2.imread('data/src/lena.jpg', cv2.IMREAD_GRAYSCALE)
In [10]:
print(im_gray.shape)
print(type(im_gray.shape))
In [11]:
h, w = im_gray.shape
print('width: ', w)
print('height:', h)
In [12]:
print('width: ', im_gray.shape[1])
print('height:', im_gray.shape[0])
In [13]:
h, w = im.shape[0], im.shape[1]
print('width: ', w)
print('height:', h)
In [14]:
print(im_gray.shape[::-1])
print(im_gray.shape[1::-1])