Tiff.lastDirectory
Tells whether the current directory is the last one in the file.
Category: Data Import and Analysis > Data Import and Export
Syntax
tf = lastDirectory(t)
Returns true at the final image directory.
Description
The method acts on a Tiff object created with Tiff(filename, mode). This is the natural stop condition for a loop over every image in a multi-image file: read the current image, then call nextDirectory until lastDirectory is true.
Input arguments
tTiffobject opened for reading.
Output arguments
tf- Logical scalar.
Example
Read every image
tag.ImageLength = 2; tag.ImageWidth = 2;
tag.Photometric = Tiff.Photometric.MinIsBlack;
tag.BitsPerSample = 8; tag.SamplesPerPixel = 1; tag.RowsPerStrip = 2;
tag.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky;
w = Tiff('m.tif', 'w');
w.setTag(tag); w.write(uint8([1 2; 3 4])); w.writeDirectory();
w.setTag(tag); w.write(uint8([5 6; 7 8])); w.close();
r = Tiff('m.tif', 'r');
while true
disp(r.read())
if r.lastDirectory(), break, end
r.nextDirectory();
end
r.close();
Output
1 2
3 4
5 6
7 8
See also
Tiff.nextDirectory Tiff.currentDirectory Tiff.setDirectory Tiff.read