Big tiff problem again.

I am again encountering problems working with a tiff > 2GB. (I inquired about a similar problem previously, and three of my posts were removed for being ads or promotional - it doesn’t make any sense to me.)
I have used ITK to create a 3D tiff (from 400 slices) that is a bit bigger than 2GB. It is not recognized by irfanview-64 or by Fiji. If I reduced the number of slices to 350 everything is OK. I don’t understand where the 2GB restriction is coming from. I thought maybe it was a Windows issue, but in that case surely I would not be able to create the tiff to start with.

Suggestions welcome.
Gib

1 Like

https://www.awaresystems.be/imaging/tiff/bigtiff.html

It looks like the last significant refactoring of TIFF code was done by @blowekamp back in 2014. 2GB is the limit where ITK decides to write BigTIFF instead of the regular TIFF.

1 Like

@dzenanz Is correct at 2GB itk::TIFFImageIO switches to writing BigTIFF. Technically, regular tiff files can support large, but due to potential (maybe actual?) problems with 32-bit signed integer math 2GB is the decision point.

I have had some success and some problems writing TIFFs with ITK then reading with Fiji. Scalar images seem to work well, but multi-components image I have had problems.

Can you please share the specifics of you Image size, pixel type and number of components?

Fiji uses SCIFIO so there may be some compatibility that could be improved on both ends.
@ctrueden

2 Likes

Thanks to David, Dzenan and Bradley.
My slices are 2160x2560, 8-bit. There is only one component.
The 400-page 3D tiff is 2,160,183 KB.
The message from Fiji is “File is not in a supported format”
Irfanview appears to open the file, but thinks it has only 2 pages. In the case of the compressed file it thinks it has 4 pages.
Could the fact that I’m using ITK-4.7.2 be relevant?

1 Like

Yes, that version is quite old.

I was able to write tiff images with SimpleITK 1.2.3, and then read the with Fiji which recovered the correct volume size with a little SimpleITK script:

import SimpleITK as sitk
img = sitk.Image([2160, 2560, 400], sitk.sitkUInt8)
writer = sitk.ImageFileWriter()
writer.SetImageIO("TIFFImageIO")
writer.SetUseCompression(True)
writer.SetFileName("test_compressed.tif")
writer.Execute(img)

OK, it’s about time I installed a recent version. Are there any gotchas?

You will probably need to make minor modifications to your code, especially if you want to build ITK with disabled legacy code. A migration guide is available. In case something is missing from it, please let us know or submit a PR yourself.

In case you really don’t want to migrate to ITKv5, you could use version 4.13.2+.

Thanks Dzenan. I just tried to build 5.0.1, and discovered that it needs VS 2015, but I only have VS 2012. Will version 4.13.2+ build with VS 2012?

I answered my own question - now building with VS 2012.
I first made the mistake of downloading the 4.13.2 zip file at https://itk.org/ITK/resources/software.html, but this gave cmake errors. Using the github file all is OK.

I built version 4.13.2, but the behaviour with these tiffs is identical to 4.7.2, as far as I can tell. Looking at the responses to an earlier query I made on this subject, I see that Curtis Rueden suggested using the SCIFIO plugin in ImageJ to read big tiffs. This works.
3 Likes

Yes, My FIJI was automatically using SCIFIO when I said it was working.

1 Like

I had to turn on SCIFIO in Fiji.

1 Like