Failed to read TIFF 64-bit samples

Hi VTK community :wave:

I’m coming from the 3D Slicer community (cc: @jcfr) where I have been attempting to a load a TIFF file where Slicer’s usage of the vtkTIFFReader is reporting [VTK] Unable to read tiff file: Sorry, can not handle images with 64-bit samples which originates at the following location below. Is VTK supposed to be able to load this file? Or is it functionality that has just not been implemented yet?

@dzenanz, was able to confirm that the itkTIFFImageIO reader also struggled in the same way where it reporting to load this image with 64-bit samples.

C:\Dev\ITK-git\Modules\IO\TIFF\src\itkTIFFImageIO.cxx:503:
ITK ERROR: TIFFImageIO(00000197AFFDF2A0): Unable to read tiff file: Sorry, can not handle images with 64-bit samples

A lot of this reader is from 2002 to 2005 (at least in the region of that message). I suspect that it just hasn’t been implemented (32 bits/sample isn’t available either for that matter).

Not sure if the 32 bits/sample and 64 bits/sample support originally came from BigTIFF being added to LibTIFF, but it appears that higher bit support became available starting in LibTIFF 4.0? Since VTK appears to be using LibTIFF 4.3.0, it seems like support would just need to be added on the VTK reader side?

Assuming that 4.0 is where it started being available, yes, it “just” needs support on the VTK side. I have no idea how much work that is though

I’m surprised to hear that vtkTIFFReader doesn’t support 16-bit images, because 10 years ago I was using it to read confocal microscopy images which are generally 16-bit. In fact the git logs refer to adding support for floating-point, too. But I haven’t used this reader for a while.

Ah, 64-bit. I was misreading. Sorry for the noise.

For the most part, converting the reader to 64-bit would just involve a careful search-and-replace of the 32-bit TIFF APIs with 64-bit TIFF APIs, and replacing unsigned int with uint64_t.

However, VTK itself has the restriction that image dimensions are limited to 31-bit. So the maximum image size is 2147483647^2 and maximum volume size is 2147483647^3 (or actually 2097152^3 - 1 due to the 63-bit limit on the number of voxels).