from PIL import Image
import matplotlib.pyplot as plt
image = Image.open('images/t.jpg') # 读取一张图
#读取的图像模式
mode_list = ['1', 'L', 'I', 'F', 'P', 'RGB', 'RGBA', 'CMYK', 'YCbCr' ]
for mode in mode_list:
img = image.convert(mode)
img_data = np.array(img)
print('img_{:>1}.shape: {}' .format(mode, img_data.shape))
print('img_{:>}_data[0, 0]: {}'.format(mode, img_data[0, 0]))
print('---')
其中:
1:位图,像素深度为1
L:是灰度图,像素8位
I:像素int32
F:像素float32
P: 8位 映射为其它模式
RGB:真彩色,三通道
RGBA:4通道,加透明
CMYK:印刷。4通道
YCbCr:亮色分离,三通道