【发布时间】:2022-01-06 11:53:21
【问题描述】:
假设我有两个图像连接,所以整个图像的形状是(256,512) 这样的:[X|X]
我希望能够做到这一点:
from PIL import Image
both_image = Image.open(path)
img_left = both_image[:,:256]
img_right = both_image[:,256:]
但是*** TypeError: 'PngImageFile' object is not subscriptable
要修复它,我在写:both_image = np.array(Image.open(path)),最后使用Image.fromarray()
有没有更好的方法可以做到这一点,而不需要来回从 Image 类型到 numpy 数组?
【问题讨论】:
标签: python image numpy python-imaging-library