I am trying to read a multipage tiff which is 128 pixels x 128 pixels x 122000 frames. Reading the file with the following code:
InfoImage=imfinfo(fname);
mImage=InfoImage(1).Width;
nImage=InfoImage(1).Height;
NumberImages=length(InfoImage);
image=zeros(nImage,mImage,NumberImages,'uint16');
TifLink = Tiff(fname, 'r');
for i=1:NumberImages
TifLink.setDirectory(i);
image(:,:,i)=TifLink.read();
end
TifLink.close();
produces the following error:
Error using tifflib
Input argument out of range.
Error in Tiff/setDirectory (line 1277)
tifflib('setDirectory',obj.FileID,dirNum-1);
Error in TiffReader (line 18)
TifLink.setDirectory(i);
at exactly i = 65537, or 2^16 + 1.
It seems that MATLAB thinks that a tiff cannot possibly be longer than 65536 frames, which is clearly not the case, because I have one which opens just fine in ImageJ.
Does anyone know what the problem might be?