【发布时间】:2015-05-14 12:22:47
【问题描述】:
我正在尝试将多页(准确地说是 1024 页)写入文件。
for frame=1:num_images
imwrite(output(:,:,frame), 'output.tif', 'tif', 'WriteMode', 'append', 'compression', 'none');
end
我试过这个,但是 imwrite 不支持将 Int32 写入 tiff。 我也试过了
tiffObj = Tiff('output.tif', 'w');
tiffObj.setTag('ImageLength', x_size);
tiffObj.setTag('ImageWidth', y_size);
tiffObj.setTag('Photometric', Tiff.Photometric.MinIsBlack);
tiffObj.setTag('BitsPerSample', 32);
tiffObj.setTag('SamplesPerPixel', 1);
tiffObj.setTag('RowsPerStrip', 64);
tiffObj.setTag('SampleFormat', Tiff.SampleFormat.Int);
tiffObj.setTag('TileWidth', 128);
tiffObj.setTag('TileLength', 128);
tiffObj.setTag('Compression', Tiff.Compression.None);
tiffObj.setTag('PlanarConfiguration',Tiff.PlanarConfiguration.Chunky);
tiffObj.setTag('Software', 'MATLAB');
tiffObj.write(output);
tiffObj.close();
我 imread() 的 tif 每帧有 1 个 SamplesPerPixel,但是当我尝试使用相同的值时,我得到了
SamplesPerPixel 为 1,但提供的图像平面数为 1204。
如果我将其设置为 1204 Imagej 抱怨
不支持的 SamplesPerPixel:1204
这很令人沮丧。
【问题讨论】:
-
说实话我没有意识到有一个下载按钮所以一开始我不明白他所说的功能是从哪里来的。效果很好,谢谢:)
-
MATLAB 在多页 TIFF 方面表现不佳;我最近有非常相似的挫败感。改用这个:mathworks.com/matlabcentral/fileexchange/…