画像情報の出力

V2.4.11, V3.0.0
In [2]:
import cv2
import numpy as np

img = cv2.imread("lena.jpg", cv2.IMREAD_COLOR)           # rgb
alpha_img = cv2.imread("lena.jpg", cv2.IMREAD_UNCHANGED) # rgba
gray_img = cv2.imread("lena.jpg", cv2.IMREAD_GRAYSCALE)  # grayscale

print type(img)
print 'RGB shape: ', img.shape        # Rows, cols, channels
print 'ARGB shape:', alpha_img.shape
print 'Gray shape:', gray_img.shape
print 'img.dtype: ', img.dtype
print 'img.size: ', img.size
<type 'numpy.ndarray'>
RGB shape:  (512, 512, 3)
ARGB shape: (512, 512, 3)
Gray shape: (512, 512)
img.dtype:  uint8
img.size:  786432

inserted by FC2 system