import numpy as np
import cv2
rawImg = np.fromfile('./test.raw', dtype=np.uint8)
rawImg = rawImg.reshape(1200, 1792, 1)
cv2.imwrite('./img_test.bmp', rawImg)
本文介绍了一种使用Python的numpy和OpenCV库将原始RAW格式图像数据转换为BMP格式的方法。首先,从文件中读取RAW数据,并将其重塑为指定尺寸的二维数组。然后,使用cv2.imwrite()函数将此数据保存为BMP图像。
import numpy as np
import cv2
rawImg = np.fromfile('./test.raw', dtype=np.uint8)
rawImg = rawImg.reshape(1200, 1792, 1)
cv2.imwrite('./img_test.bmp', rawImg)
您可能感兴趣的与本文相关的镜像
Python3.8
Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本