Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers)
Cast the image to np.uint8
after scaling [0, 255]
range will dismiss this warning. It seems like a feature in matplotlib
, as discussed in this issue.
plt.imshow((out * 255).astype(np.uint8))
Instead of plt.imshow(out)
, use plt.imshow(out.astype('uint8'))
. That's it!
If you want to show it, you can use img/255
.
Or
np.array(img,np.int32)
The reason is that if the color intensity is a float, then matplotlib expects it to range from 0 to 1. If an int, then it expects 0 to 255. So you can either force all the numbers to int or scale them all by 1/255.