So i noticed for me and a few of my colleagues that when we display a binary array using matplotlib.pyplot's imshow function the edges of the displayed image seems altered. For a while i thought it was just a visual artifact, but ran into further trouble with it today.
By the way i am running with matplotlib: 3.2.2 and numpy: 1.19.1
If i create a small binary array and plot it it you can see a small "halo" to the binary box in the image. It is not very obvious but it is there:
import matplotlib.pyplot as plt
import numpy as np
img=np.zeros((100,100))
img[25:60,25:60]=50
plt.imshow(img)
It will become more apparent if i change the cmap for the plot.
my_cmap = plt.cm.get_cmap('prism')
my_cmap.set_under('black')
plt.imshow(img,cmap=my_cmap, vmin=1)
The displayed array should only have 0's as background and 1's in the box, but the box is displayed as a green box with a red/yellow border.
With previous versions of pyplot i have not had this issue and it does become a problem when i do object detection and i want to display them and my other wise binary objects end up like this:
I hope you can help me with this




