Tiff.setDirectory

Makes a given image directory the current one.

Category: Data Import and Analysis > Data Import and Export

Syntax

setDirectory(t, dirNum)

Jumps to directory number dirNum.

Description

The method acts on a Tiff object created with Tiff(filename, mode). Unlike nextDirectory, it goes straight to any image, in either direction. Reading with read afterwards returns that image, and getTag reports its tags.

Input arguments

t
Tiff object.
dirNum
Directory index, counted from 1.

Example

Jump to the second 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');
r.setDirectory(2);
r.read()
r.setDirectory(1);
r.read()
r.close();
Output
ans = 2×2 uint8 matrix

   5   6
   7   8
ans = 2×2 uint8 matrix

   1   2
   3   4

See also

Tiff.nextDirectory Tiff.currentDirectory Tiff.lastDirectory Tiff.read