MATLAB Answers

Soum
0

How to show Tiff stacks

Asked by Soum
on 11 Nov 2013
Latest activity Commented on by Soum
on 12 Nov 2013
Hi everyone;
I'm trying to show a tiff stack '57 images as one file' but I faced this problem:
Warning: Can only display one frame from this multiframe file:
"Stack.tif".
> In imuitools\private\getImageFromFile at 20
In imuitools\private\imageDisplayParseInputs at 74
In imshow at 198
In Prg at 4
how can I display a tiff stack image? and after I applied some processes how can I collect them again 'refile them'

  0 Comments

Sign in to comment.

1 Answer

Jeff E
Answer by Jeff E
on 12 Nov 2013
 Accepted Answer

You can read each tiff image in one at a time using imread (note I'm making some assumptions...like you do indeed have a multipage tiff):
tiff_info = imfinfo('2-A^11815^52071.tif'); % return tiff structure, one element per image
tiff_stack = imread('2-A^11815^52071.tif', 1) ; % read in first image
%concatenate each successive tiff to tiff_stack
for ii = 2 : size(tiff_info, 1)
temp_tiff = imread('2-A^11815^52071.tif', ii);
tiff_stack = cat(3 , tiff_stack, temp_tiff);
end
And you can then use the 'append' switch to write each tiff as a new image in a multi-page tiff:
%write a Tiff file, appending each image as a new page
for ii = 1 : size(tiff_stack, 3)
imwrite(tiff_stack(:,:,ii) , 'new_stack.tif' , 'WriteMode' , 'append') ;
end

  3 Comments

Soum
on 12 Nov 2013
Thank you a lot for the excellent answer but if I have a separate tiff
images and I would to read them as one tiff file can I do it?
Many thanks in advance
Jeff E
on 12 Nov 2013
If you mean separate tiff files, all in one directory, then change the first bit of code to use the output from DIR (again, assuming you have more than one tiff in a directory):
files = dir('C:\temp\*.tiff');
tiff_stack = imread(files(1).name);
for ii = 2 : size(files, 1)
temp_tiff = imread(files(ii).name);
tiff_stack = cat(3 , tiff_stack, temp_tiff);
end
If you meant something else, please elaborate.
Soum
on 12 Nov 2013
thank you but I mean I've a 57 images .tiff 'separated' and I wanna read
them as one multipage tiff image

Sign in to comment.