Natasha
Natasha

Reputation: 1521

Reading multiframe tiff in MATLAB

I am trying to read a multiframe tiff of dimension 610 x 610 x 1200 imread('file.tiff') reads only the first image as mentioned in the documentation.

I would like to know how to read all frames.

ip =  imread('file.tiff') 

i.e

size(ip) = 610   610

but I want it to return

size(ip) = 610  610   1200

Any suggestions on how to do this will be really helpful.

Upvotes: 0

Views: 1382

Answers (1)

Sardar Usama
Sardar Usama

Reputation: 19689

You should be using tiff.read which is dedicated for this purpose:

t = Tiff('file.tiff','r');
ip = read(t);

With your code, you are getting only the first image because this is the default behavior of imread. The documentation says:

TIFF Files
'Index' — Image to read

1 (default) | positive integer
Image to read, specified as the comma-separated pair consisting of 'Index' and a positive integer. For example, if the value of Index is 3 then imread reads the third image in the file.

Also read "Read Specific Image in Multipage TIFF File" in the documentation. If you want to use imread then you may loop over all the indices to get your desired result.

Upvotes: 1

Related Questions