packing greyscale values
jimgardener
jimgardener at gmail.com
Mon Feb 11 09:45:27 EST 2008
>>Are you sure the lists you give belong to the same image?
the greyvalues list was printed out by python script on a 3X4
sampleimage i made to check this
im=Image.open("mypicgrey.jpg")
pixels=im.getdata()
for pix in pixels:
print pix
whereas the integers in the second list were from java code
FileInputStream fIn = new FileInputStream("mypicgrey.jpg");
JPEGImageDecoder jpeg_decode = JPEGCodec.createJPEGDecoder(fIn);
BufferedImage image = jpeg_decode.decodeAsBufferedImage();
int width = image.getWidth();
int height = image.getHeight();
int[] rgbdata = new int[width * height];
image.getRGB(0,0,width,height,rgbdata,0,width);
'rgbdata' now has the second list of integer values
if it was an rgb image with r,g,b values i could pack it as
return unpack("l", pack("BBBB", b, g, r, alpha))[0]
(where alpha=255)
but i don't know how to do this for a greyscale image
jim
More information about the Python-list
mailing list