[Tutor] New to python: some advises for image processing tool

Eike Welk eike.welk at gmx.net
Tue Oct 13 13:39:50 CEST 2009


On Monday 12 October 2009, Nicola De Quattro wrote:
> I've started to write something about input image loading and
> rotation. My goal is that, from graphical interface, the user will
> be able to rotate an image at steps (perhaps using two buttons) or
> by entering the amount of degree the image has to be rotated. I've
> writed the following "main" that will call some functions for
> rotating, saving, etc.

I think you shouldn't write text based menus either. You should just 
write a library of Python functions. To use your software you call 
these functions from the Python prompt. IPython, an extension for the 
standard Python interpreter, is good for it. You then work with 
Python similar to Matlab.
http://ipython.scipy.org/moin/

Only when the functions work, then you start to write more simple user 
interfaces. Your mail illustrates my point: You currently think about 
user interface stuff and not about the real problem, analyzing 
spectra of stars. 
 
A session with your software would then look like this:
~> ipython
In [1]: from analyze_spectra import *
In [2]: im1 = load_image("astro/spectra/13-10-2009/im1.fits")
In [3]: display_image(im1)
In [4]: im1rot = rotate_image(im1, 20, degrees=True)
....
And so on. 

This is much more flexible than Graphical or menu driven user 
interfaces, and it is much more comfortable for software development. 
You can write test scripts, instead of clicking around in your 
unfinished user interface. The added flexibility lets you do odd 
tasks, that a GUI can't do. And you get automation if you have many 
similar images for free.

If you have Windows users, they can install Python XY. This is a 
Package that contains a Python interpreter and many libraries for 
scientists. It contains the libraries that I have recommended, but 
unfortunately not Pyfits. It also contains Eclipse as a development 
environment. (I think it is even better than any repository for Suse 
Linux.) 
http://www.pythonxy.com/foreword.php


Kind regards,
Eike.


More information about the Tutor mailing list