-1

寻找代码或操作系统库以使用 Java / C# / Python 读取RAW 12并以一些常用格式保存 - JPG、GIF、PNG。尝试以下代码:

import numpy 
from PIL import Image
import rawpy

input_file = 'c:\\IdeaProjects\\raw12\\IT8-chart-15ms.raw12'
npimg = numpy.fromfile(input_file, dtype=numpy.uint16)
imageSize = (2048, 1536)
npimg = npimg.reshape(imageSize)

发生异常:ValueError 无法将大小为 9437184 的数组重新整形为形状 (2048,1536)

 output_file = 'converted.tiff'
 Image.fromarray(npimg/1023.0).save(output_file)

图像 RAW12

4

1 回答 1

1

在您的情况下,尺寸(2048、1536)不正确,我尝试了 3072*3072,结果如下:

图片

import numpy as np
import matplotlib.pyplot as plt 

input_file =  "IT8-chart-5ms.raw12"
npimg = np.fromfile(input_file, dtype=np.uint16)
# print(npimg.shape)
imageSize = (3072,3072)
npimg = (npimg.reshape(imageSize)).astype(np.uint8)

plt.imshow(npimg, cmap='gray')
plt.axis('off')
plt.show()
于 2021-01-06T15:55:04.523 回答