Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matlab: how to save TIFF series?

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

like image 546
Art Avatar asked Dec 29 '11 09:12

Art


1 Answers

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');
like image 151
Clement J. Avatar answered Sep 30 '22 12:09

Clement J.