Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在python中读取32位TIFF图像?_Python_Image Processing_Matplotlib_Tiff_32 Bit - Fatal编程技术网

如何在python中读取32位TIFF图像?

如何在python中读取32位TIFF图像?,python,image-processing,matplotlib,tiff,32-bit,Python,Image Processing,Matplotlib,Tiff,32 Bit,我想用python读取32位浮点图像文件来做一些图像分析 我试过了 import matplotlib.pyplot as plt im = plt.imread('path_to_file.tif') 但是,这仅将数据读取为8位整数值。有没有办法为imread()提供正确的数据类型 --嗯,它以前是用16位TIFF文件开箱即用的,但不是32位浮点。我通过PIL找到了一种方法,它是: from matplotlib import pyplot as plt from matplotlib i

我想用python读取32位浮点图像文件来做一些图像分析

我试过了

import matplotlib.pyplot as plt

im = plt.imread('path_to_file.tif')
但是,这仅将数据读取为8位整数值。有没有办法为imread()提供正确的数据类型


--嗯,它以前是用16位TIFF文件开箱即用的,但不是32位浮点。

我通过PIL找到了一种方法,它是:

from matplotlib import pyplot as plt
from matplotlib import cm

from PIL import Image
from numpy import array

im = Image.open('path_to_file.tif')

ncols, nrows = im.size
ima = array(im.getdata()).reshape((nrows, ncols))
plt.imshow(ima, cmap=cm.Greys_r)
也许这对某人有帮助


我在尝试读取单通道32位整数图像时遇到了类似的问题。我想出的解决办法是:

from skimage import io
im = io.imread('path_to_file.tif')
如果您的计算机上安装了OpenCV,您也可以尝试:

import cv2
im = cv2.imread('path_to_file.tif', -1)
希望这对我有帮助(关键标志是
IMREAD\u ANYDEPTH
):

cv2.imread(fullImagePath,flags=(cv2.imread_GRAYSCALE | cv2.imread_ANYDEPTH))
我在这里找到的:

使用skimage可以很好地工作,但我在使用opencv(使用python3.6)时遇到了一个非类型问题。您使用的是什么版本的opencv?我使用的是来自Anaconda 3(5.2.0)的opencv 3.4.2和python3.6。您可以通过Dropbox、Google drive等共享您的图像吗?