<br>You could convert the image to a netpbm format, like ppm, pgm or pbm. If the image has few colors, that should be quite viable. Each of these formats are easy to work with in Python. ppm is for color, pgm is for grayscale, pbm is for strictly black and white, pnm pertains to any of the 3. There are all sorts of filters for converting between these formats and many others in netpbm, and image processing.<br>
<br>You might be able to use pnmcut (to select just the part of the image you need - I'm guessing your math will be simpler if you crop off the axes and everything outside them), ppmdist (to convert color (with a low number of colors) to grayscale) or ppmtopgm (for high color images), and pgmedge (for edge detection), etc. Then you might pnmnoraw to get an ASCII pbm instead of a binary one - ASCII netpbm files are even simpler than binary onesto work with.<br>
<br>Here's an example of generating a ppm file in Python 2. It looks like this after conversion to png format:<br><a href="http://stromberg.dnsalias.org/~dstromberg/software/circle.png">http://stromberg.dnsalias.org/~dstromberg/software/circle.png</a><br>
If you set a bunch of them next to each other (say, by tiling it as a wallpaper), it gives a slightly eerie 3D effect. It's an application of the inverse square law. I know, it's kind of the opposite of what you need, but it may still illustrate the approach:<br>
<br>#!/usr/bin/python<br><br># writes a ppm file for a sort of sphere on stdout.<br><br>import math<br>import sys<br><br>def pad(n):<br> s = str(n)<br> while len(s) < 4:<br> s = s + ' '<br>
return s<br><br>size=200<br>colors=256<br>print 'P3'<br>print size,size<br>print colors-1<br>half=float(size/2)<br>sqrt2 = math.sqrt(2)<br>for i in range(0,size):<br> for j in range(0,size):<br> x = float(i - half) / half<br>
y = float(j - half) / half<br> z = math.sqrt(x*x + y*y)/sqrt2<br> col = int(z * (colors-1))<br> #sys.stderr.write(str(x)+' '+str(y)+' '+str(col)+'\n')<br>
ch = chr(col)<br> sys.stdout.write(pad(col)+pad(col)+pad(col)+' ')<br> print<br><br>BTW, I don't do string concatenation this much anymore, and xrange is good in 2.x. :)<br>
<br><div class="gmail_quote">On Fri, May 13, 2011 at 3:19 AM, Bastian Ballmann <span dir="ltr"><<a href="mailto:balle@chaostal.de">balle@chaostal.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi python lovers out there,<br>
<br>
I am searching for a library to parse data from a graph in an image file<br>
something like <a href="http://pytseries.sourceforge.net/_images/yahoo.png" target="_blank">http://pytseries.sourceforge.net/_images/yahoo.png</a><br>
Any suggestions, hints, links?<br>
<br>
TIA && have a nice day! :)<br>
<br>
Basti<br>
<br>--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
<br></blockquote></div><br>