簡體   English   中英

有沒有辦法在python中顯示原始圖像?

[英]Is there any way to display a raw image in python?

我想以 RGB565-Big Endian 或灰色 16 位 Big-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()

來自https://docs.scipy.org/doc/numpy/user/basics.byteswapping.html

將第 11 行中的 dtype 替換為:

dtype='>i2'

>代表大端

i代表整數

2代表 2 個字節

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM