Scale imread matrix in python
Question: I am looking for a way to rescale the matrix given by reading in a png file
using the matplotlib routine imread, e.g.

    
    
    from pylab import imread, imshow, gray, mean
    from matplotlib.pyplot import show
    a = imread('spiral.png')
    #generates a RGB image, so do
    show()
    

but actually I want to manually specify the dimension of $a$, say 200x200
entries, so I need some magic command (which I assume exists but cannot be
found by myself) to interpolate the matrix.

Thanks for any useful comments : )

Cheers


Answer: You could try using the PIL (Image) module instead, together with numpy. Open
and resize the image using Image then convert to array using numpy. Then
display the image using pylab.

    
    
    import pylab as pl
    import numpy as np
    import Image
    
    path = r'\path\to\image\file.jpg'
    
    img = Image.open(path)
    
    img.resize((200,200))
    
    a = np.asarray(img)
    
    pl.imshow(a)
    pl.show()
    

Hope this helps. :)

