On Thu, Nov 6, 2008 at 9:00 AM, Nils Wagner <[EMAIL PROTECTED]> wrote: > Hi all, > > Is it possible to combine jpegs with matplotlib or PIL ? > > Any pointer would be appreciated.
if you have PIL installed, you can load them into mpl with imread, and then set the alpha channel to make one partially transparent, and then overlay them as in the layer images example http://matplotlib.sourceforge.net/examples/pylab_examples/layer_images.html Below is some example code that loads a jog into RGB data, and then embeds it in RGBA with an alpha mask of 0.5. Note however, that mpl is not a general image processing library, so you will probably have better luck with PIL. I'm no PIL expert, so can't help there... In [8]: from matplotlib.image import imread In [9]: im = imread('lena.jpg') In [10]: im.shape Out[10]: (512, 512, 3) In [12]: import numpy as np In [13]: rgba = np.zeros((512,512,4)) In [14]: im.dtype Out[14]: dtype('uint8') In [15]: im = im.astype(float)/255. In [17]: rgba[:,:,:3] = im In [18]: rgba[:,:,-1] = 0.5 ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users