ISP/sim/transform/raw_cut.py

23 lines
567 B
Python
Raw Normal View History

2024-05-10 13:13:50 +08:00
import imageio
import numpy as np
2024-05-18 18:56:32 +08:00
cut_width = 1936
cut_height = 1088
2024-05-10 13:13:50 +08:00
if __name__ == '__main__':
2024-05-14 21:00:19 +08:00
# txt = open('./test.dat', 'w')
binfile = open('./test.bin', "wb")
2024-05-10 13:13:50 +08:00
image = imageio.imread_v2('./im.tif')
2024-05-14 21:00:19 +08:00
2024-05-10 13:13:50 +08:00
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()):
2024-05-14 21:00:19 +08:00
# txt.write('%02x\n%02x\n' % (data & 0x00ff, (data & 0xff00) >> 4))
binfile.write(data)
# txt.close()
binfile.close()
2024-05-10 13:13:50 +08:00
2024-05-14 21:00:19 +08:00
# imageio.imsave('./test.tif', cut)