Convert data to image and then image to numpy.ndarray
Is it possible to convert a data set stored as a numpy.ndarray > plot the data with a colormap , possibly cm.jet. > and then store the image pixels to a numpy.ndarray. The data array of the image should have the same shape of the data array used to make the array. The image conversion is only used for getting a visual representation of the data, and normalise it using the cm.jet. So I actually just interested in the RGB values of the colormap normalised input data. IS this possible?
Hi Carlton On Wed, Apr 26, 2017, at 20:14, Carlton Banks wrote:
Is it possible to convert a data set stored as a numpy.ndarray > plot the data with a colormap , possibly cm.jet. > and then store the image pixels to a numpy.ndarray.
I hope you're not using jet ;) But here's an example: In [8]: from matplotlib.cm import viridis In [9]: import numpy as np In [10]: image = np.random.random((10, 10)) In [11]: image_mapped = viridis(image) In [12]: image_mapped.min(), image_mapped.max(), image_mapped.shape Out[12]: (0.031496999999999997, 1.0, (10, 10, 4)) Best regards StÃ©fan
participants (2)

Carlton Banks

Stefan van der Walt