Image 使用MATLAB TIFF类时为空白TIF图像

Image 使用MATLAB TIFF类时为空白TIF图像,image,image-processing,tiff,matlab,Image,Image Processing,Tiff,Matlab,*strong text*我试图在2012a中使用MATLAB TIFF类保存多页TIF文件,方法如下。我的用法不同之处在于,我正在编写一个32位灰度图像,其值范围约为-10000到200000 % Use 'a' for 'append' since this code is in a loop that writes each page. % Note: 'fileName' is defined elsewhere and the file is created. t = Tiff(fil

*strong text*我试图在2012a中使用MATLAB TIFF类保存多页TIF文件,方法如下。我的用法不同之处在于,我正在编写一个32位灰度图像,其值范围约为-10000到200000

% Use 'a' for 'append' since this code is in a loop that writes each page.
% Note: 'fileName' is defined elsewhere and the file is created.
t = Tiff(fileName, 'a');

tagstruct.ImageLength = size(result, 2);
tagstruct.ImageWidth = size(result, 1);
tagstruct.Photometric = Tiff.Photometric.MinIsBlack;
tagstruct.SampleFormat = Tiff.SampleFormat.IEEEFP;
tagstruct.Compression = Tiff.Compression.None;
tagstruct.BitsPerSample = 32;
tagstruct.SamplesPerPixel = 1;
tagstruct.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky;
tagstruct.Software = 'MATLAB';
t.setTag(tagstruct);

% Viewing the data immediately before the 'write' operation shows it correct.
% imtool(result(:, :, j));
% Tools -> Adjust Contrast                       
t.write(result(:, :, j));

t.close();
由MATLAB和ImageJ检查的输出图像大小正确,元数据正确,但所有值均为零

更新:

MATLAB的文档对于TIFF类来说有点稀疏,TIFF类本身就是该类的包装器。表示每种TIF图像类型所需字段的完整列表。

中有一行代码中没有:

tagstruct.RowsPerStrip = 16

因此,
tagstruct
RowsPerStrip
字段缺失可能是全零映像的原因。

您是正确的。MATLAB文档(对我来说)没有将“RowsPerStrip”指定为必填字段。添加条目确实创建了一个包含可用数据的TIF文件。非常感谢。