Notes on reading and writing float32 TIFF images in python

background

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.

Method

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).

Be careful with endian

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

Notes on reading and writing float32 TIFF images in python
Reading and writing text in Python
Reading and writing CSV and JSON files in Python
Notes on Python and dictionary types
Python CSV file reading and writing
Reading and writing NetCDF with Python
Reading and writing CSV with Python
[Python] Notes on while statements (writing style and infinite loop)
Notes using cChardet and python3-chardet in Python 3.3.1.
Notes on building Python and pyenv on Mac
Reading and writing JSON files with Python
(Python) HTML reading and regular expression notes
Notes on using code formatter in Python
Read the file with python and delete the line breaks [Notes on reading the file]
Notes on installing Python3 and using pip on Windows7
Study from Python Reading and writing Hour9 files
ABC125_C --GCD on Blackboard [Notes solved in Python]
Example of reading and writing CSV with Python
Notes on HDR and RAW image processing with Python
[Introduction for beginners] Reading and writing Python CSV files
Notes on writing config files for Python Note: configparser
Notes on exchanging and multiple assignment of Python variable values ​​learned in quiz format
Notes on how to use StatsModels that can use linear regression and GLM in python
I tried [scraping] fashion images and text sentences in Python.
Notes on tf.function and Tracing
Base64 encoding images in Python 3
Python on Ruby and angry Ruby on Python
Web scraping notes in python3
Notes on * args and ** kargs
Reading and writing csv files
Notes on pyenv and Atom
[Python] Notes on data analysis
Notes on installing Python on Mac
An introduction to statistical modeling for data analysis (Midorimoto) reading notes (in Python and Stan)
Stack and Queue in Python
Notes on deploying pyenv with Homebrew and managing Python versions
Notes on imshow () in OpenCV
Notes on installing Python on CentOS
How to install OpenCV on Cloud9 and run it in Python
uproot: Python / Numpy based library for reading and writing ROOT files
Number recognition in images with Python
Pixel manipulation of images in Python
MIDI packages in Python midi and pretty_midi
Python 3.6 on Windows ... and to Xamarin.
Difference between list () and [] in Python
Difference between == and is in python
View photos in Python and html
Sorting algorithm and implementation in Python
Minimum grammar notes for writing Python
Notes on using MeCab from Python
Manipulate files and folders in Python
About dtypes in Python and Cython
Notes on using post-receive and post-merge
Assignments and changes in Python objects
Integrate Modelica and Python on Windows
Check and move directories in Python
Extract text from images in Python
Ciphertext in Python: IND-CCA2 and RSA-OAEP
Notes on installing Python using PyEnv
Hashing data in R and Python
Function synthesis and application in Python