Tiff.writeEncodedTile
Method of a Tiff object: writes one tile of a tiled TIFF image from an array of pixels.
Category: Data Import and Analysis > Data Import and Export
Syntax
writeEncodedTile(t, tileNumber, data)
Encodes data and stores it as tile number tileNumber.
Description
A tiled TIFF divides the image into rectangular blocks, which makes it cheap to read a small region of a large picture. Choose tiling by setting TileLength and TileWidth instead of RowsPerStrip; the usual TIFF rule is that both are multiples of 16.
writeEncodedTile stores one block at a time. Tiles are numbered in row-major order, so in an image with two tiles per row tile 2 is the top right block and tile 3 is the bottom left one.
Input arguments
t- A
Tiffobject opened for writing. tileNumber- Tile index, starting at 1 and counting across each row of tiles from the top left.
data- Pixels of the tile,
TileLengthrows byTileWidthcolumns.
Example
A 32 by 32 image from four tiles
t = Tiff('tile_demo.tif','w');
t.setTag('ImageLength',32); t.setTag('ImageWidth',32);
t.setTag('TileLength',16); t.setTag('TileWidth',16);
t.setTag('Photometric',Tiff.Photometric.MinIsBlack);
t.setTag('BitsPerSample',8); t.setTag('SamplesPerPixel',1);
t.setTag('PlanarConfiguration',Tiff.PlanarConfiguration.Chunky);
for k = 1:4
t.writeEncodedTile(k, uint8(k*50*ones(16)));
end
t.close();
r = Tiff('tile_demo.tif','r');
img = r.read();
r.close();
size(img)
img([1 17], [1 17])
Output
ans = 1×2
32 32
ans = 2×2 uint8 matrix
50 100
150 200