【问题标题】:Blank TIF image when using MATLAB TIFF class使用 MATLAB TIFF 类时的空白 TIF 图像
【发布时间】:2012-05-15 15:17:05
【问题描述】:

*strong text*我正在尝试按照example in the documentation 在 2012a 中使用 MATLAB TIFF 类保存多页 TIF 文件。我的用法有所不同,因为我正在编写一个 32 位灰度图像,其值范围约为 -10,000 到 200,000。

% 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 检查,输出图像大小正确,元数据正确,但所有值均为零。

更新:

对于 TIFF 类,MATLAB 的文档有些稀疏,它本身就是 LibTIFF library 的包装器。 official TIFF Specification Version 6 表示每种 TIF 图像类型的必填字段的完整列表。

【问题讨论】:

    标签: image image-processing tiff matlab


    【解决方案1】:

    example of MATLAB documentation: Exporting to images 中有一行您的代码中没有:

    tagstruct.RowsPerStrip = 16
    

    所以可能缺少tagstructRowsPerStrip 字段是图像全为零的原因。

    【讨论】:

    • 你是对的。 MATLAB 文档没有以将“RowsPerStrip”指定为必填字段的方式读取(对我而言)。添加条目确实创建了一个包含可用数据的 TIF 文件。谢谢。
    猜你喜欢
    • 2015-10-17
    • 2015-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-18
    • 2012-04-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多