import matplotlib
from matplotlib import pyplot as plt
%matplotlib inline
arr = np.array([[130,146,133,95,71,71,62,78],
[130,146,133,92,62,71,62,71],
[139,146,146,120,62,55,55,55],
[139,139,139,146,117,112,117,110],
[139,139,139,139,139,139,139,139],
[146,142,139,139,139,143,125,139],
[156,159,159,159,159,146,159,159],
[168,159,156,159,159,159,139,159]
])
所以我想重新构建这个图像
我有每个像素的灰度颜色,我使用以下python代码(python 3,jupyter)
import matplotlib.image as mpimg
import matplotlib.cm as cm
fig = plt.figure(1, figsize=(8,6), dpi=64)
ax = fig.gca()
ax.autoscale_view(True, False, False)
plt.imshow(arr, cmap = cm.gray)
plt.show()
但我得到的结果是这张图片,但我希望将它显示为原始图像!