Tiff class

MATLAB Gateway to LibTIFF library routines

Description

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 imwritefunctions 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 atLibTIFF - TIFF Library and Utilities.

MATLAB supports LibTIFF version 4.0.0.

For copyright information, see the libtiffcopyright.txt file.

Construction

obj = Tiff(filename,mode) creates a Tiff object associated with the TIFF file filenamemode 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 ImageWidthImageHeightBitsPerSampleSamplesPerPixelCompressionPlanarConfiguration, 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 theTileWidth and TileHeight tags. Use the setTag method to define values for these tags.

Input Arguments

filename

Text string specifying name of file.

mode

One of the following text strings specifying the type of access to the TIFF file.

 Supported Values

Properties

Compression

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 setTag method. For more clarification, see the example.

 Supported Values

Example: Set the Compression tag to the value JPEG. Note how you use the property to specify the value.

tiffobj.setTag('Compression', Tiff.Compression.JPEG);

ExtraSamples

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 setTag method. For more clarification, see the example.

This field is required if there are extra channels in addition to the usual colormetric channels.

 Supported Values

Example: Set the ExtraSamples tag to the value AssociatedAlpha. Note how you use the property to specify the value.

tiffobj.setTag('ExtraSamples', Tiff.ExtraSamples.AssociatedAlpha);

See Also Specify Tiff object properties and describe alpha channel

Group3Options

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 setTag method. For more clarification, see the example.

This property is also referred to as Fax3 and T4Options. This value is a bit mask controlled by the first three bits.

 Supported Values

Example:

mask = bitor(Tiff.Group3Options.Encoding2D,Tiff.Group3Options.Uncompressed)
tiffobj.setTag('Group3Options',mask);

InkSet

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 setTag method. For more clarification, see the example.

In this context, separated refers to photometric interpretation, not the planar configuration.

 Supported Values

Example:

tiffobj.setTag('InkSet', Tiff.InkSet.CMYK);

JPEGColorMode

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 readRGBAImagereadRGBAStrip, and readRGBATile methods.

 Supported Values

Example:

tiffobj.setTag('JPEGColorMode',Tiff/JPEGColorMode.RGB);

See also Create YCbCr/JPEG image from RGB data

Orientation

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 setTag method. For more clarification, see the example.

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.

 Supported Values

Example:

tiffobj.setTag('Orientation', Tiff.Orientation.TopRight);

Photometric

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 setTag method. For more clarification, see the example.

 Supported Values

Example:

tiffobj.setTag('Photometric', Tiff.Photometric.RGB);

PlanarConfiguration

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 setTag method. For more clarification, see the example.

 Supported Values

Example:

tiffobj.setTag('PlanarConfiguration', Tiff.PlanarConfiguration.Chunky);

ResolutionUnit

Specify unit of measure used to interpret the XResolution and YResolution tags.

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 setTag method. For more clarification, see the example.

 Supported Values

Example: Set ResolutionUnit tag to the value Inch. Then, setting XResolution tag to 300 means pixels per inch.

tiffObj.setTag('ResolutionUnit', Tiff.ResolutionUnit.Inch);
tiffObj.setTag('XResolution', 300);
tiffObj.setTag('YResolution', 300);

SampleFormat

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 setTag method. For more clarification, see the example.

 Supported Values

Example:

tiffobj.setTag('SampleFormat', Tiff.SampleFormat.IEEEFP);

SGILogDataFmt

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 setTag method. For more clarification, see the example.

These enumerated values should only be used when the photometric interpretation value is LogL or LogLUV. The BitsPerSampleSamplesPerPixel, and SampleFormat tags should not be set if the image type isLogL or LogLuv. The choice of SGILogDataFmt will set these tags automatically. The Float and Bits8settings imply a SamplesPerPixel value of 3 for LogLUV images, but only 1 for LogL images.

 Supported Values

This tag can be set only once per instance of a LogL/LogLuv Tiff image object instance.

Example:

tiffobj = Tiff('example.tif','r');
tiffobj.setDirectory(3); % image three is a LogLuv image
tiffobj.setTag('SGILogDataFmt', Tiff.SGILogDataFmt.Float);
imdata = tiffobj.read();

SubFileType

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 setTag method. For more clarification, see the example.

SubFileType is a bitmask that indicates the type of the image.

 Supported Values

Example:

tiffobj.setTag('SubFileType', Tiff.SubFileType.Mask);

TagID

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 setTag method. For example, Tiff.TagID.ImageWidth returns the ID of the ImageWidthtag. To get a list of the names of supported tags, use the getTagNames method.

Example:

tiffobj.setTag(Tiff.TagID.ImageWidth, 300);

Thresholding

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 setTag method. For more clarification, see the example.

 Supported Values

Example:

tiffobj.setTag('Thresholding', Tiff.Thresholding.HalfTone);

YCbCrPositioning

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 setTag method. For more clarification, see the example.

This property identifies all supported values for the YCbCrPositioning tag.

 Supported Values

Example:

tiffobj.setTag('YCbCrPositioning', Tiff.YCbCrPositioning.Centered);

Methods

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

See Also

imfinfo | imread | imwrite

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值