GreycLab/CImg

Reading and displaying 32-bit TIFF image files

Closed this issue · 6 comments

I am having some problems with reading a 32-bit TIFF image file. My code snippet is the following:

CImg ImgTest;
ImgTest.load_tiff("filename.TIF");
ImgTest.display("test image with 32 bit float values");

Unfortunately, the display image is cut off at 65,535 and won't show any float values even though it has values much larger than just 65,535.

The stdin output is:
test image: this = 0x7ffe0698e7d0, size = (480,480,1,1) [1800 Kio], data = (double*)0x7f81b7512010..0x7f81b76d400f (non-shared) = [ 65535 65535 65535 65535 0 0 65535 65535 ... 65535 65535 0 0 65535 65535 65535 65535 ], min = 0, max = 65535, mean = 46330.6, std = 29828.6, coords_min = (4,0,0,0), coords_max = (0,0,0,0).

Any help would be really appreciated, thanks!

You are using a CImg<float> ImgTest, right ?

Yes, I am.

Do I need to enable '#define cimg_use_tiff' in my source code?

Ah yes of course ! If you don't define cimg_use_tiff, then loading/saving tiff is not handled natively by CImg, but is done through ImageMagick's convert, and in this case there are limitations to 16bits tiff.

Great, it's working now! It wasn't so obvious, since unsigned int and unsigned char were both working.
Thanks a lot!

Happy to see this is working for you! In fact, support for float-valued tiff files is quite rare nowadays, so yes, apart from using libtiff directly, the chances it work with other tools are a bit marginal.
I think I can close the issue.