我通过下载
JSRT database找到了一些像你这样的射线照片图像.我在这个数据库的第一张图片上测试了下面的代码:JPCLN001.IMG.
import matplotlib.pyplot as plt
import numpy as np
# Parameters.
input_filename = "JPCLN001.IMG"
shape = (2048,2048) # matrix size
dtype = np.dtype('>u2') # big-endian unsigned integer (16bit)
output_filename = "JPCLN001.PNG"
# Reading.
fid = open(input_filename,'rb')
data = np.fromfile(fid,dtype)
image = data.reshape(shape)
# Display.
plt.imshow(image,cmap = "gray")
plt.savefig(output_filename)
plt.show()
它生成一个输出文件JPCLN001.PNG,如下所示:
我希望我已经回答了你的问题.快乐的编码!