Fast imshow plotting

I am creating a script that generates images and displays them to the screen in real time. I created the following simple script:

···

#!/usr/bin/env python

from pylab import *
from scipy import *

for k in range(1,10000):
img = standard_normal((40,40))
imshow(img,interpolation=None,animated=True,label=“blah”)
clf()
show()


Now, this script plots the image too slowly. I am forced to use the clf() function so that it doesn’t slow down at each iteration of the for loop. Is there a way that I can plot this simple image faster? What’s the best way to get imshow() to plot quickly? Thanks for your help.

-Joey

Not sure if this will help, but maybe you can do something like this?

···

---
#!/usr/bin/env python

from pylab import *
from scipy import *

img = standard_normal((40,40))
image = imshow(img,interpolation='nearest',animated=True,label="blah")

for k in range(1,10000):
     img = standard_normal((40,40))
     image.set_data(img)
     show()
---

Note, interpolation='nearest' can be faster than interpolation=None if your default interpolation is set to bicubic (which it probably is)

Does this speed things up?

Thomas

On May 1, 2009, at 3:31 PM, Joey Wilson wrote:

I am creating a script that generates images and displays them to the screen in real time. I created the following simple script:

__________________________

#!/usr/bin/env python

from pylab import *
from scipy import *

for k in range(1,10000):
    img = standard_normal((40,40))
    imshow(img,interpolation=None,animated=True,label="blah")
    clf()
    show()

__________________________

Now, this script plots the image too slowly. I am forced to use the clf() function so that it doesn't slow down at each iteration of the for loop. Is there a way that I can plot this simple image faster? What's the best way to get imshow() to plot quickly? Thanks for your help.

-Joey

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Thomas Robitaille wrote:

Not sure if this will help, but maybe you can do something like this?

---
#!/usr/bin/env python

from pylab import *
from scipy import *

To run this as a standalone script, without ipython -pylab, you need to include:

ion()

img = standard_normal((40,40))
image = imshow(img,interpolation='nearest',animated=True,label="blah")

for k in range(1,10000):
     img = standard_normal((40,40))
     image.set_data(img)
     show()

show() should never be called more than once for a given figure; what you want here is draw().

Eric

···

---

Note, interpolation='nearest' can be faster than interpolation=None if your default interpolation is set to bicubic (which it probably is)

Does this speed things up?

Thomas

On May 1, 2009, at 3:31 PM, Joey Wilson wrote:

I am creating a script that generates images and displays them to the screen in real time. I created the following simple script:

__________________________

#!/usr/bin/env python

from pylab import *
from scipy import *

for k in range(1,10000):
    img = standard_normal((40,40))
    imshow(img,interpolation=None,animated=True,label="blah")
    clf()
    show()

__________________________

Now, this script plots the image too slowly. I am forced to use the clf() function so that it doesn't slow down at each iteration of the for loop. Is there a way that I can plot this simple image faster? What's the best way to get imshow() to plot quickly? Thanks for your help.

-Joey

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations Conference from O'Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance & Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Eric and Thomas,

Thanks for your help. I was able to get it plotting MUCH faster. Here’s my code:

#!/usr/bin/env python

from pylab import *
from scipy import *

ion()
img = standard_normal((50,100))
image = imshow(img,interpolation=‘nearest’,animated=True,label=“blah”)

for k in range(1,100):
img = standard_normal((100,100))
image.set_data(img)
draw()

Thanks again.
-Joey

···

On Sat, May 2, 2009 at 1:27 PM, Eric Firing <efiring@…202…> wrote:

Thomas Robitaille wrote:

Not sure if this will help, but maybe you can do something like this?


#!/usr/bin/env python

from pylab import *

from scipy import *

To run this as a standalone script, without ipython -pylab, you need to include:

ion()

img = standard_normal((40,40))

image = imshow(img,interpolation=‘nearest’,animated=True,label=“blah”)

for k in range(1,10000):

 img = standard_normal((40,40))

 image.set_data(img)

 show()

show() should never be called more than once for a given figure; what you want here is draw().

Eric


Note, interpolation=‘nearest’ can be faster than interpolation=None if your default interpolation is set to bicubic (which it probably is)

Does this speed things up?

Thomas

On May 1, 2009, at 3:31 PM, Joey Wilson wrote:

I am creating a script that generates images and displays them to the screen in real time. I created the following simple script:


#!/usr/bin/env python

from pylab import *

from scipy import *

for k in range(1,10000):

img = standard_normal((40,40))

imshow(img,interpolation=None,animated=True,label="blah")

clf()

show()

Now, this script plots the image too slowly. I am forced to use the clf() function so that it doesn’t slow down at each iteration of the for loop. Is there a way that I can plot this simple image faster? What’s the best way to get imshow() to plot quickly? Thanks for your help.

-Joey


Register Now & Save for Velocity, the Web Performance & Operations

Conference from O’Reilly Media. Velocity features a full day of

expert-led, hands-on workshops and two days of sessions from industry

leaders in dedicated Performance & Operations tracks. Use code vel09scf

and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf_______________________________________________

Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Register Now & Save for Velocity, the Web Performance & Operations Conference from O’Reilly Media. Velocity features a full day of expert-led, hands-on workshops and two days of sessions from industry leaders in dedicated Performance & Operations tracks. Use code vel09scf and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users