You can write a (22,5,3884) array of float32
to a TIFF like this:
import tifffile
import numpy as np
# Synthesize image
signals = np.zeros((22,5,3844), dtype=np.float32)
# Save as TIFF
tifffile.imwrite('signals.tif', signals)
If you check the result with tiffinfo
:
tiffinfo signals.tif
you can see there are 22 images in the file, each one a 3844x5 greyscale image of 32-bit IEEE-754 floating point.
Sample Output
TIFF Directory at offset 0x8 (8)
Image Width: 3844 Image Length: 5
Resolution: 1, 1 (unitless)
Bits/Sample: 32
Sample Format: IEEE floating point
Compression Scheme: None
Photometric Interpretation: min-is-black
Samples/Pixel: 1
Rows/Strip: 5
Planar Configuration: single image plane
ImageDescription: {"shape": [22, 5, 3844]}
Software: tifffile.py
TIFF Directory at offset 0x19d020 (1691680)
... abbreviated, but as above ...
TIFF Directory at offset 0x19d0d2 (1691858)
... abbreviated, but as above ...
TIFF Directory at offset 0x19d184 (1692036)
... abbreviated, but as above ...
TIFF Directory at offset 0x19d236 (1692214)
TIFF Directory at offset 0x19d2e8 (1692392)
TIFF Directory at offset 0x19d39a (1692570)
TIFF Directory at offset 0x19d44c (1692748)
TIFF Directory at offset 0x19d4fe (1692926)
TIFF Directory at offset 0x19d5b0 (1693104)
TIFF Directory at offset 0x19d662 (1693282)
TIFF Directory at offset 0x19d714 (1693460)
TIFF Directory at offset 0x19d7c6 (1693638)
TIFF Directory at offset 0x19d878 (1693816)
TIFF Directory at offset 0x19d92a (1693994)
TIFF Directory at offset 0x19d9dc (1694172)
TIFF Directory at offset 0x19da8e (1694350)
TIFF Directory at offset 0x19db40 (1694528)
TIFF Directory at offset 0x19dbf2 (1694706)
TIFF Directory at offset 0x19dca4 (1694884)
TIFF Directory at offset 0x19dd56 (1695062)
TIFF Directory at offset 0x19de08 (1695240)
If you want the signals stacked one-above-the-other vertically, you can reshape()
like this:
tifffile.imwrite('signals.tif', signals.reshape(110,3844))
I made each of the 22 sub-images a solid grey that increases down the stack so you can see the image is dark at the top and light at the bottom:
