matlab: how to save TIFF series?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 03:10:00

问题


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 :)


回答1:


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');



回答2:


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



来源:https://stackoverflow.com/questions/8665825/matlab-how-to-save-tiff-series

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!