Main Content

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

writeEncodedStrip

将数据写入到指定的条带

说明

示例

writeEncodedStrip(t,stripNumber,imageData)imageData 写入到与 Tiff 对象 t 关联的 TIFF 文件中由 stripNumber 指定的条带中。

示例

writeEncodedStrip(t,stripNumber,Y,Cb,Cr) 将 YCbCr 分量数据写入到与 Tiff 对象 t 关联的 TIFF 文件中由 stripNumber 指定的条带中。要使用此语法,您必须设置 YCbCrSubSampling 标记的值。

示例

全部折叠

从一个 TIFF 文件中读取两个条带,并将它们写入到另一个新 TIFF 文件中的不同位置。

打开一个包含条状布局的图像数据的 TIFF 文件,获取图像数据和图像中的条带数。

tr = Tiff('peppers_RGB_stripped.tif','r');
imageR = read(tr);
nStrips = numberOfStrips(tr)
nStrips = 6

读取图像的第二个和第五个条带。

stripTwo = readEncodedStrip(tr,2);
stripFive = readEncodedStrip(tr,5);

为新文件创建一个 Tiff 对象,并从第一个文件中复制图像和标记信息。

tw = Tiff('write_strip.tif','w');
tagstruct.ImageLength = getTag(tr,'ImageLength');
tagstruct.ImageWidth =  getTag(tr,'ImageWidth');
tagstruct.Photometric = getTag(tr,'Photometric');
tagstruct.RowsPerStrip = getTag(tr,'RowsPerStrip');
tagstruct.BitsPerSample = getTag(tr,'BitsPerSample');
tagstruct.SamplesPerPixel = getTag(tr,'SamplesPerPixel');
tagstruct.PlanarConfiguration = getTag(tr,'PlanarConfiguration');  
setTag(tw,tagstruct); 
write(tw,imageR)

在条带 2 的位置写入 stripFive,在条带 5 的位置写入 stripTwo

writeEncodedStrip(tw,2,stripFive);
writeEncodedStrip(tw,5,stripTwo);

读取新图像并与原图像并排显示。

imageW = read(tw);
subplot(121);
imshow(imageR); 
title('Original Image')
subplot(122);
imshow(imageW); 
title('Strips Shuffled Image')

关闭 Tiff 对象。

close(tr);
close(tw);

从一个 YCbCr TIFF 文件中读取两个条带,并将它们写入到另一个新 TIFF 文件中的不同位置。

打开包含条状布局的 YCbCr 图像数据的 TIFF 文件,获取图像数据和图像中的条带数。

tr = Tiff('peppers_YCbCr_stripped.tif','r');
[Yr,Cbr,Crr] = read(tr);
nStrips = numberOfStrips(tr)
nStrips = 6

读取图像的第 2 个和第 5 个条带。

[Y2,Cb2,Cr2] = readEncodedStrip(tr,2);
[Y5,Cb5,Cr5] = readEncodedStrip(tr,5);

为新文件创建一个 Tiff 对象,并从第一个文件中复制图像和标记信息。

tw = Tiff('write_strip.tif','w');
tagstruct.ImageLength = getTag(tr,'ImageLength');
tagstruct.ImageWidth =  getTag(tr,'ImageWidth');
tagstruct.SampleFormat = getTag(tr,'SampleFormat');
tagstruct.Photometric = getTag(tr,'Photometric');
tagstruct.RowsPerStrip = getTag(tr,'RowsPerStrip');
tagstruct.BitsPerSample = getTag(tr,'BitsPerSample');
tagstruct.SamplesPerPixel = getTag(tr,'SamplesPerPixel');
tagstruct.YCbCrSubSampling = getTag(tr,'YCbCrSubSampling');
tagstruct.Compression = getTag(tr,'Compression');
tagstruct.PlanarConfiguration = getTag(tr,'PlanarConfiguration');  
setTag(tw,tagstruct); 
write(tw,Yr,Cbr,Crr)

在条带 2 的位置写入条带 5,在条带 5 的位置写入条带 2。

writeEncodedStrip(tw,2,Y5,Cb5,Cr5);
writeEncodedStrip(tw,5,Y2,Cb2,Cr2);

读取新图像的 Y 分量并与原图像并排显示。

[Yw,Crw,Cbw] = read(tw);
subplot(121);
imshow(Yr); 
title('Original Image (Y)')
subplot(122);
imshow(Yw); 
title('Strips Shuffled Image (Y)')

关闭 Tiff 对象。

close(tr);
close(tw);

输入参数

全部折叠

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

条带编号,指定为正整数。条带编号是从 1 开始的数字。

示例: 15

数据类型: double

图像数据,指定为数值数组。

  • 如果 imageData 的字节数大于条带的大小,则 writeEncodedStrip 会发出警告并截断数据。

  • 如果 imageData 的字节数少于条带的大小,则 writeEncodedStrip 将以静默方式填充条带。

要确定条带的大小,请查看 RowsPerStrip 标记的值。

数据类型: double

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

数据类型: double

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

数据类型: double

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

数据类型: double

算法

全部折叠

参考

此函数对应于 LibTIFF C API 中的 TIFFWriteEncodedStrip 函数。要使用此函数,您必须熟悉 TIFF 规范和技术说明。请访问 LibTIFF - TIFF 库和实用工具查看此文档。

版本历史记录

在 R2009b 中推出