Python读取tiff

使用 opencv 保存的 tiff 或 tif 格式的图片,会默认使用LZW压缩。

在python 3 当中,使用下面的库都能打开压缩之后的tiff图片,但是值不正确(或许没有正确解压)。

matplotlib
PIL
cv2

要正确的进行解压,需要使用libtiff这个库,使用如下方式打开:


from libtiff import TIFF
tif = TIFF.open('filename.tif', mode='r')
img = tif.read_image() #此时img为一个numpy.array

 

转载自:https://blog.csdn.net/dongjbstrong/article/details/84973540

You may also like...