display an rgb matrix image in python

I have an rgb matrix something like this:


i want to display an image which contains the above matrix.

I used this function to display a gray-scale image:

def displayImage(image):
    im1 = Image.fromarray(displayList)

argument(image)has the matrix

anybody help me how to display the rgb matrix


imshow in the matplotlib library will do the job

what's critical is that your NumPy array has the correct shape:

height x width x 3

(or height x width x 4 for RGBA)

>>> import os
>>> # fetching a random png image from my home directory, which has size 258 x 384
>>> img_file = os.path.expanduser("test-1.png")

>>> from scipy import misc
>>> # read this image in as a NumPy array, using imread from scipy.misc
>>> M = misc.imread(img_file)

>>> M.shape       # imread imports as RGBA, so the last dimension is the alpha channel
    array([258, 384, 4])

>>> # now display the image from the raw NumPy array:
>>> from matplotlib import pyplot as PLT

>>> PLT.imshow(M)
>>> PLT.show()

Matplotlib's built in function imshow will let you do this.

import matplotlib.pyplot as plt
def displayImage(image):

Need Your Help

IE9 raphael animation issue

javascript animation internet-explorer-9 raphael doctype

I have problem with display of correct javascript in IE9. Other browsers (Firefox, Opera, Chrome, Safari) work well, but animation in IE is not fluent. For example see this line which can be dragge...

Google App Engine ImportError

python google-app-engine web-applications python-2.7

I've come to run my app in development locally this morning, in the Google App Engine Launcher for Windows. Up until yesterday this has been working fine, and the code hasn't been changed since th...