PIL Image

weixin_33807284發表於2019-02-13
from PIL import Image
import numpy as np

img = Image.open('/temp_disk/xs/sun/train/image/0.jpg')
print(img.format)  # JPEG
print(img.mode)  # RGB
print(img.size)
print(img.info)  # a dict
img = np.array(img)
print(np.min(img))  # 3
print(np.max(img))  # 255
print()

depth = Image.open('/temp_disk/xs/sun/train/depth/0.png')
print(depth.format)  # PNG
print(depth.mode)  # I
print(depth.size)
print(depth.info)
depth = np.array(depth)
print(np.min(depth))  # 8784
print(np.max(depth))  # 52456
JPEG
RGB
(730, 530)
{'jfif': 257, 'jfif_version': (1, 1), 'jfif_unit': 0, 'jfif_density': (1, 1)}
3
255

PNG
I
(730, 530)
{}
8784
52456

相關文章