I want to read a 32-bit TIFF image (grayscale, RGB) generated by myself with python.
e.g. Using a DNG / TIFF writer that can be used with header only in C ++.
https://github.com/syoyo/tinydngloader/tree/master/examples/dngwriter
I want to save 2D tensor data and HDR images as tiffs.
How do you read a 32-bit TIFF image in python? https://stackoverflow.com/questions/40751523/how-do-you-read-a-32-bit-tiff-image-in-python
https://gist.github.com/ax3l/5781ce80b19d7df3f549
You can read it around skimage, imageio, Pillow (PIL), OpenCV. These seem to use tifffile internally. At least imageio used tifffile.
https://pypi.org/project/tifffile/
You may also be able to read it with rawpy.
You can save it around imageio (tifffile).
In TIFF, we found that pixel data must also be properly endian-converted. For example, when exporting with BigEndian on x86, endian conversion is performed.
When I read the BigEndian 32bit float TIFF with imageio and cv2 with my own tiff, I noticed that the pixel value was swapped and became an indefinite value.
Originally, it should not be necessary to swap, but is it decided by the TIFF specification somewhere?
For the time being, for x86, it's a good idea to create a TIFF with Little endian.
Recommended Posts