Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

write

写整个图像

说明

示例

write(t,imageData)imageData 写入到与 Tiff 对象 t 关联的 TIFF 文件中。write 方法将数据划分为条带或图块,具体取决于 RowsPerStrip 标记或 TileLengthTileWidth 标记的值。

示例

write(t,Y,Cb,Cr) 将 YCbCr 分量数据写入到 TIFF 文件中。仅为拥有 YCbCr 光度表示的图形使用此语法。

示例

全部折叠

将一个 RGB 图像以及表示该图像特征的多个标记值写入到新的 TIFF 文件中。

加载图像数据并显示图像。

load('peppers_RGB.mat');
imshow(RGB);
title('Peppers Image (RGB)');

创建一个 Tiff 对象,将图像数据写入到 TIFF 文件中。

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

使用 tagstruct 结构体来定义表示图像特征的多个标记值。

tagstruct.ImageLength = size(RGB,1); 
tagstruct.ImageWidth = size(RGB,2);
tagstruct.Photometric = Tiff.Photometric.RGB;
tagstruct.BitsPerSample = 8;
tagstruct.SamplesPerPixel = 3;
tagstruct.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky; 
tagstruct.Software = 'MATLAB'; 

设置 Tiff 对象的标记值。

setTag(t,tagstruct)

将图像数据写入到文件中,然后关闭 Tiff 对象。

write(t,RGB);
close(t);

将一个 YCbCr 图像以及表示该图像特征的多个标记值写入到新的 TIFF 文件中。

加载图像并显示图像的 Y 分量。

load('peppers_YCbCr.mat');
imshow(Y);
title('Peppers Image (Y Component)');

Figure contains an axes object. The axes object with title Peppers Image (Y Component) contains an object of type image.

创建一个 Tiff 对象,将图像数据写入到 TIFF 文件中。

t = Tiff('myfile_YCbCr.tif','w');  

使用 tagstruct 结构体来定义表示图像特征的多个标记值。

tagstruct.ImageLength = size(Y,1);
tagstruct.ImageWidth = size(Y,2);
tagstruct.SampleFormat = 1; % uint
tagstruct.Photometric = Tiff.Photometric.YCbCr;
tagstruct.BitsPerSample = 8 ;
tagstruct.SamplesPerPixel = 3;
tagstruct.YCbCrSubSampling = [1,1];
tagstruct.Compression = Tiff.Compression.None;  
tagstruct.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky; 
tagstruct.Software = 'MATLAB'; 

设置 Tiff 对象的标记值。

setTag(t,tagstruct)

将图像数据写入到文件中,然后关闭 Tiff 对象。

write(t,Y,Cb,Cr)
close(t)

输入参数

全部折叠

代表 TIFF 文件的 Tiff 对象。使用 Tiff 函数创建该对象。

图像数据,指定为数值数组。以一个 RGB 图像为例,其 imageDataM×N×3 数组。其中 MN 分别是图像中的行数和列数。

数据类型: double

图像数据的亮度分量,指定为二维数值数组。

数据类型: double

图像数据的蓝差色度分量,指定为二维数值数组。

数据类型: double

图像数据的红差色度分量,指定为二维数值数组。

数据类型: double

提示

  • 不建议写那些具有某些光度配置和每像素采样数的 TIFF 图像。SamplesPerPixel 的值必须等于 Tiff 对象中指定的 Photometric 颜色通道数和 ExtraSamples 的总和。

版本历史记录

在 R2009b 中推出