nextDirectory failing at 65535

2 views (last 30 days)
Arran Curran
Arran Curran on 20 Jun 2021
Edited: dpb on 20 Jun 2021
I have a tiff stack of > 65535 images. Doing the following fails at n = 65535, where frames is the number of images which is significantly greater than 2^16.
img_stack = Tiff( 'FILENAME.tif' ) ;
[ i , j ] = size( img_stack.read() );
img = zeros( i , j , frames) ;
for n = 1 : frames
img_stack.nextDirectory()
img( : , : , n ) = img_stack.read() ;
SOME PROCESS ON img
end
This fails with,
Error using tifflib
Unable to read the next directory.
Error in Tiff/nextDirectory (line 934)
tifflib('readDirectory',obj.FileID)
Error in readin (line 5)
img_stack.nextDirectory()
Then if we start the for loop at 65535 the loop fails at ... 2 * 65535! Given this is one integer below 2^16 suggests that the integer being used to keep track of nextDirectory() is a 16 bit number...?
Is this something anyone has come accross and knows more?
  1 Comment
DGM
DGM on 20 Jun 2021
Edited: DGM on 20 Jun 2021
As far as I know, that's a limitation of tifflib.
If you can manage to get it to read the next 65535 frames by using an offset, then that would probably be decent workaround. I didn't expect that would work, but if it does, then that's in your favor.

Sign in to comment.

Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!