Combine jpegs

Hi all,

Is it possible to combine jpegs with matplotlib or PIL ?

Any pointer would be appreciated.

   Nils

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

···

On Thu, Nov 6, 2008 at 9:00 AM, Nils Wagner <nwagner@...1052...> wrote:

Hi all,

Is it possible to combine jpegs with matplotlib or PIL ?

Any pointer would be appreciated.