Tiff.writeEncodedStrip
Method of a Tiff object: writes one strip of a stripped TIFF image from an array of pixels.
Category: Data Import and Analysis > Data Import and Export
Syntax
writeEncodedStrip(t, stripNumber, data)
Encodes data and stores it as strip number stripNumber.
Description
A stripped TIFF stores the image as horizontal bands of RowsPerStrip rows each. writeEncodedStrip is the low-level counterpart of write: it lets you produce the image band by band, which is useful when the whole array is not in memory at once.
Set all tags, including RowsPerStrip, before the first strip. The array passed for each strip must match the strip size and the class given by BitsPerSample. The last strip of an image whose height is not a multiple of RowsPerStrip is shorter.
Input arguments
t- A
Tiffobject opened for writing. stripNumber- Strip index, starting at 1 for the top strip.
data- Pixels of that strip,
RowsPerStriprows tall and as wide as the image.
Example
Two strips of four rows
img = uint8(magic(8)*3);
t = Tiff('strip_demo.tif','w');
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',4);
t.writeEncodedStrip(1, img(1:4,:));
t.writeEncodedStrip(2, img(5:8,:));
t.close();
r = Tiff('strip_demo.tif','r');
back = r.read();
r.close();
isequal(back, img)
Output
ans = logical
1