本文最后更新于:2023年12月5日 下午

python 在读取大图像时会报错,本文记录解决方案。

读取大图像

  • open cv 在读取超过 1G 的图像时会返回 None
  • PIL 读取超过一定像素个数的图像会报错

解决方案

  • 解除PIL最大像素个数限制
  • 之后可以使用skimage或matplot读取大图像
1
2
3
4
5
6
7
8
9
from PIL import Image
from skimage import io
import matplotlib.image as gImage

image_file = 'test.bmp'

Image.MAX_IMAGE_PIXELS = None
img_sk = io.imread(image_file)
img_ml = gImage.imread(image_file)


文章链接:
https://www.zywvvd.com/notes/coding/python/load-large-image/load-large-image/


“觉得不错的话,给点打赏吧 ୧(๑•̀⌄•́๑)૭”

微信二维码

微信支付

支付宝二维码

支付宝支付

Python - 读取大图片
https://www.zywvvd.com/notes/coding/python/load-large-image/load-large-image/
作者
Yiwei Zhang
发布于
2021年1月5日
许可协议