From coulix at gmail.com Mon Dec 1 14:30:47 2008 From: coulix at gmail.com (Gregory Tappero) Date: Mon, 1 Dec 2008 14:30:47 +0100 Subject: [Image-SIG] PIL and simple conversion Message-ID: Hi everyone, I have a png in P mode with black writting on white background I want a transparent png with black writting in white So far i did this im = Image.open("foo.png") im = im.convert("RGB") im = ImageOps.invert(im) im = im.convert("P") im.save("new2.png", transparency=0) it works well, except that i dont want to save the image i want the data to return it to my web client. So what is a equivalent of im.save("new2.png", transparency=0) which does not save the image ? Thanks Greg -- o/ From Scott.Daniels at Acm.Org Mon Dec 1 19:08:08 2008 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Mon, 01 Dec 2008 10:08:08 -0800 Subject: [Image-SIG] PIL and simple conversion In-Reply-To: References: Message-ID: Gregory Tappero wrote: > Hi everyone, ... > So far i did this: > im = Image.open("foo.png") > ... > im.save("new2.png", transparency=0) > it works well, except that i dont want to save the image i want the > data to return it to my web client. > So what is a equivalent of im.save("new2.png", transparency=0) which > does not save the image ? Almost a FAQ: import cStringIO import Image im = Image.open("xyzzy.png") ... holder = cStringIO.StringIO() im.save(holder, format="png", transparency=0) bytes_string = holder.getvalue() --Scott David Daniels Scott.Daniels at Acm.Org From fredrik at pythonware.com Thu Dec 4 18:49:21 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 4 Dec 2008 18:49:21 +0100 Subject: [Image-SIG] PIL and simple conversion In-Reply-To: References: Message-ID: <368a5cd50812040949x1d354ee4l6d7bce615fdd1080@mail.gmail.com> On Mon, Dec 1, 2008 at 7:08 PM, Scott David Daniels wrote: > Almost a FAQ: > > import cStringIO > import Image > > im = Image.open("xyzzy.png") > ... > holder = cStringIO.StringIO() > im.save(holder, format="png", transparency=0) > bytes_string = holder.getvalue() I was about to point out that it's actually mentioned in the latest version of the docs, but then I discovered that it's mentioned under "tostring" but not under "save". Looks like I have some editing to do... From TFriedrich at mednet.ucla.edu Thu Dec 4 21:29:28 2008 From: TFriedrich at mednet.ucla.edu (Friedrich, Tara) Date: Thu, 4 Dec 2008 12:29:28 -0800 Subject: [Image-SIG] error install PIL 1.1.6 Message-ID: <0C96F0BFE078D74C91A1C541D24A6AE4358A4280@EMGMB1.ad.medctr.ucla.edu> Hello, I am trying to install python image library 1.1.6 and I am having the following errors when I install the lazy way using python setup.py install: running install running build running build_py running build_ext building '_imagingtk' extension gcc -pthread -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fPIC -fPIC -I/usr/include/freetype2 -IlibImaging -I/usr/include -I/usr/local/include -I/usr/include/python2.5 -c _imagingtk.c -o build/temp.linux-x86_64-2.5/_imagingtk.o _imagingtk.c:20:16: error: tk.h: No such file or directory _imagingtk.c:23: error: expected ?)? before ?*? token _imagingtk.c:31: error: expected specifier-qualifier-list before ?Tcl_Interp? _imagingtk.c: In function ?_tkinit?: _imagingtk.c:37: error: ?Tcl_Interp? undeclared (first use in this function) _imagingtk.c:37: error: (Each undeclared identifier is reported only once _imagingtk.c:37: error: for each function it appears in.) _imagingtk.c:37: error: ?interp? undeclared (first use in this function) _imagingtk.c:45: error: expected expression before ?)? token _imagingtk.c:51: error: ?TkappObject? has no member named ?interp? _imagingtk.c:55: warning: implicit declaration of function ?TkImaging_Init? error: command 'gcc' failed with exit status 1 and the more labor intensive way: python setup.py build_ext -i: running build_ext building '_imagingtk' extension gcc -pthread -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fPIC -fPIC -I/usr/include/freetype2 -IlibImaging -I/usr/include -I/usr/local/include -I/usr/include/python2.5 -c _imagingtk.c -o build/temp.linux-x86_64-2.5/_imagingtk.o _imagingtk.c:20:16: error: tk.h: No such file or directory _imagingtk.c:23: error: expected ?)? before ?*? token _imagingtk.c:31: error: expected specifier-qualifier-list before ?Tcl_Interp? _imagingtk.c: In function ?_tkinit?: _imagingtk.c:37: error: ?Tcl_Interp? undeclared (first use in this function) _imagingtk.c:37: error: (Each undeclared identifier is reported only once _imagingtk.c:37: error: for each function it appears in.) _imagingtk.c:37: error: ?interp? undeclared (first use in this function) _imagingtk.c:45: error: expected expression before ?)? token _imagingtk.c:51: error: ?TkappObject? has no member named ?interp? _imagingtk.c:55: warning: implicit declaration of function ?TkImaging_Init? error: command 'gcc' failed with exit status 1 Any help would be greatly appreciated. Also if you could point me to any archives, that would be useful too. Tara Friedrich Geschwind Lab University of California Los Angeles IMPORTANT WARNING: This email (and any attachments) is only intended for the use of the person or entity to which it is addressed, and may contain information that is privileged and confidential. You, the recipient, are obligated to maintain it in a safe, secure and confidential manner. Unauthorized redisclosure or failure to maintain confidentiality may subject you to federal and state penalties. If you are not the intended recipient, please immediately notify us by return email, and delete this message from your computer. From mail at karsten.name Fri Dec 5 00:53:44 2008 From: mail at karsten.name (Karsten Hiddemann) Date: Fri, 05 Dec 2008 00:53:44 +0100 Subject: [Image-SIG] error install PIL 1.1.6 In-Reply-To: <0C96F0BFE078D74C91A1C541D24A6AE4358A4280@EMGMB1.ad.medctr.ucla.edu> References: <0C96F0BFE078D74C91A1C541D24A6AE4358A4280@EMGMB1.ad.medctr.ucla.edu> Message-ID: <49386D88.8000401@karsten.name> Friedrich, Tara schrieb: > _imagingtk.c:20:16: error: tk.h: No such file or directory Looks like you don't have the relevant Tk development libraries available. Cheers, Karsten From starsareblueandfaraway at gmail.com Thu Dec 4 16:24:46 2008 From: starsareblueandfaraway at gmail.com (Roy H. Han) Date: Thu, 4 Dec 2008 10:24:46 -0500 Subject: [Image-SIG] Patch Analysis In-Reply-To: References: <6a5569ec0811280955i10a637e4j7af747a2c793bcf5@mail.gmail.com> Message-ID: <6a5569ec0812040724t203c1181uce488966378a1e62@mail.gmail.com> Mandar, You can use k-means clustering to group pixels of the same class. The scipy module has a clustering function, as well as the PyCluster module. For the perimeter problem, maybe you can extract the patches as a separate image (without irrelevant pixels) and then use edge detection to get the border pixels. The PIL Image.filter and ImageFilter modules have an FIND_EDGES method. RHH On Fri, Nov 28, 2008 at 1:36 PM, Mandar Sarlashkar wrote: > Hello ! > > Thanks a lot for your reply. > > Analysis is pixel based. > For knowing the land-use mix I can use a 3x3 window operation. > But I dont know how to group pixels of same class (patch) as there will not > be just one patch but several in an image with same pixel values. > For example water - there might be many water bodies dispersed in an > image. > > Also, as you mentioned area calculation is pretty straight but If I am able > to identify patches, how to estimate the number of pixels in an outline for > estimating perimeter. > > Thank you. > > Maddy > > > ------------------------------ > Date: Fri, 28 Nov 2008 12:55:48 -0500 > From: starsareblueandfaraway at gmail.com > To: mann_sar at hotmail.com > Subject: Re: [Image-SIG] Patch Analysis > > > How are you getting your patches? > If you are doing it on a pixel by pixel basis, then you can simply count > the number of pixels in a patch to estimate the area and you can count the > number of pixels in an outline of the patch to estimate the perimeter. > > 2008/11/28 Mandar Sarlashkar > > > > Dear all, > > I am planning to use PIL in my assignment. > > One of the tasks is to calculate index such as 'Patch Density' for a > classified Land-use Land Cover Image. > > I am not getting how to handle different class patches in an image. > How can I retrieve information for each patch such as area and perimeter? > I can use FRAGSTAS for getting such indices but a python script > or guidance how it can be done using python and PIL will be more helpful. > Thanking you for your time and consideration in advance. > Regards, > Maddy > > ------------------------------ > What's on the ramp today could be on the streets tomorrow. Keep up with > trends on MSN Lifestyle Try it! > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > > > ------------------------------ > Calling TV buffs! Get TV listings, gossip on your fave stars and updates on > hot new shows Try it now! > -------------- next part -------------- An HTML attachment was scrubbed... URL: From starsareblueandfaraway at gmail.com Thu Dec 4 16:30:02 2008 From: starsareblueandfaraway at gmail.com (Roy H. Han) Date: Thu, 4 Dec 2008 10:30:02 -0500 Subject: [Image-SIG] Using GIMP filters within a Python script In-Reply-To: <200811290851.38811.frederic.mantegazza@gbiloba.org> References: <6a5569ec0811270030u64c45210gbdb7e0e90f1b79a9@mail.gmail.com> <200811290851.38811.frederic.mantegazza@gbiloba.org> Message-ID: <6a5569ec0812040730w59f39cd8x1219ad4b8439f4eb@mail.gmail.com> Hi Matthew, Joao, Fr?d?ric, Thanks for writing back with your helpful responses. I'll look into the more complicated filters later, but for now I will use PIL's ImageFilter.FIND_EDGES and make some basic haar filters too. I might consider using the GEGL library if it turns out to be better than PIL's Image.filter() method. RHH On Sat, Nov 29, 2008 at 2:51 AM, Fr?d?ric wrote: > On jeudi 27 novembre 2008, Roy H. Han wrote: > > > Is there a way to access the filters available in GIMP to process images > > within Python? > > I see that there is a way to write Python-based plugins for GIMP, but I > > would like to call GIMP filters from Python. > > Maybe this is a naive question. > > I also see that there is an ImageFilter class in PIL, but GIMP has so > > many filters already written that I wondered whether I could use GIMP's > > filters right away. > > Why not using the new GEGL lib, which Gimp will now use? There are already > python binding, and GEGL already has some basic filtering features: > > http://www.gegl.org > http://gegl.org/pygegl > http://www.gegl.org/operations.html > > -- > Fr?d?ric > > http://www.gbiloba.org > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Fri Dec 5 16:48:28 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 5 Dec 2008 16:48:28 +0100 Subject: [Image-SIG] error install PIL 1.1.6 In-Reply-To: <0C96F0BFE078D74C91A1C541D24A6AE4358A4280@EMGMB1.ad.medctr.ucla.edu> References: <0C96F0BFE078D74C91A1C541D24A6AE4358A4280@EMGMB1.ad.medctr.ucla.edu> Message-ID: <368a5cd50812050748k576be185p1b7a40b86e89e3c5@mail.gmail.com> On Thu, Dec 4, 2008 at 9:29 PM, Friedrich, Tara wrote: > I am trying to install python image library 1.1.6 and I am having the following errors when I install the lazy way using python setup.py install: > > running install > running build > running build_py > running build_ext > building '_imagingtk' extension > gcc -pthread -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fPIC -fPIC -I/usr/include/freetype2 -IlibImaging -I/usr/include -I/usr/local/include -I/usr/include/python2.5 -c _imagingtk.c -o build/temp.linux-x86_64-2.5/_imagingtk.o > _imagingtk.c:20:16: error: tk.h: No such file or directory This probably means that you have enough of Tcl/Tk installed for the installation process to think it's worth building the Tkinter support, but, as Karsten points out, not enough of it to actually be able to build that support. To fix this, either install tcl-dev/tk-dev (or whatever the packages are called on your machine), or tweak setup.py to skip that part of the process. From ghempresa at hotmail.com Fri Dec 5 18:37:18 2008 From: ghempresa at hotmail.com (Luis Gonzalez) Date: Fri, 5 Dec 2008 17:37:18 +0000 Subject: [Image-SIG] How to load Gtk Font using ImageFont? Message-ID: Hi to all, I am using pygtk to develop an application. I have a gtk.FontSelection widget that i get font name with get_font_name() method. Now i get the font name , how to using to load it in ImageFont? _________________________________________________________________ Discover the new Windows Vista http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE From kraemertim at ymail.com Mon Dec 8 10:06:04 2008 From: kraemertim at ymail.com (Tim Kraemer) Date: Mon, 8 Dec 2008 09:06:04 +0000 (GMT) Subject: [Image-SIG] Problem with show() in PIL1.1.6 Message-ID: <751632.8911.qm@web28306.mail.ukl.yahoo.com> Hi everybody, I'm new to this mailing list and hope anybody can help me with my problem: Within a python script I use Image.show() to have a look on the images I analyze (if I want to). The script runs fully automated so there is no need to look at the images all the time. With PIL1.1.5 everything is alright but with PIL1.1.6 Image.show() waits until the showing program has been closed. I didn't find anything about this fundamental change in the 1.1.6 release changes. Therefore I'm wondering if this behaviour is intended or if this is a bug? Are there any command parameters to prevent Image.show() from waiting? FYI: I'm using Windows XP Pro SP2 with ActiveState Python 2.5.2 Thanks in advance Tim -------------- next part -------------- An HTML attachment was scrubbed... URL: From mann_sar at hotmail.com Mon Dec 8 13:33:02 2008 From: mann_sar at hotmail.com (Mandar Sarlashkar) Date: Mon, 8 Dec 2008 18:03:02 +0530 Subject: [Image-SIG] Ability of Python ? Message-ID: Dear all, I am trying some analysis or Math operations on Remote Sensing ( Satellite Imagery ) Data. Currently I am trying the code on a tiny subset of the whole imagery. I want to know if there is any limit on size of Image or number of pixels in using Python, GDAL and NumPY for Image analysis. Thank you. Cheers _________________________________________________________________ Search for videos of Bollywood, Hollywood, Mollywood and every other wood, only on Live.com http://www.live.com/?scope=video&form=MICOAL -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Tue Dec 9 14:17:23 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 9 Dec 2008 14:17:23 +0100 Subject: [Image-SIG] ImageDraw leaks unless deleted? In-Reply-To: <490F7A05.9060204@nedbatchelder.com> References: <490F7A05.9060204@nedbatchelder.com> Message-ID: <368a5cd50812090517i1c4e46cen2817f31a2a9d3f43@mail.gmail.com> If explicit "del" appears to address a leak that Python's builtin refcounter doesn't handle, that's more of a bug in Python than in PIL ;-) I'm not 100% sure, but I think the rationale for including the explicit "del" in that example is that the draw object holds a reference to the image you're drawing in; by doing an explicit del, you minimize the risk that the program hangs on to potentially large image objects without you noticing. (I wouldn't rule out a memory leak either, of course; if you can find a small example that leaks when executed in a loop, let me know). On Mon, Nov 3, 2008 at 11:24 PM, Ned Batchelder wrote: > In the docs for ImageDraw > (http://www.pythonware.com/library/pil/handbook/imagedraw.htm), the example > includes "del draw". I don't understand why that line is necessary, since > when the variable goes out of scope, the object will be deleted. > But in our unit tests, we had a problem with memory use growing too large to > complete the tests. By adding some "del draw" lines into our code, we > halved the memory requirement. In all cases, these dels were in places > where the variable would go out of scope or be overwritten shortly anyway. > Why are the dels necessary? Is this a subtle memory management bug in > ImageDraw? > > --Ned. > http://nedbatchelder.com > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From fredrik at pythonware.com Tue Dec 9 17:00:17 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 9 Dec 2008 17:00:17 +0100 Subject: [Image-SIG] Problem with show() in PIL1.1.6 In-Reply-To: <751632.8911.qm@web28306.mail.ukl.yahoo.com> References: <751632.8911.qm@web28306.mail.ukl.yahoo.com> Message-ID: <368a5cd50812090800t6ca4e8aje65486436d0cfe55@mail.gmail.com> The 1.1.5 behaviour on Windows was broken in a number of ways, so the code was reverted to the 1.1.4 state of things in 1.1.6. To get the old behaviour, you can use the helper function shown in this session: >>> import threading >>> from PIL import ImageWin >>> def display(im): ... def viewer(): ... w = ImageWin.ImageWindow(im) ... w.mainloop() ... t = threading.Thread(target=viewer) ... t.start() # do the setup and run the mainloop in a separate thread ... >>> from PIL import Image >>> im = Image.new("RGB", (512, 512), "red") >>> display(im) 2008/12/8 Tim Kraemer : > Hi everybody, > > I'm new to this mailing list and hope anybody can help me with my problem: > > Within a python script I use Image.show() to have a look on the images I > analyze (if I want to). The script runs fully automated so there is no need > to look at the images all the time. > > With PIL1.1.5 everything is alright but with PIL1.1.6 Image.show() waits > until the showing program has been closed. I didn't find anything about this > fundamental change in the 1.1.6 release changes. Therefore I'm wondering if > this behaviour is intended or if this is a bug? Are there any command > parameters to prevent Image.show() from waiting? > > FYI: I'm using Windows XP Pro SP2 with ActiveState Python 2.5.2 > > Thanks in advance > Tim > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > From fredrik at pythonware.com Tue Dec 9 17:05:32 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 9 Dec 2008 17:05:32 +0100 Subject: [Image-SIG] Fail to install PIL 1.1.6 for Python 2.5 Windows In-Reply-To: <2be03dc30811242212x54d5633du760945506f9c91b5@mail.gmail.com> References: <2be03dc30811242212x54d5633du760945506f9c91b5@mail.gmail.com> Message-ID: <368a5cd50812090805s705e4a55x6d7c064a15853808@mail.gmail.com> It's not that easy to help you unless you explain to us *how* it failed. What error messages did you get? How far through the installation process did you get before it stopped working? What happens when you try to run the installer again? Are there any new files under /python26/lib/site-packages that seems to belong to PIL? 2008/11/25 Lee Seongjoo : > Hello, > > PIL 1.1.6 for Python 2.5 on Windows failed. I think the problem was Python > is running at the time of installation. Another attempt was failed even > after Python was terminated. Help? > > -- > Lee Seongjoo > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > From fredrik at pythonware.com Tue Dec 9 17:35:37 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 9 Dec 2008 17:35:37 +0100 Subject: [Image-SIG] Creating an image from 's getImageData() data In-Reply-To: References: Message-ID: <368a5cd50812090835s7952a11bp391c75a1cf9c9402@mail.gmail.com> The "raw" data decoder expects raw binary bytes; in this case, it expects four bytes per pixel ( ), repeated 80x80 times to fill the entire image. What does the data you get back from getImageData() look like if you print (a portion of) it? e.g. say print repr(data[:40]) (That "replace" you're using makes me think that you have data in text form, not binary form...) On Sun, Nov 23, 2008 at 7:16 PM, Adam Guthrie wrote: > I'm using 's getImageData() function [0] to extract pixel data > from a canvas. The function returns a CanvasPixelArray, which is just > a comma-separated list of all the RGBA pixel values. I then try to > create an image using Image.fromstring as follows: > > data = > # remove the commas from the string > data = data.replace(',', '') > im = Image.fromstring("RGBA", (80,80), data) > im.save("image.jpg") > > This all works fine without any errors. However, the resulting image > is not the same as area that I extracted from the canvas. Here's an > example of the resulting image: > http://img92.imageshack.us/img92/3495/newimagept1.jpg. And here's an > example of the expected image: > http://img92.imageshack.us/img92/2562/graphxy9.jpg. > > I can't figure out what I'm doing wrong here. Does the "raw" decoder > accept raw pixel data like this, or does it only like raw image > formats with proper headers, etc. like BMPs. Do I need to write my own > custom decoder? > > Thanks, > Adam Guthrie > > [0] http://www.whatwg.org/specs/web-apps/current-work/#dom-context-2d-getimagedata > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From fredrik at pythonware.com Tue Dec 9 19:00:10 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 9 Dec 2008 19:00:10 +0100 Subject: [Image-SIG] Creating an image from 's getImageData() data In-Reply-To: <368a5cd50812090835s7952a11bp391c75a1cf9c9402@mail.gmail.com> References: <368a5cd50812090835s7952a11bp391c75a1cf9c9402@mail.gmail.com> Message-ID: <368a5cd50812091000y430928f5y26431c6e676b8bf9@mail.gmail.com> On Tue, Dec 9, 2008 at 5:35 PM, Fredrik Lundh wrote: > The "raw" data decoder expects raw binary bytes; in this case, it > expects four bytes per pixel ( ), repeated > 80x80 times to fill the entire image. What does the data you get back > from getImageData() look like if you print (a portion of) it? e.g. > say > > print repr(data[:40]) > > (That "replace" you're using makes me think that you have data in text > form, not binary form...) And for the record, here's a fairly efficient way to convert comma-separated pixel values into a PIL Image object: >>> data = "1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16" >>> import Image >>> import array >>> a = array.array("b", map(int, data.split(","))) >>> a array('b', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) # turn it into a grayscale image (one byte per pixel) >>> i = Image.frombuffer("L", (4, 4), a, "raw", "L", 0, 1) >>> i.mode 'L' >>> list(i.getdata()) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] # turn it into an RGBA image (four bytes per pixel) >>> i = Image.frombuffer("RGBA", (1, 4), a, "raw", "RGBA", 0, 1) >>> i.mode 'RGBA' >>> list(i.getdata()) [(1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12), (13, 14, 15, 16)] From Chris.Barker at noaa.gov Tue Dec 9 19:04:27 2008 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Tue, 09 Dec 2008 10:04:27 -0800 Subject: [Image-SIG] Ability of Python ? In-Reply-To: References: Message-ID: <493EB32B.4040207@noaa.gov> Mandar Sarlashkar wrote: > I am trying some analysis or Math operations on Remote Sensing ( > Satellite Imagery ) Data. > > Currently I am trying the code on a tiny subset of the whole imagery. > > I want to know if there is any limit on size of Image or number of > pixels in using Python, GDAL and NumPY for Image analysis. you are only limited by memory -- and when you do hit those limits, there are ways to get around them -- memapped arrays, etc. if you have a particular problem you are trying to solve, try the numpy list. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker at noaa.gov From spe.stani.be at gmail.com Tue Dec 9 19:38:21 2008 From: spe.stani.be at gmail.com (Stani) Date: Tue, 09 Dec 2008 19:38:21 +0100 Subject: [Image-SIG] Ability of Python ? In-Reply-To: <493EB32B.4040207@noaa.gov> References: <493EB32B.4040207@noaa.gov> Message-ID: <1228847901.22109.52.camel@blue> I know from the Gimp developers that GEGL (new pipeline based, graphics library for Gimp) supports on demand loading of pixel areas, so there is no real limit on the size of the images. http://gegl.org/pygegl/ http://gegl.org/gallery/index.html (some xml examples, not python) It's probably still beta, but looks promising. Gegl is already in included in all major linux distributions and pygegl will be soon. Stani Op dinsdag 09-12-2008 om 10:04 uur [tijdzone -0800], schreef Christopher Barker: > Mandar Sarlashkar wrote: > > I am trying some analysis or Math operations on Remote Sensing ( > > Satellite Imagery ) Data. > > > > Currently I am trying the code on a tiny subset of the whole imagery. > > > > I want to know if there is any limit on size of Image or number of > > pixels in using Python, GDAL and NumPY for Image analysis. > > you are only limited by memory -- and when you do hit those limits, > there are ways to get around them -- memapped arrays, etc. > > if you have a particular problem you are trying to solve, try the numpy > list. > > -Chris > > From jcupitt at gmail.com Tue Dec 9 21:57:26 2008 From: jcupitt at gmail.com (jcupitt at gmail.com) Date: Tue, 9 Dec 2008 20:57:26 +0000 Subject: [Image-SIG] Ability of Python ? In-Reply-To: <1228847901.22109.52.camel@blue> References: <493EB32B.4040207@noaa.gov> <1228847901.22109.52.camel@blue> Message-ID: <522c6460812091257r2e7cd12etf93bbce7bdaafce6@mail.gmail.com> 2008/12/9 Stani : > I know from the Gimp developers that GEGL (new pipeline based, graphics > library for Gimp) supports on demand loading of pixel areas, so there is > no real limit on the size of the images. > http://gegl.org/pygegl/ > http://gegl.org/gallery/index.html (some xml examples, not python) > > It's probably still beta, but looks promising. Gegl is already in > included in all major linux distributions and pygegl will be soon. There's also vips: http://www.vips.ecs.soton.ac.uk/index.php?title=Python It should be quicker than GEGL (especially on multicore systems) and, like GEGL, has very low memory needs. John From unarsu at gmail.com Wed Dec 10 19:13:27 2008 From: unarsu at gmail.com (Uttam M. Narsu) Date: Wed, 10 Dec 2008 13:13:27 -0500 Subject: [Image-SIG] Does RGBA drawing mode work? Message-ID: I'm trying to draw using the experimental **RGBA-on-RGB interface. I can't seem to get it to work. from PIL import Image, ImageDraw ml = Image.new("RGBA", (200,200)) D = ImageDraw.Draw(ml, "RGBA") red = (0xff, 0x00, 0x00, 0xA9) green = (0x00, 0xbf, 0x00, 0x83) D.polygon([(40, 40), (40, 100), (100, 100), (100, 40)], fill=red) D.polygon([(20, 20), (20, 80), (80, 80), (80, 20)], fill=green) ml.save("test.png", "PNG") Results in the attached image. The red polygon doesn't show through beneath the green one. I'd appreciate any pointers on this. It seems fairly simple. - uman -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: test.png Type: image/png Size: 2785 bytes Desc: not available URL: From unarsu at gmail.com Wed Dec 10 19:32:00 2008 From: unarsu at gmail.com (Uttam M. Narsu) Date: Wed, 10 Dec 2008 13:32:00 -0500 Subject: [Image-SIG] Does the experimental RGBA-on-RGB drawing mode work? Message-ID: Apologies if this is a dup, since I wasn't subscribed to the list. I'm trying to draw using the experimental RGBA-on-RGB interface. I can't seem to get it to work. My code is below: from PIL import Image, ImageDraw ml = Image.new("RGBA", (200,200)) D = ImageDraw.Draw(ml, "RGBA") red = (0xff, 0x00, 0x00, 0xA9) green = (0x00, 0xbf, 0x00, 0x83) D.polygon([(40, 40), (40, 100), (100, 100), (100, 40)], fill=red) D.polygon([(20, 20), (20, 80), (80, 80), (80, 20)], fill=green) ml.save("test.png", "PNG") Results in the attached image. The red polygon doesn't show through beneath the green one. I'd appreciate any pointers on this. It seems fairly simple. I'm using python/py25-pil 1.1.6 installed through macports on leopard. Thanks. - uman -------------- next part -------------- A non-text attachment was scrubbed... Name: test.png Type: image/png Size: 2785 bytes Desc: not available URL: From unarsu at gmail.com Wed Dec 10 20:05:25 2008 From: unarsu at gmail.com (Uttam M. Narsu) Date: Wed, 10 Dec 2008 14:05:25 -0500 Subject: [Image-SIG] Does the experimental RGBA-on-RGB drawing mode work? In-Reply-To: References: Message-ID: Looks like it might be a bug in the ImageDraw init function. If I change the 3rd line to: ml = Image.new("RGB", (200,200), (0,0,0,0)) it works. Looking at the source of ImageDraw.py: blend = 0 if mode is None: mode = im.mode if mode != im.mode: if mode == "RGBA" and im.mode == "RGB": blend = 1 blend is set to 1, only if the modes are "RGBA" and "RGB". Shouldn't blending occur if I create an RGBA image and draw onto it? Or do I have to explicitly set a blend mode somewhere? -u On Wed, Dec 10, 2008 at 1:32 PM, Uttam M. Narsu wrote: > Apologies if this is a dup, since I wasn't subscribed to the list. > I'm trying to draw using the experimental RGBA-on-RGB interface. I > can't seem to get it to work. My code is below: > > from PIL import Image, ImageDraw > > ml = Image.new("RGBA", (200,200)) > D = ImageDraw.Draw(ml, "RGBA") > > red = (0xff, 0x00, 0x00, 0xA9) > green = (0x00, 0xbf, 0x00, 0x83) > > D.polygon([(40, 40), (40, 100), (100, 100), (100, 40)], fill=red) > D.polygon([(20, 20), (20, 80), (80, 80), (80, 20)], fill=green) > ml.save("test.png", "PNG") > > Results in the attached image. The red polygon doesn't show through > beneath the green one. > > I'd appreciate any pointers on this. It seems fairly simple. > > I'm using python/py25-pil 1.1.6 installed through macports on leopard. Thanks. > > - > uman > From phred78 at gmail.com Thu Dec 11 19:25:17 2008 From: phred78 at gmail.com (Frederico Leonardo) Date: Thu, 11 Dec 2008 18:25:17 +0000 Subject: [Image-SIG] Getting information from Flash to PIL Message-ID: <2b5ff9ab0812111025w4feb545cq67ea73fdf9ce33@mail.gmail.com> Hi all, I've only recently started using Python via Django and so far I'm loving it. I have a question that hopefully someone might be able to answer. I've scouted the internet looking for this but can't manage to find the right example. I'm creating an e-card application in Django. Some of the e-cards are SWF with a script that reads your webcam and then produces a new card with the webcam information. Flash is working fine and it's sending me variables to construct the new image. I can already get the width and height: card_width = int(request.POST.get('width','')) card_height = int(request.POST.get('height','')) But I have no idea how to convert the rest of the information into an image, let alone draw and save it. This is what Flash is sending me via 'POST': Variable: px19 Value: u',,,,,,,,,,,,,,,,,,,,,,,,,,,,,eeffff,abcae7,8baece,6c90b0,6b8faf,698bae,6789ae,(...) It repeats this for every px# and is also sending me rows and cols, besides the width and height. Those values are hex and I suppose that they correspond to the rows, each color being 1 pixel per column. I came across this technique here: http://www.sephiroth.it/tutorials/flashPHP/print_screen/page002.php But alas, it's a PHP script, that I would very much love to reproduce using PIL. How can I grab that information into an array and then have PIL convert it into a JPG that I can save on the server. Any ideas? Thank you! ? Frederico From gregor at kopka.net Fri Dec 12 02:37:53 2008 From: gregor at kopka.net (Gregor Kopka) Date: Fri, 12 Dec 2008 02:37:53 +0100 Subject: [Image-SIG] Getting information from Flash to PIL In-Reply-To: <2b5ff9ab0812111025w4feb545cq67ea73fdf9ce33@mail.gmail.com> References: <2b5ff9ab0812111025w4feb545cq67ea73fdf9ce33@mail.gmail.com> Message-ID: <4941C071.7030907@kopka.net> Hi Frederico, the code you took to start with isn't that bad, but it's originally used for a doodling demo which has a uniform white background (which is something that you won't have) so the protocol used will inflate the uncompressed image data you have by a factor of at least 3.5 ! Since you POST anyway maybe better use a binary format which: - gets rid of the useless (at least for sending webcam images) pseudo-compression (removing a uniform background color - which you won't have) scheme - avoids encoding the data as an ASCII string (which inflates the size of the data by at least 3.5 times) for better performance / less data to transfer? The easiest way would be to put something in the flash applet which outputs something that can be directly fed to Image.fromstring or Image.frombuffer. After getting that to work you can then add some sort of real compression, here's some fodder for you to get started: http://www.razorberry.com/blog/archives/2004/08/22/lzw-compression-methods-in-as2/ http://newmovieclip.wordpress.com/2006/05/15/image-compression-possibilities-in-flash-8/ The problem you will have is that LZW isn't that good performing (in terms of compression rate) on stuff like video images... so better code it in a way that you can plug-in another, better suited compression scheme later. But it'll be better than encoding it in ASCII for sure :) Regards, Gregor Frederico Leonardo schrieb: > Hi all, > > I've only recently started using Python via Django and so far I'm loving it. > I have a question that hopefully someone might be able to answer. I've > scouted the internet looking for this but can't manage to find the > right example. > > I'm creating an e-card application in Django. Some of the e-cards are > SWF with a script that reads your webcam and then produces a new card > with the webcam information. Flash is working fine and it's sending me > variables to construct the new image. I can already get the width and > height: > > card_width = int(request.POST.get('width','')) > card_height = int(request.POST.get('height','')) > > But I have no idea how to convert the rest of the information into an > image, let alone draw and save it. > > This is what Flash is sending me via 'POST': > > Variable: px19 > Value: u',,,,,,,,,,,,,,,,,,,,,,,,,,,,,eeffff,abcae7,8baece,6c90b0,6b8faf,698bae,6789ae,(...) > > It repeats this for every px# and is also sending me rows and cols, > besides the width and height. Those values are hex and I suppose that > they correspond to the rows, each color being 1 pixel per column. > I came across this technique here: > http://www.sephiroth.it/tutorials/flashPHP/print_screen/page002.php > But alas, it's a PHP script, that I would very much love to reproduce using PIL. > > How can I grab that information into an array and then have PIL > convert it into a JPG that I can save on the server. Any ideas? > > Thank you! > > ? Frederico > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > -------------- next part -------------- A non-text attachment was scrubbed... Name: gregor.vcf Type: text/x-vcard Size: 314 bytes Desc: not available URL: From michaelvantellingen at gmail.com Fri Dec 12 17:34:50 2008 From: michaelvantellingen at gmail.com (Michael van Tellingen) Date: Fri, 12 Dec 2008 17:34:50 +0100 Subject: [Image-SIG] PIL 1.1.6 and convert cmyk jpegs to rgb and writing png files Message-ID: Hello, I'm currently writing a webapplication which processes images uploaded by users and i'm running into two problems: - Converting a CMYK jpeg image to RGB results in the wrong colors used, i've solved this by patching PIL with the file attached to http://mail.python.org/pipermail/image-sig/2006-April/003871.html - It seems that writing a PNG image requires the GIL. I convert all uploaded images in a separate thread to PNG images and while doing so my complete python application becomes really slow, I don't have this problem when I convert it to JPEG or TIFF. Is this correct? And if so, how hard would it be to solve this problem? Thanks, Michael van Tellingen From kevin at cazabon.com Fri Dec 12 17:55:42 2008 From: kevin at cazabon.com (Kevin Cazabon) Date: Fri, 12 Dec 2008 11:55:42 -0500 Subject: [Image-SIG] PIL 1.1.6 and convert cmyk jpegs to rgb and writing png files In-Reply-To: References: Message-ID: <4FC78CAD-9541-41D8-806D-8806A71B4FFC@cazabon.com> A couple years ago, a few of us worked on adding multi-threading support to key routines in PIL - focusing on the ones that would most likely be CPU intensive or long duration operations. It's a simple fix to release the GIL before starting the op, and re-acquire before returning - look at the C code for resize, for example. We didn't get it implemented everywhere, but many of the "expensive" operations are now covered. I'm sure Fred would gladly accept patches to add support elsewhere. Kevin. On 12 Dec 2008, at 11:34, Michael van Tellingen wrote: > Hello, > > I'm currently writing a webapplication which processes images uploaded > by users and i'm running into two problems: > - Converting a CMYK jpeg image to RGB results in the wrong colors > used, i've solved this by patching PIL with the > file attached to > http://mail.python.org/pipermail/image-sig/2006-April/003871.html > > - It seems that writing a PNG image requires the GIL. I convert all > uploaded images in a separate thread to PNG > images and while doing so my complete python application becomes > really slow, I don't have this problem when > I convert it to JPEG or TIFF. Is this correct? And if so, how hard > would it be to solve this problem? > > Thanks, > Michael van Tellingen > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig From kevin at cazabon.com Fri Dec 12 17:56:30 2008 From: kevin at cazabon.com (Kevin Cazabon) Date: Fri, 12 Dec 2008 11:56:30 -0500 Subject: [Image-SIG] Fwd: PIL 1.1.6 and convert cmyk jpegs to rgb and writing png files References: <4FC78CAD-9541-41D8-806D-8806A71B4FFC@cazabon.com> Message-ID: > > A couple years ago, a few of us worked on adding multi-threading > support to key routines in PIL - focusing on the ones that would > most likely be CPU intensive or long duration operations. It's a > simple fix to release the GIL before starting the op, and re-acquire > before returning - look at the C code for resize, for example. We > didn't get it implemented everywhere, but many of the "expensive" > operations are now covered. I'm sure Fred would gladly accept > patches to add support elsewhere. > > Kevin. > > > On 12 Dec 2008, at 11:34, Michael van Tellingen wrote: > >> Hello, >> >> I'm currently writing a webapplication which processes images >> uploaded >> by users and i'm running into two problems: >> - Converting a CMYK jpeg image to RGB results in the wrong colors >> used, i've solved this by patching PIL with the >> file attached to >> http://mail.python.org/pipermail/image-sig/2006-April/003871.html >> >> - It seems that writing a PNG image requires the GIL. I convert all >> uploaded images in a separate thread to PNG >> images and while doing so my complete python application becomes >> really slow, I don't have this problem when >> I convert it to JPEG or TIFF. Is this correct? And if so, how hard >> would it be to solve this problem? >> >> Thanks, >> Michael van Tellingen >> _______________________________________________ >> Image-SIG maillist - Image-SIG at python.org >> http://mail.python.org/mailman/listinfo/image-sig > From afbarnard at wisc.edu Mon Dec 15 01:55:42 2008 From: afbarnard at wisc.edu (Aubrey Barnard) Date: Sun, 14 Dec 2008 18:55:42 -0600 Subject: [Image-SIG] Addition to PIL FAQ Message-ID: <4945AB0E.9070403@wisc.edu> Dear PIL developers of the image SIG, I have an addition that I would like to make to the PIL FAQ (located at http://www.pythonware.com/products/pil/faq.htm). I would like to add the following information to the answer to "Why does PIL say 'The _imaging C module is not installed'?" I saw this problem because I was using PIL with a different version of Python than was used to compile PIL. So the tip to add is that PIL must be compiled and used with the same Python. While this requirement might seem obvious, it can be obscured on machines with multiple versions of Python when a user requests a particular Python that is not the first one found via the path. (E.g. PIL will be built with the default Python, but the user will try to use it with a different Python.) Thank you for considering adding this to the FAQ. I think it will save PIL users such as myself many headaches. Sincerely, Aubrey Barnard From d_l_goldsmith at yahoo.com Mon Dec 15 09:45:04 2008 From: d_l_goldsmith at yahoo.com (David Goldsmith) Date: Mon, 15 Dec 2008 00:45:04 -0800 (PST) Subject: [Image-SIG] Addition to PIL FAQ In-Reply-To: <4945AB0E.9070403@wisc.edu> Message-ID: <548122.50958.qm@web52107.mail.re2.yahoo.com> I second this: it might be obvious to software developers, but _not_ to software users. IMO, this addition should be added in many other packages' FAQ, not just PIL. :-) Thanks, Aubrey. DG --- On Sun, 12/14/08, Aubrey Barnard wrote: > From: Aubrey Barnard > Subject: [Image-SIG] Addition to PIL FAQ > To: image-sig at python.org > Date: Sunday, December 14, 2008, 4:55 PM > Dear PIL developers of the image SIG, > > I have an addition that I would like to make to the PIL FAQ > (located at http://www.pythonware.com/products/pil/faq.htm). > I would like to add the following information to the answer > to "Why does PIL say 'The _imaging C module is not > installed'?" > > I saw this problem because I was using PIL with a different > version of Python than was used to compile PIL. So the tip > to add is that PIL must be compiled and used with the same > Python. > > While this requirement might seem obvious, it can be > obscured on machines with multiple versions of Python when a > user requests a particular Python that is not the first one > found via the path. (E.g. PIL will be built with the default > Python, but the user will try to use it with a different > Python.) > > Thank you for considering adding this to the FAQ. I think > it will save PIL users such as myself many headaches. > > Sincerely, > > Aubrey Barnard > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig From michaelvantellingen at gmail.com Mon Dec 15 09:53:05 2008 From: michaelvantellingen at gmail.com (Michael van Tellingen) Date: Mon, 15 Dec 2008 09:53:05 +0100 Subject: [Image-SIG] PIL 1.1.6 and convert cmyk jpegs to rgb and writing png files In-Reply-To: <4FC78CAD-9541-41D8-806D-8806A71B4FFC@cazabon.com> References: <4FC78CAD-9541-41D8-806D-8806A71B4FFC@cazabon.com> Message-ID: On Fri, Dec 12, 2008 at 17:55, Kevin Cazabon wrote: > A couple years ago, a few of us worked on adding multi-threading support to > key routines in PIL - focusing on the ones that would most likely be CPU > intensive or long duration operations. It's a simple fix to release the GIL > before starting the op, and re-acquire before returning - look at the C code > for resize, for example. We didn't get it implemented everywhere, but many > of the "expensive" operations are now covered. I'm sure Fred would gladly > accept patches to add support elsewhere. > > Kevin. Hi Kevin, thanks for the quick reply. I've followed your advice and it was simpler then I thought. I've attached two patches to this email. One diff is your old patch I was using to correctly convert CMYK images to RGB. The other one drops the GIL when saving png images. Could these be committed to the PIL svn repo after a review? Thanks, Michael > > On 12 Dec 2008, at 11:34, Michael van Tellingen wrote: > >> Hello, >> >> I'm currently writing a webapplication which processes images uploaded >> by users and i'm running into two problems: >> - Converting a CMYK jpeg image to RGB results in the wrong colors >> used, i've solved this by patching PIL with the >> file attached to >> http://mail.python.org/pipermail/image-sig/2006-April/003871.html >> >> - It seems that writing a PNG image requires the GIL. I convert all >> uploaded images in a separate thread to PNG >> images and while doing so my complete python application becomes >> really slow, I don't have this problem when >> I convert it to JPEG or TIFF. Is this correct? And if so, how hard >> would it be to solve this problem? >> >> Thanks, >> Michael van Tellingen >> _______________________________________________ >> Image-SIG maillist - Image-SIG at python.org >> http://mail.python.org/mailman/listinfo/image-sig > > -------------- next part -------------- A non-text attachment was scrubbed... Name: PIL.JpegImagePlugin.diff Type: text/x-diff Size: 2141 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: libImaging.ZipEncode.diff Type: text/x-diff Size: 969 bytes Desc: not available URL: From fredrik at pythonware.com Mon Dec 15 11:01:41 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 15 Dec 2008 11:01:41 +0100 Subject: [Image-SIG] Addition to PIL FAQ In-Reply-To: <4945AB0E.9070403@wisc.edu> References: <4945AB0E.9070403@wisc.edu> Message-ID: <368a5cd50812150201y2d6c9d74s33a72b2730abcd96@mail.gmail.com> That specific case is discussed in the last section of that page. The page is roughly sorted after how common the different cases were when the page was first written; given that different people get stuck at different points in the process, I'm not sure it's possible to have everyone's stumbling block at the top of the FAQ ;-) On Mon, Dec 15, 2008 at 1:55 AM, Aubrey Barnard wrote: > Dear PIL developers of the image SIG, > > I have an addition that I would like to make to the PIL FAQ (located at > http://www.pythonware.com/products/pil/faq.htm). I would like to add the > following information to the answer to "Why does PIL say 'The _imaging C > module is not installed'?" > > I saw this problem because I was using PIL with a different version of > Python than was used to compile PIL. So the tip to add is that PIL must be > compiled and used with the same Python. > > While this requirement might seem obvious, it can be obscured on machines > with multiple versions of Python when a user requests a particular Python > that is not the first one found via the path. (E.g. PIL will be built with > the default Python, but the user will try to use it with a different > Python.) > > Thank you for considering adding this to the FAQ. I think it will save PIL > users such as myself many headaches. > > Sincerely, > > Aubrey Barnard > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From dineshbvadhia at hotmail.com Wed Dec 17 00:05:28 2008 From: dineshbvadhia at hotmail.com (Dinesh B Vadhia) Date: Tue, 16 Dec 2008 15:05:28 -0800 Subject: [Image-SIG] Image filters Message-ID: Hi! I've just joined the group and would like to know what filters are available (if any) for extracting image information eg. Gabor, Tamura, HSV etc. Thank-you. Dinesh -------------- next part -------------- An HTML attachment was scrubbed... URL: From lwalker at monetate.com Wed Dec 17 20:31:04 2008 From: lwalker at monetate.com (Luke Walker) Date: Wed, 17 Dec 2008 14:31:04 -0500 Subject: [Image-SIG] Python version 1.2+ Message-ID: On this page: http://effbot.org/zone/pil-changes-113.htm there's talk of versions 1.2a3 and 1.2b1 as being 'released'. How can one upgrade to these versions? -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Wed Dec 17 22:10:24 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 17 Dec 2008 22:10:24 +0100 Subject: [Image-SIG] Python version 1.2+ In-Reply-To: References: Message-ID: <368a5cd50812171310k2a1e4e69ma6a1bab52b80f89@mail.gmail.com> Those were special editions that were only available as part of a commercial package (imToolkit). That branch was discontinued long ago. The next *major* update of PIL will most likely be called 2.0. 2008/12/17 Luke Walker > > On this page: http://effbot.org/zone/pil-changes-113.htm there's talk of versions 1.2a3 and 1.2b1 as being 'released'. > > How can one upgrade to these versions? From jasorod at cox.net Mon Dec 22 07:39:53 2008 From: jasorod at cox.net (Jason Rodriguez) Date: Mon, 22 Dec 2008 01:39:53 -0500 Subject: [Image-SIG] Can't seem to assign values to I;16 image Message-ID: <494F3639.2020501@cox.net> Hi, I'm trying to perform pixel-assignment operations using the load() method in order to create 16-bit TIFF files. From the documentation, it seems quite straight-forward using the internal I;16 image format, but for some reason, it seems that even a simple pixel assignment with this format fails. For instance, I cannot get this to work: >>> import Image >>> test_image = Image.new('I;16', [300,300]) >>> test_image_pix = test_image.load() >>> test_image_pix[3,3] = 5000 >>> test_image_pix[3,3] 0 >>> As you can see, rather than pixel [3,3] being assigned a value of 5000, it still gets assigned a value of 0. And this seems to happen with the putdata() method as well. It also doesn't seem to matter what integer value I input, they all return 0 when I call them back. For RGB, Float, 32-bit Integer, etc. formats, this method seems to work fine though. For instance: >>> test_image2 = Image.new('RGB', [300,300]) >>> test_image2_pix = test_image2.load() >>> test_image2_pix[3,3] = 40,40,40 >>> test_image2_pix[3,3] (40, 40, 40) >>> Is there a bug I'm un-aware of for assigning pixel values to I;16 formatted images? Or is there a specific function I should apply to the integers being input into the I;16 format for them to be assigned properly? If there is a bug, what is the work-around for creating a 16-bit TIFF? Thanks, Jason Rodriguez Virginia Beach, VA From fetchinson at googlemail.com Thu Dec 25 09:55:04 2008 From: fetchinson at googlemail.com (Daniel Fetchinson) Date: Thu, 25 Dec 2008 00:55:04 -0800 Subject: [Image-SIG] content based image querying Message-ID: Hi folks, I'm aware that this subject is a huge one but please bear with me, I think I have well defined questions, although I'm not at all an imaging expert. Math is not a problem though. I've been looking into content based image querying and was lead to the following paper: Jacobs, Finkelstein, Salesin: Fast Multiresolution Image Querying - http://salesin.cs.washington.edu/abstracts.html#MultiresQuery This paper has the following appealing characteristics: 1. simple to understand the algorithm for non imaging experts 2. relatively easy to implement 3. what it does is exactly what I need The paper is from 1995 and I was wondering if in the past 13 years there was any comparable paper with the above 3 characteristics ("what I need" can be defined as "what the above paper does"). Also, experts in the imaging field also think that this paper is a relevant one? Are there better approaches to the same problem? (Again, "same" means what the above paper does.) Concerning implementation I'm not afraid of writing C but would prefer something that can be implemented using PIL or stable third party libraries like gegl. For example the Haar transform always pops up in similar papers and I'm not aware of a stable library that would do this for me. Are there any I should look into? Finally, I'm aware of the imgSeek project but its not suitable for my needs for various reasons, dependency on qt, slow development, weird database approach, weird packaging (imgSeek, imgSeekLite, isk-daemon, pretty chaotic), not cross-platform (32bit vs 64bit issues), etc. I really considered the option of using parts of imgSeek but after a careful deliberation I decided to start from scratch. Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown From ggpolo at gmail.com Mon Dec 29 20:43:13 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Mon, 29 Dec 2008 17:43:13 -0200 Subject: [Image-SIG] First cut at porting PIL to py3k In-Reply-To: References: Message-ID: On Mon, Dec 29, 2008 at 2:26 PM, Guilherme Polo wrote: > Hi there, > > I hope I didn't waste some time porting PIL to py3k, but I assume I > didn't try finding anyone that was doing it. > > So.. I ported PIL 1.1.6 to py3k today and I believe someone else > around here might be interested on it. It is very likely to exist > problems caused by the transition to bytes in py3k that I didn't fix > yet, but all the tests pass. I also didn't fix display.c (since it is > all Windows dependent) neither Sane/. > > If you give it a try and find any problems, please report (or fix) :) > If this isn't the right place for distributing a patch, my bad then. > I noticed I forgot to do a recursive diff, so it is missing a lot of fixes. I've decided to place it in a repo now: http://gpolo.ath.cx:4242/ git clone git://gpolo.ath.cx/pil-py3k.git > Regards, > -- -- Guilherme H. Polo Goncalves From ggpolo at gmail.com Mon Dec 29 17:26:43 2008 From: ggpolo at gmail.com (Guilherme Polo) Date: Mon, 29 Dec 2008 14:26:43 -0200 Subject: [Image-SIG] First cut at porting PIL to py3k Message-ID: Hi there, I hope I didn't waste some time porting PIL to py3k, but I assume I didn't try finding anyone that was doing it. So.. I ported PIL 1.1.6 to py3k today and I believe someone else around here might be interested on it. It is very likely to exist problems caused by the transition to bytes in py3k that I didn't fix yet, but all the tests pass. I also didn't fix display.c (since it is all Windows dependent) neither Sane/. If you give it a try and find any problems, please report (or fix) :) If this isn't the right place for distributing a patch, my bad then. Regards, -- -- Guilherme H. Polo Goncalves -------------- next part -------------- A non-text attachment was scrubbed... Name: PIL-1.1.6-py3k.diff Type: text/x-patch Size: 62021 bytes Desc: not available URL: From nick.pye at gmail.com Wed Dec 31 17:39:46 2008 From: nick.pye at gmail.com (nicholas Pye) Date: Wed, 31 Dec 2008 16:39:46 +0000 Subject: [Image-SIG] malloc error Message-ID: <40509F14-8DD7-43B8-AC6B-E6D0D48D7964@gmail.com> Hello, I have a peice of code that repeatidly draws new images (draw_image) and then compares the images drawn against an origional image (image_cost). If I remove the PIL functions in these functions the rest of the code runs fine, and does not exhibit a memory leak, however when using PIL repeatidally in these functions I soon run out of memory. It's as if PIL is caching the images in memory or not cleaning up memory ... I've tried png, gif formats all eventually give a malloc of the period of the code run. error Python(2046) malloc: *** mmap(size=16777216) failed (error code=12) def draw_image(popmember,path,img_tick,poly_vector_len): img=Image.new('RGB',(300,300),(0,0,0)) d = aggdraw.Draw(img) for strand in range(len(popmember)): vector = split_strand(popmember[strand],"vec",poly_vector_len) rgb = split_strand(popmember[strand],"rgb",poly_vector_len) alpha = split_strand(popmember[strand],"alpha",poly_vector_len) b = aggdraw.Brush(tuple(rgb),alpha[0]) d.polygon(vector,b) d.flush() img.save(path + str(img_tick) + '.jpg','PNG') def image_cost(path,image2,img_tick): h1 = Image.open(path+image2).histogram() h2 = Image.open(path+str(img_tick)+'.png').histogram() rms = math.sqrt(reduce(operator.add,map(lambda a,b: (a-b)**2, h1, h2))/len(h1)) return rms -------------- next part -------------- An HTML attachment was scrubbed... URL: