Tiff.writeDirectory
Method of a Tiff object: closes the current image directory and starts a new one, for multi-image TIFF files.
Category: Data Import and Analysis > Data Import and Export
Syntax
writeDirectory(t)
Finishes the current directory and creates an empty one after it.
t.writeDirectory()
Same call in dot notation.
Description
A TIFF file is a chain of directories, and each directory describes one image with its own tags. After you write the pixels of one image, writeDirectory seals it and opens the next directory, so the tags must be set again before the next write.
Do not call it after the last image: close already finishes the final directory. When reading, nextDirectory and setDirectory move between the stored images.
Input arguments
t- A
Tiffobject opened for writing.
Example
Two images in one file
img = uint8(magic(8)*3);
t = Tiff('pages_demo.tif','w');
for k = 1:2
page = img;
if k == 2, page = 255 - img; end
t.setTag('ImageLength',8); t.setTag('ImageWidth',8);
t.setTag('Photometric',Tiff.Photometric.MinIsBlack);
t.setTag('BitsPerSample',8); t.setTag('SamplesPerPixel',1);
t.setTag('PlanarConfiguration',Tiff.PlanarConfiguration.Chunky);
t.setTag('RowsPerStrip',8);
t.write(page);
if k < 2, t.writeDirectory(); end
end
t.close();
r = Tiff('pages_demo.tif','r');
a = r.read();
r.nextDirectory();
b = r.read();
r.close();
disp(a(1,1:3))
disp(b(1,1:3))
Output
192 6 9
63 249 246