summaryrefslogtreecommitdiffstats
path: root/tests/make-input-multipage-readers
blob: a5651225d17f10bc7115e72701dff64e832b468b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python3

import h5py
import numpy as np
import tifffile


base = np.ones((15, 128, 128), dtype=np.uint16) * np.arange(15, dtype=np.uint16)[:, np.newaxis, np.newaxis]
fmt = 'multipage-image-{:>02}.{}'


for i in range(4):
    current = base + i * len(base)
    tifffile.imsave(fmt.format(i, 'tif'), current)
    with h5py.File(fmt.format(i, 'h5'), 'w') as f:
        dset = f.create_dataset('images', data=current)
    with open(fmt.format(i, 'raw'), 'wb') as f:
        f.write(current.tostring())