python读取tiff图像rgb值_Python:读写TIFF 16位,三通道,彩色图像

有没有人有一种方法来导入16位每通道,3通道TIFF图像在

Python?

我还没有找到一种在处理TIFF格式时保留每个通道的16位深度的方法.我希望有一些有用的灵魂会有一个解决方案.

以下是我迄今为止没有成功尝试的结果列表:

import numpy as np

import PIL.Image as Image

import libtiff

import cv2

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

# IOError: cannot identify image file

tif = libtiff.TIFF.open('a.tif')

im = tif.read_image()

# im only contains one of the three channels. im.dtype is uint16 as desired.

im = []

for i in tif.iter_images():

# still only returns one channel

im = np.array(cv2.imread('a.tif'))

# im.dtype is uint8 and not uint16 as desired.

# specifying dtype as uint16 does not correct this

到目前为止,我发现的唯一解决方案是使用ImageMagick将图像转换为PNG.然后沼泽标准matplotlib.pyplot.imread读取PNG文件没有任何问题.

另一个问题是将任何numpy数组保存为16位PNG文件,到目前为止还不是很简单.

你可能感兴趣的:(python读取tiff图像rgb值_Python:读写TIFF 16位,三通道,彩色图像)