python读取tif图片_Python模块_PyLibTiff读取tif文件的实例

本文介绍了如何使用Python的PyLibTiff库读取和处理tif图像,包括读取、写入、转换图像序列。同时,还展示了使用OpenCV读取tif图像的不同模式,以及PIL库的相关操作,如旋转、缩放和创建图像。
摘要由CSDN通过智能技术生成

Usage example (libtiff wrapper)

from libtiff import TIFF

# to open a tiff file for reading:

tif = TIFF.open('filename.tif', mode='r')

# to read an image in the currect TIFF directory and return it as numpy array:

image = tif.read_image()

# to read all images in a TIFF file:

for image in tif.iter_images(): # do stuff with image

# to open a tiff file for writing:

tif = TIFF.open('filename.tif', mode='w')

# to write a image to tiff file

tif.write_image(image)

Usage example (pure Python module)

from libtiff import TIFFfile, TIFFimage

# to open a tiff file for reading

tif = TIFFfile('filename.tif')

# to return memmaps of images and sample names (eg channel names, SamplesPerPixel>=1)

samples, sample_names = tiff.get_samples()

# to create a tiff structure from image data

tiff = TIFFimage(data, description='')

# to write tiff structure to file

tiff.write_file('filename.tif', compression='none') # or 'lzw'

del tiff # flushes data to disk

from libtiff import TIFF

from scipy import misc

##tiff文件解析成图像序列

##tiff_im

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值