matlab:如何保存TIFF系列?

发布于 2024-12-23 02:40:51 字数 264 浏览 2 评论 0原文

假设我有一个 3D 数组“img”(x、y、帧)并希望将其保存为 TIFF。到目前为止,我是通过像这样逐一保存来做到这一点的:

for K=1:length(img(1, 1, :))
   outputFileName = sprintf('img_%d.tif',K);
   imwrite(img(:, :, K), outputFileName);
end

很酷,但是如果我想将其保存为一个 tiff 堆栈怎么办?怎么做呢? 谢谢 :)

Lets say I have a 3D array 'img' (x, y, frame) and want to save it as a TIFF. So far I was doing it by saving one-by-one like this:

for K=1:length(img(1, 1, :))
   outputFileName = sprintf('img_%d.tif',K);
   imwrite(img(:, :, K), outputFileName);
end

cool, but what if I want to save it as a one tiff stack? How to do it?
Thanks :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

面如桃花 2024-12-30 02:40:51

参数 'append' 似乎对应于您想。

outputFileName = 'img_stack.tif'
for K=1:length(img(1, 1, :))
   imwrite(img(:, :, K), outputFileName, 'WriteMode', 'append');
end

编辑:
IMAGEJ 在打开这样保存的多个文件时会出现问题。 '压缩','无'正在解决问题:)使用:

imwrite(img(:, :, K), outputFileName, 'WriteMode', 'append',  'Compression','none');

The parameter 'append' seems to correspond to what you want.

outputFileName = 'img_stack.tif'
for K=1:length(img(1, 1, :))
   imwrite(img(:, :, K), outputFileName, 'WriteMode', 'append');
end

EDIT:
IMAGEJ has problems when opening multipletiffs saved like that. 'Compression','none' is solving the problem :) use:

imwrite(img(:, :, K), outputFileName, 'WriteMode', 'append',  'Compression','none');
寂寞清仓 2024-12-30 02:40:51

我认为现在首选的方法是使用 Tiff 新版本 MATLAB 中的类

I think the preferred method these days is to use the Tiff class in newer version of MATLAB.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文