23 lines
565 B
Python
23 lines
565 B
Python
import imageio
|
|
import numpy as np
|
|
|
|
cut_width = 512
|
|
cut_height = 256
|
|
|
|
if __name__ == '__main__':
|
|
# txt = open('./test.dat', 'w')
|
|
binfile = open('./test.bin', "wb")
|
|
image = imageio.imread_v2('./im.tif')
|
|
|
|
print(image.shape)
|
|
cut = image[0:cut_height, 0:cut_width]
|
|
print(cut.shape)
|
|
cut = np.array(cut, dtype=np.int16)
|
|
|
|
for data in list(cut.flatten()):
|
|
# txt.write('%02x\n%02x\n' % (data & 0x00ff, (data & 0xff00) >> 4))
|
|
binfile.write(data)
|
|
# txt.close()
|
|
binfile.close()
|
|
|
|
# imageio.imsave('./test.tif', cut) |