MATLAB: How to dynamically read multiple images from one TIFF-file into MATLAB 7.8 (R2009a)

fileimagesimfinfoimreadMATLABmultipletiff

I have a TIFF-file which contains multiple images. I want to determine how many images are in this TIFF-file so that I can read these into MATLAB dynamically. I also want to know how to use IMREAD to read in all of these images, not just the first one.

Best Answer

To read and view multiple images from one TIFF-file in MATLAB 7.8 (R2009a), please use IMFINFO and IMREAD as follows:
To obtain the number of images in one TIFF-file, use the following syntax:
numimgs = size(imfinfo(filename),1)
To read in all images in the TIFF-file, please try the following:
for i = 1:numimgs,
% Use IMREAD with two inputs, the second input
% being the index of the image you are currently
% reading.
I = imread(filename,i);
figure
imshow(I)
end