Open DylanMuir opened 6 years ago
imfinfo
is fast because it uses the undocumented Matlab mex
file matlab.io.internal.imagesci.tifftagsread
. The calling syntax appears to be:
function vsInfoStructure = ...tifftagsread(strFilename, nBytesOffset, nIFDsToSkip, nNumIFDsToRead);
tifftagsread
is 10x faster than the matlab version of tiffread31_header
, but reads all tags. This is undesirable for ScanImage TIFF files, since the headers contain large duplicated Software
and Artist
tags (and others?).
Suggestion: to write an accelerated mex
version that reads only necessary tags from the TIF file.
Hassles:
Hi, I have some ideas/questions about this.
1) Sometimes we might know how many images/IFDs are in a tiff file? What about creating an option for passing such information to the TIFFStack on creation? That could partially solve the problem of reallocation you describe above.
2) Sometimes, all the image in a tiff stack are uniform. Is it then necessary to read through all the headers? Say I know the number of images in the TIFFStack I want to open, and I know that all the images are the same format, is there a reason not to jus read the header of the first directory and use that information for all the remaining directories?
The
tiffread31_header
function is slow to iterate over the IFDs in large files.imfinfo
is fast, but reads all tags.