PIL Image.open 读取图像 单通道 三通道 图像为空 时的表现

python的PIL库的读取图像,但与opencv不同,它在读取 单通道 三通道 以及 图像为空时的表现,并没有被明确的说明,没有注意的话容易踩坑,这里做实验记录一下

test = Image.open("test.jpg")
print(test.getpixel((0,0)))

1.读取单通道图像时,默认会得到单通道图像

2.读取三通道图像时,默认会得到RGB三通道图像

3.读取空图像时,会抛出异常 FileNotFoundError: [Errno 2] No such file or directory: 'test.jpg'

猜你喜欢

转载自blog.csdn.net/flyconley/article/details/119155453