471,616 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,616 software developers and data experts.

python image digitizing

i am a newbie to python..and trying to use it to get data in a jpeg image

i can do this in java like
Expand|Select|Wrap|Line Numbers
  1.     FileInputStream fIn = new FileInputStream(filename);
  2.    JPEGImageDecoder jpeg_decode= JPEGCodec.createJPEGDecoder(fIn);
  3. BufferedImage image = jpeg_decode.decodeAsBufferedImage();
  5.             width = image.getWidth();
  6.             height = image.getHeight();
  8.             int[] rgbdata = new int[width * height];
  10.             image.getRGB(0,0,width,height,rgbdata,0,width);
  13.             bytes = new byte[rgbdata.length];
  14.             doubles = new double[rgbdata.length];
  15.             int i;
  16.             for ( i = 0; i < bytes.length; i++) {
  17.               bytes[i]    = (byte)  (rgbdata[i] & 0xFF);
  18.               doubles[i]  = (double)(rgbdata[i]);
  19.             }
  21.             fIn.close();
  22.         }
but how do i do that in python?i wish to get the image data as byte[] and double[]

can anyone suggest a way
Oct 7 '07 #1
2 2615
126 100+
I have no idea what the [EDIT: expalative delete] you are talking about.

But i guess that PIL (Python Imaging Library) is a good place to start.
Oct 7 '07 #2
well, i was trying to get the rgb pixels as a from a jpeg image ,i can do this in java using the above code..but i am new to python &PIL ,so i was wondering if anybody knows how to do that ..it seems like a common enuf task

Oct 8 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

16 posts views Thread by Jason | last post: by
3 posts views Thread by fdsl ysnh | last post: by
reply views Thread by Xah Lee | last post: by
9 posts views Thread by corey.coughlin | last post: by
reply views Thread by Kurt B. Kaiser | last post: by
10 posts views Thread by Ohmster | last post: by
reply views Thread by james.duckworthy | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.