Quantcast

BUG: convert to greyscale errors

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

BUG: convert to greyscale errors

David Austin
Hi all,

I've found an incorrect dependency upon neighbouring pixels in conversion to
greyscale.  Running this simple script (against attached images):

import Image
im1 = Image.open('a.png')
im2 = Image.open('b.png')
pt = (301, 72)
print "Before", im1.getpixel(pt), im2.getpixel(pt)
im1 = im1.convert("P")
im2 = im2.convert("P")
print "After", im1.getpixel(pt), im2.getpixel(pt)

Gives:

Before (63, 73, 50) (63, 73, 50)
After 60 59

i.e. before conversion the RGB values are identical, after the greyscale
values are not.

Regards,
David

_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig

a.png (264K) Download Attachment
b.png (264K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: BUG: convert to greyscale errors

Oliver Tonnhofer-4
Hi,

On 21.03.2012, at 01:33, David Austin wrote:

> I've found an incorrect dependency upon neighbouring pixels in conversion to
> greyscale.  Running this simple script (against attached images):
>
> import Image
> im1 = Image.open('a.png')
> im2 = Image.open('b.png')
> pt = (301, 72)
> print "Before", im1.getpixel(pt), im2.getpixel(pt)
> im1 = im1.convert("P")
> im2 = im2.convert("P")

This will convert the image to a paletted image.

> Before (63, 73, 50) (63, 73, 50)
> After 60 59

And this is not the gray-value but an index to the color palette. This palette will look different if the images differ.

_______________________________________________
Image-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/image-sig
Loading...