1
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]
               ])

So I want to re-construct this image

enter image description here

I have the colors in gray-scale for each pixel, and I am using the following python code (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()

But the result I get is this image, but I want to display it as sharp as the original!

enter image description here

Vahid Mirjalili
  • 6,211
  • 15
  • 57
  • 80

0 Answers0