write

Class: Tiff

Write entire image

Syntax

write(tiffobj,imageData)
write(tiffobj,Y,Cb,Cr)

Description

write(tiffobj,imageData) writes imageData to TIFF file associated with the Tiff object, tiffobj. The write method breaks the data into strips or tiles, depending on the value of the RowsPerStrip tag, or the TileLength and TileWidth tags.

write(tiffobj,Y,Cb,Cr) writes the YCbCr component data to the TIFF file. Use this syntax only for images with a YCbCr photometric interpretation.

Examples

expand all

Write Image Data

Write tags and image data to a new TIFF file.

Read sample data into an array, imdata. Create a Tiff object associated with a new file, myfile.tif, and open the file for writing.

imdata = imread('example.tif');
t = Tiff('myfile.tif','w');

Set tag values.

setTag(t,'ImageLength',size(imdata,1))
setTag(t,'ImageWidth',size(imdata,2))
setTag(t,'Photometric',Tiff.Photometric.RGB)
setTag(t,'BitsPerSample',8)
setTag(t,'SamplesPerPixel',size(imdata,3))
setTag(t,'TileWidth',128)
setTag(t,'TileLength',128)
setTag(t,'Compression',Tiff.Compression.JPEG)
setTag(t,'PlanarConfiguration',Tiff.PlanarConfiguration.Chunky)
setTag(t,'Software','MATLAB')

Write the image data to the TIFF file.

write(t,imdata)
close(t)
Was this topic helpful?