Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble reading tiff files saved by MATLAB #36

Open
dickinson-lab opened this issue Feb 24, 2021 · 2 comments
Open

Trouble reading tiff files saved by MATLAB #36

dickinson-lab opened this issue Feb 24, 2021 · 2 comments

Comments

@dickinson-lab
Copy link

I'm not sure whether this is an issue with TIFFStack or not, but I'm hoping you might be able to point me towards a solution.

I have a 3D stack that I have saved to disk using the MATLAB Tiff object, which I believe is a wrapper for libtiff. I can open this file (and the image looks correct) using ImageJ or MATLAB imread, so it seems to be a bona fide TIFF file. However, when I try to use TIFFStack to read this file back into MATLAB, I get the following error:

Error using tiffread31_header (line 54)
This is not a TIFF file (no MM or II).

It can't really be possible that MATLAB's Tiff doesn't write the header properly, can it? There must be an issue with the reader, unless I'm missing something. Thanks in advance for any suggestions!

@dickinson-lab
Copy link
Author

I think I figured it out: The issue is on line 44 of tiffread31_header.m. Current code is
bos = fread(TIF.file, 2, '*char');
The issue is that the 'char' format is platform-dependent, and apparently my system wasn't reading it correctly. I changed it to
bos = fread(TIF.file, 2, 'uchar=>char');
which seems to have fixed the issue. Let me know if you want me to submit a pull request for this change.

@marcel-goldschen-ohm
Copy link

I'm also getting an error reading files written using Matlab's imwrite function. The error message I get complains about the compression format not being supported:

'Compression format 32773 not supported.'

I've tried specifying the compression mode in imwrite as 'none', 'packbits', or 'lzw', but none of those work. Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants