0
* 強文本 *我正在嘗試使用MATLAB TIFF類在2012a中保存多頁TIF文件,方法是遵循example in the documentation。我的用法不同,我正在寫一個32位灰度圖像,值範圍從大約-10,000到200,000。使用MATLAB TIFF類時的空白TIF圖像
% 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類,這本身就是對LibTIFF library的包裝有點稀疏。 official TIFF Specification Version 6表示每個TIF圖像類型的必填字段的完整列表。
你是對的。 MATLAB文檔不會以指定'RowsPerStrip'爲必填字段的方式讀取(對我)。添加條目確實創建了包含可用數據的TIF文件。謝謝。 – Noren