python3 raw 數據轉換為jpg


python3 raw 數據轉換為jpg

我們大家都知道,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()








免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM