Maximum number of frames in unint16 class tiff image (using libtiff).
조회 수: 5 (최근 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!