MATLAB Gateway to LibTIFF library routines
The Tiff
class represents a connection to
a Tagged Image File Format (TIFF) file and provides access to many
of the capabilities of the LibTIFF library. Use the methods of the Tiff
object
to call routines in the LibTIFF library. While you can use the imread
and imwrite
functions
to read and write TIFF files, the Tiff
class offers
capabilities that these functions don't provide, such as reading subimages,
writing tiles and strips of image data, and modifying individual TIFF
tags.
In most cases, the syntax of the Tiff
method
is similar to the syntax of the corresponding LibTIFF library function.
To get the most out of the Tiff
object, you must
be familiar with the LibTIFF API, as well as the TIFF specification
and technical notes. View this documentation at LibTIFF - TIFF
Library and Utilities
.
MATLAB® supports LibTIFF version 4.0.0.
For copyright information, see the libtiffcopyright.txt
file.
obj = Tiff(filename,mode)
creates a Tiff
object
associated with the TIFF file filename
. mode
specifies
the type of access to the file.
A TIFF file is made up of one or more image file directories
(IFDs). An IFD contains image data and associated metadata. IFDs can
also contain subIFDs which also contain image data and metadata. When
you open a TIFF file for reading, the Tiff object makes the first
IFD in the file the current IFD. Tiff
methods
operate on the current IFD. You can use Tiff
object
methods to navigate among the IFDs and the subIFDs in a TIFF file.
When you open a TIFF file for writing or appending, the Tiff
object
automatically creates a IFD in the file for writing subsequent data.
This IFD has all the default values specified in TIFF Revision 6.0.
When creating a new TIFF file, before writing any image to the
file, you must create certain required fields (tags) in the file.
These tags include ImageWidth
, ImageHeight
, BitsPerSample
, SamplesPerPixel
, Compression
, PlanarConfiguration
,
and Photometric
. If the image data has a stripped
layout, the IFD contains the RowsPerStrip
tag.
If the image data has a tiled layout, the IFD contains the TileWidth
and TileHeight
tags.
Use the setTag
method to define values for these
tags.
|
Character vector specifying name of file. |
|
Type of access to the TIFF file specified as one of the following. |
|
Specify scheme used to compress image data This property defines all the supported values for this tag.
You use this property to specify the value you want to assign to the
tag, using the Example: Set the tiffobj.setTag('Compression', Tiff.Compression.JPEG); |
|
Describe extra components This property defines all the supported values for this tag.
You use this property to specify the value you want to assign to the
tag, using the This field is required if there are extra channels in addition to the usual colormetric channels. Example: Set the tiffobj.setTag('ExtraSamples', Tiff.ExtraSamples.AssociatedAlpha); See Also Specify Tiff object properties and describe alpha channel |
|
Options for Group 3 Fax Compression This property defines all the supported values for this tag.
You use this property to specify the value you want to assign to the
tag, using the This property is also referred to as Example: mask = bitor(Tiff.Group3Options.Encoding2D,Tiff.Group3Options.Uncompressed) tiffobj.setTag('Group3Options',mask); |
|
Specify set of inks used in separated image This property defines all the supported values for this tag.
You use this property to specify the value you want to assign to the
tag, using the In this context, separated refers to photometric interpretation, not the planar configuration. Example: tiffobj.setTag('InkSet', Tiff.InkSet.CMYK); |
|
Specify control of YCbCr/RGB conversion Use these values only when the photometric interpretation is YCbCr. This property should not be used for the purpose of reading
YCbCr imagery as RGB. In this case, use the RGBA interface provided
by the Example: tiffobj.setTag('JPEGColorMode',Tiff/JPEGColorMode.RGB); |
|
Specify visual orientation of the image data. This property defines all the supported values for this tag.
You use this property to specify the value you want to assign to the
tag, using the The first row represents the top of the image, and the first column represents the left side. Support for this tag is for informational purposes only, and it does not affect how MATLAB reads or writes the image data. Example: tiffobj.setTag('Orientation', Tiff.Orientation.TopRight); |
|
Specify color space of image data This property defines all the supported values for this tag.
You use this property to specify the value you want to assign to the
tag, using the Example: tiffobj.setTag('Photometric', Tiff.Photometric.RGB); |
|
Specifies how image data components are stored on disk This property defines all the supported values for this tag.
You use this property to specify the value you want to assign to the
tag, using the Example: tiffobj.setTag('PlanarConfiguration', Tiff.PlanarConfiguration.Chunky); |
|
Specify unit of measure used to interpret the This property defines all the supported values for this tag.
You use this property to specify the value you want to assign to the
tag, using the Example: Set tiffObj.setTag('ResolutionUnit', Tiff.ResolutionUnit.Inch); tiffObj.setTag('XResolution', 300); tiffObj.setTag('YResolution', 300); |
|
Specify how to interpret each pixel sample This property defines all the supported values for this tag.
You use this property to specify the value you want to assign to the
tag, using the Example: tiffobj.setTag('SampleFormat', Tiff.SampleFormat.IEEEFP); |
|
Specify control of client data for SGILog codec This property defines all the supported values for this tag.
You use this property to specify the value you want to assign to the
tag, using the These enumerated values should only be used when the photometric
interpretation value is This tag can be set only once per instance of a Example: tiffobj = Tiff('example.tif','r'); tiffobj.setDirectory(3); % image three is a LogLuv image tiffobj.setTag('SGILogDataFmt', Tiff.SGILogDataFmt.Float); imdata = tiffobj.read(); |
|
Specify type of image This property defines all the supported values for this tag.
You use this property to specify the value you want to assign to the
tag, using the
Example: tiffobj.setTag('SubFileType', Tiff.SubFileType.Mask); |
|
List of recognized TIFF tag names with their ID numbers This property identifies all the supported TIFF tags with their
ID numbers. Use this property to specify a tag when using the Example: tiffobj.setTag(Tiff.TagID.ImageWidth, 300); |
|
Specifies technique used to convert from gray to black and white pixels. This property defines all the supported values for this tag.
You use this property to specify the value you want to assign to the
tag, using the Example: tiffobj.setTag('Thresholding', Tiff.Thresholding.HalfTone); |
|
Specify relative positioning of chrominance samples This property defines all the supported values for this tag.
You use this property to specify the value you want to assign to the
tag, using the This property identifies all supported values for the Example: tiffobj.setTag('YCbCrPositioning', Tiff.YCbCrPositioning.Centered); |
close | Close Tiff object |
computeStrip | Index number of strip containing specified coordinate |
computeTile | Index number of tile containing specified coordinates |
currentDirectory | Index of current IFD |
getTag | Value of specified tag |
getTagNames | List of recognized TIFF tags |
getVersion | LibTIFF library version |
isTiled | Determine if tiled image |
lastDirectory | Determine if current IFD is last in file |
nextDirectory | Make next IFD current IFD |
numberOfStrips | Total number of strips in image |
numberOfTiles | Total number of tiles in image |
read | Read entire image |
readEncodedStrip | Read data from specified strip |
readEncodedTile | Read data from specified tile |
readRGBAImage | Read image using RGBA interface |
readRGBAStrip | Read strip data using RGBA interface |
readRGBATile | Read tile data using RGBA interface |
rewriteDirectory | Write modified metadata to existing IFD |
setDirectory | Make specified IFD current IFD |
setSubDirectory | Make subIFD specified by byte offset current IFD |
setTag | Set value of tag |
write | Write entire image |
writeDirectory | Create new IFD and make it current IFD |
writeEncodedStrip | Write data to specified strip |
writeEncodedTile | Write data to specified tile |