Matlab: how to save TIFF series?

Suppose I have a 3D array 'img' (x, y, frame) and want to save it as TIFF. So far I have been doing this, saving one by one as follows:

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 single tiff stack? How to do it? Thanks:)

+6
source share
2 answers

The append 'parameter seems to match 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 opening multiples saved in this way. "Compression", "nobody" solves the problem :) use:

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

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

0
source

Source: https://habr.com/ru/post/904652/


All Articles