On Feb 11, 9:11 pm, Peter Otten <[EMAIL PROTECTED]> wrote: > jimgardener wrote: > > hi > > i am getting value of a pixel of a greyscale image using PIL's > > image.getdata and need to pack it as an int as below > > > ie greyvalues > > 127 , 56 , 135 , 99 , 102 , 101 , 146 , 112 , 155 , 154 , 112 , 169 > > > should become > > -4473925, -8289919, -4144960, -5789785, -5592406, -5658199 ,-3684409, > > -5131855, -3289651,-3355444, -5131855, -2763307 > > > (i got these values using java's BufferedImage class..)I would like to > > know if there is a way to do the conversion in python.(.i need 'these > > 'for some calculations) > > Judging from > > >>> hex(0x100000000 - 4473925) > '0xffbbbbbb' > >>> 0xbb > > 187 > > -4273925 indeed seems to denote a gray value, but the lighter 187 rather > than 127. Are you sure the lists you give belong to the same image? > > Peter
Let Y = Java-derived numbers (187, etc) and X = PIL-derived numbers (127, etc) Y approx = 0.75 * X + 90 What the underlying cause of this relationship is, I have not a clue. Cheers, John -- http://mail.python.org/mailman/listinfo/python-list