%% Write Image Data to Tiles
% Open a Tiff object for writing and set tag values.

t = Tiff('myfile.tif','w');
setTag(t,'ImageLength',32)
setTag(t,'ImageWidth',32)
setTag(t,'Photometric',Tiff.Photometric.MinIsBlack)
setTag(t,'BitsPerSample',8)
setTag(t,'SamplesPerPixel',1)
setTag(t,'TileWidth',16)
setTag(t,'TileLength',16)
setTag(t,'PlanarConfiguration',Tiff.PlanarConfiguration.Chunky)

%
% Write data to four tiles.

writeEncodedTile(t,1,ones(16,16,'uint8'))
writeEncodedTile(t,2,2*ones(16,16,'uint8'))
writeEncodedTile(t,3,3*ones(16,16,'uint8'))
writeEncodedTile(t,4,4*ones(16,16,'uint8'))
close(t)

% Copyright 2012 The MathWorks, Inc.