Effacer les filtres
Effacer les filtres

Maximum number of frames in unint16 class tiff image (using libtiff).

6 vues (au cours des 30 derniers jours)
Andre Zeug
Andre Zeug le 28 Mar 2023
Modifié(e) : DGM le 28 Mar 2023
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.'

Réponse acceptée

DGM
DGM le 28 Mar 2023
Déplacé(e) : DGM le 28 Mar 2023
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 commentaires
Andre Zeug
Andre Zeug le 28 Mar 2023
🙈 Oh yeah, file size just reaches 4GB, would compression help (a bit) to stay below 4GB?
DGM
DGM le 28 Mar 2023
Modifié(e) : DGM le 28 Mar 2023
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..

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by