我们大家都知道,sensor 直接出来的裸数据为raw 数据,没有经过编解码,压缩。
我们需要将raw数据转换为其他格式比如jpg,png,bmp 人眼才能看到。
import numpy as np
import imageio
rawfile = np.fromfile('C:/Users/awssome/Desktop/3.raw', dtype='uint16') # 以int16读图片
print(rawfile.shape)
rawfile.shape = (1520, 2688)
print(rawfile.shape)
b=rawfile.astype('uint16')#变量类型转换
print(b.dtype)
imageio.imwrite("C:/Users/awsome/Desktop/3.jpg", b)
import matplotlib.pyplot as pyplot
pyplot.imshow(rawfile)
pyplot.show()
本文介绍了如何将未经编解码的raw图像数据通过Python操作,如numpy处理和astype转换,最终保存为人眼可识别的jpg格式。通过实例展示了从读取raw文件、类型转换到图像显示的完整过程。
1543

被折叠的 条评论
为什么被折叠?



