%% Get Tile from RGBA TIFF Image
% Read a tile of data from a TIFF image file using the RGBA interface.
% Create a Tiff object for the image file.

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

% Get the number of tiles and tile size.

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

% Read the tile containing the 100th row and 100th column from the image. The readRGBATile 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.

row = 100;
col = 100;
[RGB,A] = readRGBATile(t,row,col);

% Display the image.

imshow(RGB,'InitialMagnification','fit') % magnify for display

% Close the Tiff object.

close(t);

% Copyright 2012 The MathWorks, Inc.