用PIL的Image模块打开tif图片后,编译器直接挂掉

首先普通TIF图像没问题,有一个原因可能是我不懂这个tif存储图像原理导致的,我做的这个项目需要对图像进行一个平均 就是累加5张连续图像的像素再平均,这样存储之后的图像 我就没法用PIL的image模块读取了,但是电脑上的软件又能打开图像显示,pyqt的Qpixmap模块也是可以显示的。但是为了实现图像像素强度的读取又不得不使用这个库,cv读出来的都是几百 ,我这个像素一般都是几万,因为是16位的。不知道大家有没有遇到过这种情况,

from PIL import Image
import numpy as np
Image.open(r"G:\Data\test3\clear\pretreatment_00015.tif")
Out[6]: <PIL.TiffImagePlugin.TiffImageFile image mode=I;16 size=819x801>
g = Image.open(r"G:\Data\test3\clear\pretreatment_00015.tif")
c = np.array(g)
进程已结束,退出代码-1073740791 (0xC0000409)

tif没法上传,只能放在网盘里了,有兴趣的可以试一试,在下真的没有解决方法了
链接:pan.baidu.com/s/1rVkhLLQjz4Iqi07c1...
提取码:mggg

讨论数量: 3
Jason990420

Nothing wrong found ...

>>> from PIL import Image
>>> g = Image.open(r"D:\pretreatment_00015.tif")
>>> g.mode, g.size
('I;16', (819, 801))
>>> 
>>> import numpy as np
>>> c = np.array(g)
>>> c
array([[20223, 21014, 19133, ..., 18746, 18105, 21830],
       [18873, 18890, 19639, ..., 21878, 18731, 21417],
       [20458, 21228, 18347, ..., 17914, 21926, 17829],
       ...,
       [21552, 21445, 21014, ..., 18323, 18499, 21977],
       [21797, 18323, 21797, ..., 17528, 19218, 21603],
       [18787, 20591, 20458, ..., 18540, 21252, 19025]], dtype=uint16)
d:\>pip show pillow
Name: Pillow
Version: 9.2.0
Summary: Python Imaging Library (Fork)
Home-page: https://python-pillow.org
Author: Alex Clark (PIL Fork Author)
Author-email: aclark@python-pillow.org
License: HPND
Location: c:\software\python\lib\site-packages
Requires:
Required-by: adbutils, fastai, imageio, imgaug, matplotlib, paddlepaddle, PyScreeze, scikit-image, tkhtmlview, torchvision, visualdl, wxPython
3周前 评论
coco2 (楼主) 3周前
Jason990420
d:\>python
Python 3.8.10 (tags/v3.8.10:3d8993a, May  3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()

d:\>pip show numpy
Name: numpy
Version: 1.23.1
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email:
License: BSD
Location: c:\software\python\lib\site-packages
Requires:
Required-by: blis, Bottleneck, fastai, imageio, imgaug, matplotlib, numexpr, opencv-contrib-python, opencv-python, opt-einsum, paddleocr, paddlepaddle, pandas, pdf2docx, PyWavelets, scikit-image, scikit-learn, scipy, spacy, tensorboardX, thinc, tifffile, torchvision, visualdl, wxPython
3周前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!