Quantcast
Channel: How to convert a NumPy array to PIL image applying matplotlib colormap - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Shital Shah for How to convert a NumPy array to PIL image applying matplotlib colormap

$
0
0

The method described in the accepted answer didn't work for me even after applying changes mentioned in its comments. But the below simple code worked:

import matplotlib.pyplot as pltplt.imsave(filename, np_array, cmap='Greys')

np_array could be either a 2D array with values from 0..1 floats o2 0..255 uint8, and in that case it needs cmap. For 3D arrays, cmap will be ignored.


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>