[Image-SIG] RGB conversion to CMKY gives strange results

Ray Pasco pascor at hotpop.com
Fri Mar 11 00:46:39 CET 2005


Jeff -

Thanks for the tips.  The documentation specifically says that 
im.point() can only be used to
convert  mode L and P images to mode 1 images, and that the mode string 
must be specified
as the second parameter.  If not so, the present handbook is very wrong 
and misleading.

Is the proper documentation for im.point() available anywhere ?

The doc for im.convert is obviously wrong, too !  It says that the 
coefficient matrix
must be either a 4-tuple or a 16-tuple, yet its own example uses a 
12-tuple !

Egads !  What is going on ?

Ray


Jeff Epler wrote:

>(Please copy the list with these posts.  Maybe others will benefit from
>this discussion someday)
>
>Here's some code that inverts the red channel of an RGB image using
>im.point:
>    import Image
>
>    inverter = [255-i for i in range(256)]
>    unchanged = range(256)
>    i = Image.open("input.jpg")
>    j = i.point(inverter + unchanged + unchanged)
>    j.save("output.jpg")
>In this usage, i.point takes a 768-entry list of integers.  The first
>256 entries are used to map red values, the second 256 entries to map
>green values, and the last 256 entries to map blue values.  You could
>change brightness and contrast across all channels by using a ramp
>functnction of your choice.  Something like [untested]
>    contrast = 1.1  # Increase contrast to 110% of original
>    brightness = 16 # Increase brightness by 16/255 ~= 6.25%
>    c = [int(min(255, max(0, i * contrast + brightness))) for i in range(255)]
>    ...
>    j = i.point(c+c+c)
>
>I didn't immediately get the 'im.convert' to XYZ colorspace to work as
>documented.
>
>Jeff
>  
>




More information about the Image-SIG mailing list