How am I able to analyze a file as a time lapse that contains image stacks such as .tif files?

4 views (last 30 days)
Whenever I upload a .tif file onto MATLAB it only displays the first image of the image stack. I would like to view the images in a sort of time lapse as if it were displaying a video of the images for me to analyze. How would I go about doing this? Thank you

Answers (1)

Walter Roberson
Walter Roberson on 7 Mar 2016
.tif files can contain multiple "directory entries", and each "directory entry" can contain one image and/or can contain "sub-directories" each of which can contain images. Each of the images can, in turn, have a number of channels of "associated data" that could be pixels themselves (but typically this would only be used for Alpha information or for hyperspectral images.)
So... to extract properly, you need to know which of the several ways of storing the additional images has been used.
If you want to use any of the advanced features about subdirectories, then you need to use the Tiff() class.
However, for the case where the additional images have simply been stored as additional "directories", then you can use imread() on the .tif file, and pass it an additional numeric parameter which is the "index" of the image you want to read. For example,
for K = 1 : 10
MyImages(:,:,:,K) = imread('YourFile.tif', K);
end
.tif files are not restricted to having the same image size for each image.
At the moment I do not see a simple way of determining the number of images stored. The TIFF file format itself does not keep count: it just knows where the first one is, and each one knows where the "next" one is or if instead it is the "last" one. Therefore if you do not know the number of images ahead of time, it would be recommended to use the Tiff() calls instead of imread()

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!