Tiff.readEncodedTile
Reads one tile of the current image, still as stored.
Category: Data Import and Analysis > Data Import and Export
Syntax
T = readEncodedTile(t, tileNum)
Decodes tile number tileNum.
Description
The method acts on a Tiff object created with Tiff(filename, mode). The tile is returned at its full stored size, so a tile that overhangs the image edge carries padding that you must crop. Here a 4-by-4 image sits in a 16-by-16 tile.
Input arguments
tTiffobject opened on a tiled image.tileNum- Tile index, counted from 1.
Output arguments
T- Array of
TileLength-by-TileWidthpixels. Tiles at the edge include padding beyond the image.
Example
Read and crop a tile
tag.ImageLength = 4; tag.ImageWidth = 4;
tag.Photometric = Tiff.Photometric.MinIsBlack;
tag.BitsPerSample = 8; tag.SamplesPerPixel = 1;
tag.TileLength = 16; tag.TileWidth = 16;
tag.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky;
w = Tiff('u.tif', 'w'); w.setTag(tag); w.write(uint8(magic(4))); w.close();
r = Tiff('u.tif', 'r');
T = r.readEncodedTile(1);
size(T)
T(1:4, 1:4)
r.close();
Output
ans = 1×2
16 16
ans = 4×4 uint8 matrix
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
See also
Tiff.computeTile Tiff.numberOfTiles Tiff.read Tiff.readEncodedStrip