Re: [Matplotlib-users] imshow, imsave to PIL image conversion

2010-06-02 Thread rugspin
Thanks Jae-Joon and Friedrich I will try out both solutions. Regards Hans Jae-Joon Lee wrote: > > On Tue, Jun 1, 2010 at 2:22 PM, rugspin wrote: >> That's doing it, thought there might be an internal way within >> matplotlib, >> but I could figure one. > > If you need more hard-core way of

Re: [Matplotlib-users] imshow, imsave to PIL image conversion

2010-06-01 Thread Jae-Joon Lee
On Tue, Jun 1, 2010 at 2:22 PM, rugspin wrote: > That's doing it, thought there might be an internal way within matplotlib, > but I could figure one. If you need more hard-core way of doing this, a = np.arange(16384).reshape(128, 128) from matplotlib.colors import Normalize import matplotlib.cm

Re: [Matplotlib-users] imshow, imsave to PIL image conversion

2010-06-01 Thread Friedrich Romstedt
> That's doing it, thought there might be an internal way within matplotlib, > but I could figure one. I think you can use the agg backend and the corresponding Canvas'es method canvas.tostring_rgb() . Then you can load this in PIL by Image.fromstring. Well, I simply send you my PIL backend.

Re: [Matplotlib-users] imshow, imsave to PIL image conversion

2010-06-01 Thread rugspin
Thanks Jae-Joo That's doing it, thought there might be an internal way within matplotlib, but I could figure one. I'm quite confused with the canvas, dpi, ... Regards Hans Jae-Joon Lee wrote: > > You may use StringIO. > > from scipy import * > from pylab import * > from PIL import Image >

Re: [Matplotlib-users] imshow, imsave to PIL image conversion

2010-06-01 Thread Jae-Joon Lee
You may use StringIO. from scipy import * from pylab import * from PIL import Image import cStringIO a = arange(16384).reshape(128,128) f = cStringIO.StringIO() imsave(f, a, cmap=cm.summer,vmin=0,vmax=16383, format="png") # you'd better set the format explicitly. f.reset() b = Image.open(f) f.

Re: [Matplotlib-users] imshow, imsave to PIL image conversion

2010-06-01 Thread rugspin
Angus McMorland-2 wrote: > > On 31 May 2010 23:17, Angus McMorland wrote: > >> On 31 May 2010 19:49, rugspin wrote: >> >>> >>> I have a small problem how to convert an image from matplotlib to PIL >>> >>> right now doing somthing like this: >>> -- >>>

Re: [Matplotlib-users] imshow, imsave to PIL image conversion

2010-05-31 Thread Angus McMorland
On 31 May 2010 23:17, Angus McMorland wrote: > On 31 May 2010 19:49, rugspin wrote: > >> >> I have a small problem how to convert an image from matplotlib to PIL >> >> right now doing somthing like this: >> -- >> from scipy import * >> from pylab import *

Re: [Matplotlib-users] imshow, imsave to PIL image conversion

2010-05-31 Thread Angus McMorland
On 31 May 2010 19:49, rugspin wrote: > > I have a small problem how to convert an image from matplotlib to PIL > > right now doing somthing like this: > -- > from scipy import * > from pylab import * > from PIL import Image > > a = arange(16384).reshape(128

[Matplotlib-users] imshow, imsave to PIL image conversion

2010-05-31 Thread rugspin
I have a small problem how to convert an image from matplotlib to PIL right now doing somthing like this: -- from scipy import * from pylab import * from PIL import Image a = arange(16384).reshape(128,128) imsave( "test.png", a, cmap=cm.summer,vmin=0,vmax=