3
我使用this question的代碼將一些原始圖像轉換爲png。在Python中調整圖像大小
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()
事情是,我期待一個2048x2048的PNG大小,但我得到的是500x500下的圖像。有關如何解決這個問題的任何建議?