matlab

t=Tiff('IMG_3952.TIF', 'r+');
k = 1;
t.setDirectory(k);
img{k} = t.read();
src = img{1};
dst(:,:,1) = src(:,:,1) ;
dst(:,:,2) = src(:,:,2) ;
dst(:,:,3) = src(:,:,3) ;
figure;
imshow(dst);

python

#coding=utf-8
from libtiff import TIFF
from scipy import misc
##tiff文件解析成图像序列
##tiff_image_name: tiff文件名;
##out_folder:保存图像序列的文件夹
##out_type:保存图像的类型,如.jpg、.png、.bmp等
def tiff_to_image_array(tiff_image_name, out_folder, out_type):
tif = TIFF.open(tiff_image_name, mode = "r")
idx = 0
for im in list(tif.iter_images()):
#
im_name = out_folder + str(idx) + out_type
misc.imsave(im_name, im)
print (im_name, 'successfully saved!!!')
idx = idx + 1
return
##图像序列保存成tiff文件
##image_dir:图像序列所在文件夹
##file_name:要保存的tiff文件名
##image_type:图像序列的类型
##image_num:要保存的图像数目
def image_array_to_tiff(image_dir, file_name, image_type, image_num):
out_tiff = TIFF.open(file_name, mode = 'w')
#这里假定图像名按序号排列
for i in range(0, image_num):
image_name = image_dir + str(i) + image_type
image_array = Image.open(image_name)
#缩放成统一尺寸
img = image_array.resize((480, 480), Image.ANTIALIAS)
out_tiff.write_image(img, compression = None, write_rgb = True)
out_tiff.close()
return tiff_image_name = "IMG_3952.TIF"
out_folder = "123/"
out_type = ".bmp"
tiff_to_image_array(tiff_image_name, out_folder, out_type);

matlab与python读取tiff文件的更多相关文章

  1. Python读取txt文件

    Python读取txt文件,有两种方式: (1)逐行读取 data=open("data.txt") line=data.readline() while line: print ...

  2. Python读取Yaml文件

    近期看到好多使用Yaml文件做为配置文件或者数据文件的工程,随即也研究了下,发现Yaml有几个优点:可读性好.和脚本语言的交互性好(确实非常好).使用实现语言的数据类型.有一个一致的数据模型.易于实现 ...

  3. python读取中文文件编码问题

    python 读取中文文件后,作为参数使用,经常会遇到乱码或者报错asii错误等. 我们需要对中文进行decode('gbk') 如我有一个data.txt文件有如下内容: 百度 谷歌 现在想读取文件 ...

  4. Python读取SQLite文件数据

    近日在做项目时,意外听说有一种SQLite的数据库,相比自己之前使用的SQL Service甚是轻便,在对数据完整性.并发性要求不高的场景下可以尝试! 1.SQLite简介: SQLite是一个进程内 ...

  5. Python读取xlsx文件

    Python读取xlsx文件 脚本如下: from openpyxl import load_workbook workbook = load_workbook(u'/tmp/test.xlsx') ...

  6. Python 读取WAV文件并绘制波形图

    aa Python 读取WAV文件并绘制波形图 ffmpeg -i test_pcm_mulaw.wav -f wav -codec:a pcm_s16le -ar 8000 -ac 1 out.wa ...

  7. 使用python读取yaml文件

    在做APP测试时,通常需要把参数存到一个字典变量中,这时可以将参数写入yaml文件中,再读取出来. 新建yaml文件(android_caps.yaml),文件内容为: platformName: A ...

  8. python 读取bin文件

    python读取bin文件并下发串口   # coding:utf-8import time, serialfrom struct import *import binascii file = ope ...

  9. 记录:python读取excel文件

    由于最近老是用到python读取excel文件,所以特意记录一下python读取excel文件的大体框架. 库:xlrd(读),直接pip安装即可.想要写excel文件的话,安装xlwd库即可,也是直 ...

随机推荐

  1. Python——运算符

    Python算术运算符 以下假设变量: a=10,b=20: 运算符 描述 实例 + 加 - 两个对象相加 a + b 输出结果 30 - 减 - 得到负数或是一个数减去另一个数 a - b 输出结果 ...

  2. [POI2012]Tour de Bajtocja

    [POI2012]Tour de Bajtocja 题目大意: 给定一个\(n(n\le10^6)\)个点\(m(m\le2\times10^6)\)条边的无向图,问最少删掉多少条边能使得编号小于等于 ...

  3. POJ 水题(刷题)进阶

    转载请注明出处:優YoU http://blog.csdn.net/lyy289065406/article/details/6642573 部分解题报告添加新内容,除了原有的"大致题意&q ...

  4. redis:list列表类型的操作

    1. list列表类型的操作 1.1. lpush/rpush key value [value ...] 链表的头部(左侧)或尾部(右侧)插入值 语法:lpush key value [value ...

  5. 问题7:JavaScript 常用正则示例

    1. trim功能(清除字符串两端空格) String.prototype.trim = function() { return this.replace(/(^\s+)|(\s+$)/g, ''); ...

  6. nvidia-docker2配置与NVIDIA驱动安装

    要运行高版本的GPU版TensorFlow,需要更新宿主机的显卡驱动(本文以NVIDIA390为例) 一.更新驱动 禁用nouveau驱动: 添加/etc/modprobe.d/blacklist.c ...

  7. Docker 下载镜像慢的问题解决方法

    让你火箭般的速度下载docker镜像! 的冷漠度 百家号17-11-1713:09 因为有墙的原因所以在国内下载docker镜像的速度非常慢,有时候是几kb每秒,那个蛋疼的等待,真是谁等谁知道!下面我 ...

  8. CentOS7配置防火墙

    使用命令的方式配置 ##Add firewall-cmd --permanent --zone=public --add-port=/tcp ##Remove firewall-cmd --perma ...

  9. LeetCode: Gray Code [089]

    [题目] The gray code is a binary numeral system where two successive values differ in only one bit. Gi ...

  10. 哪些 Python 库让你相见恨晚?【转】

    原文链接:https://www.zhihu.com/question/24590883/answer/92420471 原文链接:Python 资源大全 ---------------- 这又是一个 ...