创建一个多帧.tif文件 [英] Create a multiframe .tif file

查看:248
本文介绍了创建一个多帧.tif文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有要用于创建具有多个帧的新.tif图像的像素数据.我将如何去做呢?我试过了python PIL,但是我只发现它支持多帧读取而不是写入.请参阅下文,了解我的无效尝试.

I have pixel data that I want to use to create a new .tif image that has multiple frames. How would I go about doing this? I have tried python PIL however I have only found it supports multiple frame reading not writing. See below for my attempt that didn't work.

new_Image = Image.new("I;16", (num_pixels,num_rows))

for frame in range((len(final_rows)/num_rows)):
    pixels = new_Image.load()
    for row in range(num_rows):
        row_pixel = final_rows[row].getPixels()
        for pixel in range(num_pixels):
            pixels[pixel,row] = row_pixel[pixel]
    print frame
    new_Image.seek(frame)

推荐答案

例如,将numpy和 scikit-image FreeImage 插件:

For example, using numpy and scikit-image with FreeImage plugin:

import numpy as np
from skimage.io._plugins import freeimage_plugin as fi
image = np.zeros((32, 256, 256), 'uint16')
fi.write_multipage(image, 'multipage.tif')

或使用numpy和 tifffile.py 将其未压缩保存:

Or save it uncompressed using numpy and tifffile.py:

import numpy as np
from tifffile import imsave
image = np.zeros((32, 256, 256), 'uint16')
imsave('multipage.tif', image)

这假定所有页面具有相同的数据形状和类型,并且无需写入其他标签.

This assumes that all pages have the same data shape and type and no additional tags need to be written.

这篇关于创建一个多帧.tif文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆