Hi. Unfortunately I think that this transformation can not be done with Image.convert: you can only do transformations between equivalent color spaces (i.e. reach the destination colorspace by doing a multiplication with a matrix with the source colorspace).
The HSI colorspace, instead, is not an equivalent colorspace of RGB. To get the HSI equivalent of a RGB pixel one must do these transformations: I = 1/3 * (R+G+B) S = 1 - (3/(R+G+B))*(min(R,G,B)) H = cos^-1 ( (((R-G)+(R-B))/2)/ (sqrt((R-G)^2 + (R-B)*(G-B) ))) Some references: 1: http://www.cs.rit.edu/~ncs/color/t_convert.html 2: http://answers.google.com/answers/threadview?id=68502 There is a lot of efficient ways to do these transformations and also efficient algorithms in C/C++ . But to do it in python pil i would have to do a pixel by pixel operation with Image.getpixel and Image.putpixel, with every image pixel, what seemed a very slow way to do. I already thought in making an extension to PIL to do this colorspace transformation, but only asking to be sure there is not one already. Vinicius On Wed, 9 Mar 2005 17:50:25 +0100 (CET), [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Hi all > > > > Can you help me in a doubt? Is there some efficient way to do a > > conversion between an image in the RGB format in an image and the HSI > > format (aka, HLS or HSV), in python (PIL or others)? > > yes, PIL gives that. > > look at the page > > http://www.pythonware.com/library/pil/handbook/image.htm > > in particular at the <convert> method of image Object in PIL.Image module. > Enjoy. > > P.S. In general I have found in PIL an efficient and complete image > processing library to be use from Python. > > Giovanni Angeli. > <[EMAIL PROTECTED]> > > -- .----------------------. | Vinicius Cubas Brand | | viniciuscb gmail.com | '----------------------' "A human being is part of a whole, called by us the Universe, a part limited in time and space. He experiences himself, his thoughts and feelings, as something separated from the rest--a kind of optical delusion of his consciousness. This delusion is a kind of prison for us, restricting us to our personal desires and to affection for a few persons nearest us. Our task must be to free ourselves from this prison by widening our circles of compassion to embrace all living creatures and the whole of nature in its beauty." - Albert Einstein _______________________________________________ Image-SIG maillist - [email protected] http://mail.python.org/mailman/listinfo/image-sig
