varsha_holla
varsha_holla

Reputation: 862

how to convert ndarray to image and display it using python

I have converted set of images to ndarray and stored it, now i have to convert them back to images without saving it to disk. I tried with " toimage() " function, but it is displaying only 1 image.

toimage(resizedlist.values()[0]).show()

resizedlist.values contains the ndarray of 49 images. Is there any way to display images randomly??

Thanks in advance!

Upvotes: 5

Views: 14199

Answers (1)

ebarr
ebarr

Reputation: 7842

To plot an ndarray as an image you can use matplotlib:

import numpy as np
import matplotlib.pyplot as plt

random = np.random.normal(0,1,size=[100,100])
plt.imshow(random,aspect="auto")
plt.show()

If your image data is stored RGBA, imshow will plot the image with the correct colours etc.

For reference, all this information can be found here:

http://matplotlib.org/1.3.1/users/image_tutorial.html

Upvotes: 12

Related Questions