I have an array with 600×600×40 dimension that each band(from 40 band) represent a 600×600 image I want to save it to a multiple band .tif image. I have tried this functions from scikit-image and openCV but they can not save more than 3 band(as RGB).
import cv2
cv2.imwrite('image.tif',600by600_just3band_array)
tifffile
(https://pypi.org/project/tifffile/) supports multi-channel .tiff's and has an API similar to the one of scikit-image
or OpenCV
:
In [1]: import numpy as np
In [2]: import tifffile
In [3]: # Channel dimension should come first
In [4]: x = np.random.randint(0, 255, 4*100*100).reshape((4, 100, 100))
In [5]: tifffile.imsave('test.tiff', x)
In [6]: y = tifffile.imread('test.tiff')
In [7]: np.all(np.equal(x, y))
Out[7]: True
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With