Reading and writing image data is a recurring task, and I was wondering, why reading and writing image sequences that are saved in one single
*.tiff file are not a standard function in the imaging libraries I regularly use (such as OpenCV, libtiff, Pillow etc.).
Reading 3D tiff files is easy, e.g. with OpenCV
import cv2 res_tuple = cv2.imreadmulti(path_to_file, flags = cv2.IMREAD_UNCHANGED)
will do the job. However, when trying to save the resulting array back to a file, it will fail. A working filesave for 3D tiff stacks could e.g. look like this:
from skimage.external import tifffile as tif import numpy as np image = np.ones((100,10,10), dtype=np.uint16) tif.imsave('test.tif', image)
Of course the
tifffile library will do that as well, however, I find it more convenient to have only
scikit-image installed and let it call the
tifffile as external library.