有没有办法用python显示原始图像?

2024-05-19 20:12:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我想以RGB565大端或灰色16位大端显示原始图像。此代码的结果是little Endian

from cv2 import cv2
import numpy as np
import sys
from struct import *



fd = open('path', 'rb')
rows = 360
cols = 640
f = np.fromfile(fd, dtype=np.int16,count=rows*cols)
im = f.reshape((rows, cols)) #notice row, column format
fd.close()

print(fd)

cv2.imshow('', im)
cv2.waitKey()
cv2.destroyAllWindows()

Tags: 代码from图像importnumpynpcv2rows