[scikit-image] Convert data to image and then image to numpy.ndarray

Stefan van der Walt stefanv at berkeley.edu
Thu Apr 27 15:38:15 EDT 2017


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


More information about the scikit-image mailing list