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

Nicola De Quattro lead.expression at gmail.com
Mon Oct 12 21:55:04 CEST 2009

Hi all
I'm starting with my project (rather slowly...) and I want to give you a 
little update (and do some trivial questions).

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.


def tipsy_imp
	"Tests of Tipsy Imp input management"
	import Image, os, sys
	print """
	Tipsy Imp - Alpha version 0.0.1
	by Nicola De Quattro
	var = 0
	while(var !=q0)
		print """
		Please select an action from the menu below:
		o) Open an image
		+) Rotate the image of 1° clockwise
		-) Rotate the image of -1° clockwise
		r) Rotate the image of an input degree
		s) Show the image
		a) Save the image
		q) Quit Tipsy Imp
		var = raw_input("Make a choice: ");


I've some questions:
1) Is there a switch-case statement in Python? It seems to me not. How 
do you suggest to proceed in order to switch into var values?
2) If I want this script to automatically load a image that I give him 
as argument, I obtain filename by simply using the instruction:

import sys
input= sys.argv[1:]

So under Linux I type, from commandline

$ python main.py <filename>

It can be the same under Windows?

Thank you for your advices.


Nicola De Quattro ha scritto:
> Hi,
> I'm a 26 years old Italian engineer. Because to the fact that I'm an
> astrophile and astronomical tool (expecially under Linux) are not so
> common, I would like to develop some simple tool for some purposes.
> Well, I'm not knew to software development but I've never used python.
> So I want to list you my needed for the first tool, so you can tell me
> if Python could be a good choice and how to begin the develop.
> First of all, I need a software running both under Windows and Linux
> at least (it would be better if running either under MacOS). This is a
> first reason to choose Python.
> Secondly, I want a OpenSource tool
> The software shall be a tool for Star Analyzer (spectroscopic
> analyzer) images. A similar software already exists, it can be seen at
> this link (I'm sorry, it is in Italian, but you can understand from
> the images what is the input and the output)
> http://www.astropix.it/software/astrospectrum.html
> So I've to open an image (various formats, first I could need only
> .fits), to process the image in order to select the interesting strip
> containing the star and the spectrum (first image of the link posted,
> but I hope I can select the strip not only in the horizontal line but
> I will rotate the image), to obtain a graph like the second and third
> image (this may be simple, it plots the value of luminosity of each
> point), calibrate the image using periodical table of elements as
> shown in 6th image in order to color the graph.
> Well, I know that many people doesn't understand the problem :) I hope
> you can be able, with the elements reported above, how I have to
> proceed, remembering that I've no problem programming in Matlab and C
> but I've never worked with graphical interfaces and with image
> processing (only under Matlab).
> I've learned most of python commands. I think I've to start with some library?
> Thank you very much and sorry for the poem (and for my english)!
> PS: If the question is "Why don't you use Astrospectrum?" the answer
> is: it is only for Linux and is not opensource :(

More information about the Tutor mailing list