Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers)

I tried to run the graph cut algorithm for a slice of an MRI after converting it into PNG format. I keep encountering the following problem:

Clipping input data to the valid range for imshow with RGB data ([0..1] for floats or [0..255] for integers). 

This is even after setting vmin and vmax as follows:

plt.imshow(out, vmin=0, vmax=255) 
like image 480
Ankita Shinde Avatar asked Apr 04 '18 06:04

Ankita Shinde


People also ask

How do I change my color on Imshow?

The most direct way is to just render your array to RGB using the colormap, and then change the pixels you want.

What is PLT Imshow ()?

imshow. The matplotlib function imshow() creates an image from a 2-dimensional numpy array. The image will have one square for each element of the array. The color of each square is determined by the value of the corresponding array element and the color map used by imshow() .

What is Imshow return?

As you have already found out, the return type of plt. imshow() is a matplotlib. image. AxesImage .


1 Answers

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)) 
like image 72
Dat Avatar answered Sep 19 '22 20:09

Dat