%% Read Tile from YCbCr TIFF Image
% Read a tile of image data from a YCbCr TIFF file that contains an image with a tiled layout.

t = Tiff('peppers_YCbCr_tiled.tif','r');

% Determine the number of tiles and the tile size in the image.

nTiles = numberOfTiles(t)
tileSize = [getTag(t,'TileLength') getTag(t,'TileWidth')]

% Read and display the Y component of the 19th tile of the image. The readEncodedTile function trims the area in a tile that is outside of the ImageLength and ImageWidth boundaries. Therefore, image data from tiles that occur on the right edge or the bottom edge of the image can have different dimensions.

[Y,Cb,Cr] =  readEncodedTile(t,19);
imshow(Y,'InitialMagnification','fit') % Magnify for display
title('19^{th} Tile of Peppers Image (YCbCr)')

% Close the Tiff object.

close(t);

% Copyright 2012 The MathWorks, Inc.