Want to convert images into HSL format

F. GEIGER fgeiger at datec.at
Tue Mar 19 02:21:23 EST 2002


The Sandard Lib - the undiscovered land... ;-). Works fine, thanks a lot for
the hint!

Best regards
Franz GEIGER


"Fredrik Lundh" <fredrik at pythonware.com> schrieb im Newsbeitrag
news:uzol8.25972$n4.5086912 at newsc.telia.net...
> "F. GEIGER" wrote:
>
> > PIL can supply me with RGB data of an image. Does anybody know, how I
can
> > PIL have to transform this into the HSL (aka HSI) model?
> >
> > I'm new to image processing, but if I understand the chapter Introducint
> > PIL -> Concepts -> Mode right, HSL is not mentioned there. Well, I have
to
> > admit, the only two color modes of the mentioned ones I understand are
RGB
> > and CMYK.
>
> PIL doesn't support HLS images.
>
> if you only need HLS values for individual pixels, you can use
> the colorsys module in Python's standard library:
>
> >>> import Image
> >>> im = Image.open("lenna.im")
> >>> im.mode
> 'RGB'
> >>> im.getpixel((0, 0))
> (226, 161, 119)
> >>> import colorsys
> >>> colorsys.rgb_to_hls(*[x/255.0 for x in im.getpixel((0, 0))])
> (0.065420560747663545, 0.67647058823529416, 0.64848484848484833)
>
> see the library reference for details.
>
> </F>
>
>





More information about the Python-list mailing list