Re: [Matplotlib-users] display each images from a directory

2010-11-29 Thread Benjamin Root
On Mon, Nov 29, 2010 at 1:48 PM, Massimo Di Stefano <
massimodisa...@gmail.com> wrote:

> Hello All,
>
> i'm tring to write python code to display images from a directory .. but
> i'm not able to learn how to use the matplotlib events
> to handle how the images will be displaied.
>
> simpli i need to pass to the code the path to directory where i have
> several tiff files and disply them one at time using a key event.
>
> to display a single image i'm using somethin like :
>
>
>
> #!/usr/bin/env python
> from pylab import *
> try:
>import Image
> except ImportError, exc:
>raise SystemExit("PIL must be installed to run this example")
> import glob
>
> def dispimg(input):
>image = Image.open(input)
>im = imshow(image, origin='lower')
>show()
>
>
>
> ###
>
> i tried to define a key action like :
>
>
> def onpress(event):
>if event.key=='a':
>fig.canvas.draw()
>
>
> # and set my directory with :
>
> fig = figure()
> fig.canvas.mpl_connect('key_press_event', onpress)
> TIFFS = glob.glob("/home/habcam/habcamdata/20100820_1840/*.tif")
> print "num TIFFS %d" % len(TIFFS)
>
> ##
>
> but i'm not able to learn how to plot them and update the displayed image
> using the key bindings :
>
> for tif in TIFFS:
>print tif
>show()
>
>
> thanks a lot for Any help!
>
>
> Massimo.
>

Massimo,

You might want to try a different approach.  Instead of having a keypress
binding, why not just have a normal for-loop with a call to dispimg() and
some sort of blocking input like a wait for keypress or something?  You
might even be able to do something with a while loop that checks for a 'q'
input (for quit) and then have two keys be used for forward and backwards
progression through your list of TIFFS.

Another thing to consider is just not use matplotlib at all, and just use
linux's image viewer (called "eog") which you can give it the first file in
a directory, and you can use the arrow keys to move through the list of all
image files in that directory.

I hope that helps,

Ben Root
--
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] display each images from a directory

2010-11-29 Thread Massimo Di Stefano
Hello All,

i'm tring to write python code to display images from a directory .. but i'm 
not able to learn how to use the matplotlib events
to handle how the images will be displaied.

simpli i need to pass to the code the path to directory where i have several 
tiff files and disply them one at time using a key event.

to display a single image i'm using somethin like :



#!/usr/bin/env python
from pylab import *
try:
import Image
except ImportError, exc:
raise SystemExit("PIL must be installed to run this example")
import glob

def dispimg(input):
image = Image.open(input)
im = imshow(image, origin='lower')
show()



###

i tried to define a key action like :


def onpress(event):
if event.key=='a':
fig.canvas.draw()


# and set my directory with :

fig = figure()
fig.canvas.mpl_connect('key_press_event', onpress)
TIFFS = glob.glob("/home/habcam/habcamdata/20100820_1840/*.tif")
print "num TIFFS %d" % len(TIFFS)

##

but i'm not able to learn how to plot them and update the displayed image using 
the key bindings :

for tif in TIFFS:
print tif
show()


thanks a lot for Any help!


Massimo.
--
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users