Maximum number of frames in unint16 class tiff image (using libtiff).
6 次查看(过去 30 天)
显示 更早的评论
Hi there, I have a (long) time series of uint16 xyt dataset which I want to save as tiff.
I used
filename = 'testtifffp.tiff';
t = Tiff( filename,'w' );
sz = size(d);
tagstruct.ImageLength = size(d, 1);
tagstruct.ImageWidth = size(d, 2);
%tagstruct.ImageDepth = size(d, 3);
tagstruct.SampleFormat = Tiff.SampleFormat.UInt;
tagstruct.Photometric = Tiff.Photometric.MinIsBlack;
tagstruct.BitsPerSample = 16;
tagstruct.SamplesPerPixel = 1;
tagstruct.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky;
for z = 1:min(sz(3),8189)
t.setTag(tagstruct);
t.write(d(:,:,z));
if z < sz(3)
t.writeDirectory();
fprintf('%%')
end
if ~rem(z,128);fprintf('\n');end
end
fprintf('\n');
t.close();
but reach the problem that I cannot write more than 8189 frames.
At frame 8190 I get
Error using tifflib
Unable to write strip #1.
Error in Tiff/writeAllStrips (line 1982)
tifflib('writeEncodedStrip',obj.FileID, stripNum-1,imageData(row_inds,:));
Error in Tiff/write (line 1486)
obj.writeAllStrips(varargin{:});
Error in NisargsBrain (line 125)
t.write(d(:,:,z));
the easier command
t.write(d);
causes the following error
t.write(d);
Warning: Sum of Photometric color channels and ExtraSamples does not match the value specified in SamplesPerPixel.
Writing with this configuration will error in a future release. To correct the configuration, define the non-color channels as ExtraSamples.
Error using tifflib
Unable to write strip #1.
Error in Tiff/writeAllStrips (line 1980)
tifflib('writeEncodedStrip',obj.FileID,stripNum-1,imageData(row_inds,:,:));
Error in Tiff/write (line 1486)
obj.writeAllStrips(varargin{:});
It is probably the same problem.
Is there any option to save more than 8189 frames when
sz = size(d)
sz =
512 512 16384
?
Any solution?
>> versionString = Tiff.getVersion()
versionString =
'LIBTIFF, Version 4.4.0
Copyright (c) 1988-1996 Sam Leffler
Copyright (c) 1991-1996 Silicon Graphics, Inc.'
0 个评论
采纳的回答
DGM
2023-3-28
移动:DGM
2023-3-28
I don't think this is a limitation on the number of channels. I think you're simply running into the 4GB limit and would need to use BigTIFF to create a larger file. The best way to do that in MATLAB? I'm not sure off the top of my head.
2 个评论
DGM
2023-3-28
编辑:DGM
2023-3-28
I am not sure what aspect of addressing gives rise to the limitation, so I'm not sure if that's 4GB of image data or 4GB of file size. I don't really have the memory to do much testing.
If you want to avoid trying to figure out what it takes to use BigTIFF, you might try it. The achieveable compression ratio would be dependent on the data and the compression method used..
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!