I have a small code sample to plot images in matplotlib, and the image is shown as this :
Notice the image in the black box has black background, while my desired output is this :
My code to plot the image is this :
plt.subplot(111)
plt.imshow(np.abs(img), cmap = 'gray')
plt.title('Level 0'), plt.xticks([]), plt.yticks([])
plt.show()
My understanding is that cmap=grey
should display it in grayscale. Below is a snippet of the matrix img
being plotted :
[[ 192.77504036 +1.21392817e-11j 151.92357434 +1.21278246e-11j
140.67585733 +6.71014111e-12j 167.76903747 +2.92050743e-12j
147.59664180 +2.33718944e-12j 98.27986577 +3.56896094e-12j
96.16252035 +5.31530804e-12j 112.39194666 +5.86689097e-12j....
What am I missing here ?