write
写整个图像
说明
示例
将图像数据写入到 TIFF 文件中
将一个 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 文件中
将一个 YCbCr 图像以及表示该图像特征的多个标记值写入到新的 TIFF 文件中。
加载图像并显示图像的 Y 分量。
load('peppers_YCbCr.mat'); imshow(Y); title('Peppers Image (Y Component)');
创建一个 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)
输入参数
t
— Tiff 对象
Tiff
对象
代表 TIFF 文件的 Tiff
对象。使用 Tiff
函数创建该对象。
imageData
— 图像数据
数值数组
图像数据,指定为数值数组。以一个 RGB 图像为例,其 imageData
是 M
×N
×3
数组。其中 M
和 N
分别是图像中的行数和列数。
数据类型: double
Y
— 亮度分量
数值数组
图像数据的亮度分量,指定为二维数值数组。
数据类型: double
Cb
— 蓝差色度分量
数值数组
图像数据的蓝差色度分量,指定为二维数值数组。
数据类型: double
Cr
— 红差色度分量
数值数组
图像数据的红差色度分量,指定为二维数值数组。
数据类型: double
提示
不建议写那些具有某些光度配置和每像素采样数的 TIFF 图像。
SamplesPerPixel
的值必须等于Tiff
对象中指定的Photometric
颜色通道数和ExtraSamples
的总和。
版本历史记录
在 R2009b 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)