在图像PIL中导入TIF图像,其值为Python的像素
我有一个TIF图像(32位,浮点数) 我需要用Python导入在图像PIL中导入TIF图像,其值为Python的像素,python,image,import,python-imaging-library,Python,Image,Import,Python Imaging Library,我有一个TIF图像(32位,浮点数) 我需要用Python导入 from PIL import Image, ImageDraw image = "C:\\foo.tif" im = Image.open(image).convert('F') im.getextrema() (0,0) data = np.array(im) >>> data array([[ 0., 0., 0., ..., 0., 0., 0.], [ 0., 0., 0.,
from PIL import Image, ImageDraw
image = "C:\\foo.tif"
im = Image.open(image).convert('F')
im.getextrema()
(0,0)
data = np.array(im)
>>> data
array([[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.],
...,
[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.]], dtype=float32)
极值为0和0,但在原始图像(32位,浮点数)中,最小值为301.4110107421875,最大值为4563.666015625
当我试图绘制图像时,我有一个空的绘图
import pylab as pl
pl.imshow(im)
pl.show()
如果可能的话,图像的示例(或链接到它以便我们下载和检查)会很有用。@Marcin感谢重播,我可以发布图片,但我不知道如何创建链接到下载的图片。图像下载为png,而不是原始tiff。但无论如何,它说对于32个浮点图像,您需要使用
F
而不是L
。也许这会有帮助。F极值也是0和0对不起,但我不知道。还不确定python的PIL对32位图像的支持程度。也许不是。您还可以在使用PIL之前查看图像,或者,如果可能,将图像重新编码为“正常”格式。