From image-sig at online.de Sat Jan 1 14:08:04 2011 From: image-sig at online.de (Helge) Date: Sat, 01 Jan 2011 14:08:04 +0100 Subject: [Image-SIG] PIL .paste Bug? In-Reply-To: References: Message-ID: <4D1F2734.3020007@online.de> HNY Amadeus, Amadeus Demarzi schrieb: > http://dl.dropbox.com/u/18782/PILBug.zip > > My intent is to have burn.png NOT manipulate the transparency of the > entire image when being pasted onto the solid color. Am I missing > something is this a bug? And if this is a bug, is there some sort of > workaround for it? Please have a look into the thread "Paste with alpha not working correctly" from Sat, 28 Aug 2010 20:07:05 +0200. The solution proposed by Stani may work for your problem as well. Best Regards, Helge From kkrizka at gmail.com Thu Jan 6 06:06:27 2011 From: kkrizka at gmail.com (Karol Krizka) Date: Wed, 5 Jan 2011 21:06:27 -0800 Subject: [Image-SIG] Cannot Load Pixel Information From PNG Image Message-ID: Hi there, I have a PNG file for which PIL 1.1.7 cannot seem to load the pixel values. It returns an integer for all of them instead of a touple. The script that I use to test this is very simple: import Image im=Image.open('house.png') print im data=im.load() print data print data[149,136] The output of it is: 97 I should note that the point (149,136) contains a pixel of colour (97,97,97). However when I change the colour at that point to (128,0,1), I get a value of 160. The PNG image was created by converting a PPM file (which PIL has no trouble reading) using ImageMagick's convert utility. PIL has no trouble reading other images created using the same method. My image viewing programs (xv, gwenview) have no trouble opening this problematic PNG file. I've attached the image to this email. The PIL version that I used is 1.1.7. It is the one in Gentoo Linux repositories. I also tried it with PIL that comes with Ubuntu Maverick 10.10 with the same results. -- Cheers, Karol Krizka http://www.krizka.net -------------- next part -------------- A non-text attachment was scrubbed... Name: house.png Type: image/png Size: 2489 bytes Desc: not available URL: From kkrizka at gmail.com Thu Jan 6 08:50:41 2011 From: kkrizka at gmail.com (Karol Krizka) Date: Wed, 5 Jan 2011 23:50:41 -0800 Subject: [Image-SIG] Cannot Load Pixel Information From PNG Image In-Reply-To: References: Message-ID: On Wed, Jan 5, 2011 at 11:23 PM, Joao S. O. Bueno wrote: > On Thu, Jan 6, 2011 at 3:06 AM, Karol Krizka wrote: >> Hi there, >> >> I have a PNG file for which PIL 1.1.7 cannot seem to load the pixel >> values. It returns an integer for all of them instead of a touple. The >> script that I use to test this is very simple: >> >> import Image >> im=Image.open('house.png') >> print im >> data=im.load() >> print data >> print data[149,136] >> > > It just lookslike you have an indexed image, instead of an RGB one - > Just print out your > "im.mode" to get shure - > print im.mode 'L' Hmm, that seemed to have been the problem... I guess because this image only had greyish values (all RGB components were equal), ImageMagick decided that it would be best to create an grayscale PNG. Thank you for your help! > Proper parameter passing to imagemagick can convert it to a proper RGB > .png file. > For those interested, I now managed to create an RGB image using the following command: convert house.ppm png24:house.png > ?js > ?-><- >> The output of it is: >> >> >> 97 >> >> I should note that the point (149,136) contains a pixel of colour >> (97,97,97). However when I change the colour at that point to >> (128,0,1), I get a value of 160. >> >> The PNG image was created by converting a PPM file (which PIL has no >> trouble reading) using ImageMagick's convert utility. PIL has no >> trouble reading other images created using the same method. My image >> viewing programs (xv, gwenview) have no trouble opening this >> problematic PNG file. I've attached the image to this email. >> >> The PIL version that I used is 1.1.7. It is the one in Gentoo Linux >> repositories. I also tried it with PIL that comes with Ubuntu Maverick >> 10.10 with the same results. >> >> >> -- >> Cheers, >> Karol Krizka >> http://www.krizka.net >> >> _______________________________________________ >> Image-SIG maillist ?- ?Image-SIG at python.org >> http://mail.python.org/mailman/listinfo/image-sig >> >> > -- Cheers, Karol Krizka From Chris.Barker at noaa.gov Thu Jan 6 18:08:52 2011 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Thu, 06 Jan 2011 09:08:52 -0800 Subject: [Image-SIG] Cannot Load Pixel Information From PNG Image In-Reply-To: References: Message-ID: <4D25F724.60105@noaa.gov> On 1/5/11 11:50 PM, Karol Krizka wrote: >> It just lookslike you have an indexed image, instead of an RGB one - >> Just print out your >> "im.mode" to get shure - >> > > print im.mode > 'L' > > Hmm, that seemed to have been the problem... yup. > For those interested, I now managed to create an RGB image using the > following command: > convert house.ppm png24:house.png you could have converted to RGB inside PIL, as well. -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 fredrik at pythonware.com Fri Jan 7 16:19:52 2011 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 7 Jan 2011 16:19:52 +0100 Subject: [Image-SIG] Does the ImageTk.PhotoImage support alpha channels? In-Reply-To: <1292801719.10673.1411147003@webmail.messagingengine.com> References: <1292801719.10673.1411147003@webmail.messagingengine.com> Message-ID: 2010/12/20 : > Does the ImageTk.PhotoImage support alpha channels? If not, are there > any plans to add support for this feature or is the lack of this > functionality a limitation of Tkinter? Yes, RGBA images are supported. In versions before 8.4, the A layer is handled as a mask, not a true alpha layer, but later versions should handle it correctly. From fredrik at pythonware.com Fri Jan 7 16:22:16 2011 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 7 Jan 2011 16:22:16 +0100 Subject: [Image-SIG] bug in version 1.1.7 In-Reply-To: <4D168A07.30901@skynet.be> References: <4D168A07.30901@skynet.be> Message-ID: Yep, it's a known bug in 1.1.7. Trivial patch here: http://hg.effbot.org/pil-2009-raclette/changeset/355 2010/12/26 Kevin Paulus : > > > Hello All and Merry Christmas, > > I've found a bug and verified it with several of my > Slackware fanatics: it seems that Pil 1.1.7 (python 2.6.4 ) > > when you do a Image.open('image').show() > > ImageShow seems to call every available viewer from _viewers on your system > which on mine and a lot of other systems means it builds a separate tempfile > and calls xv and display with them. > > It's been reported the same stuff happens on freebsd where imagemagick's > display and xv is available, which i guess are all the available _viewers > (did some pdb on it, but my knowledge of pdb is rudimentary at best) > > I'm not sure if this is a bug but the docs mentions it should start the > default viewer (usually xv) and not viewer*s* > > it's annoying to say the least. > > > Greetings, > > > goarilla > > > PS: Happy New year's and i hope i didn't offend anyone or didn't follow the > net etiquette, since the only mailing list I've ever used is the one which > is used at work. > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From fredrik at pythonware.com Fri Jan 7 16:49:02 2011 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 7 Jan 2011 16:49:02 +0100 Subject: [Image-SIG] [python-imaging-sane] get_devices and threading In-Reply-To: References: <4D18C5B7.4090308@gmail.com> Message-ID: Well, I'd say scanning falls under the "image stuff" umbrella, and the Sane bindings are shipped with the PIL source code... I don't know much about them, though, but I suspect this is a Python GIL issue. 2010/12/28 Edward Cannon : > wrong mailing list, this is for PIL and related topics only. Try a > sane specific mailing list > > On Mon, Dec 27, 2010 at 8:58 AM, Sandro Mani wrote: >> Hi, >> I wanted to execute sane.get_devices in a separate thread, i.e. consider the >> following program: >> >> #!/usr/bin/env python >> # -*- coding: utf-8 -*- >> >> import threading >> import sane >> import time >> >> devices=None >> >> class GetDevicesThread(threading.Thread): >> ? ?def __init__(self): >> ? ? ? ?threading.Thread.__init__(self) >> ? ? ? ?self.setDaemon(True) >> >> ? ?def run(self): >> ? ? ? ?global devices >> ? ? ? ?#time.sleep(10) >> ? ? ? ?#devices=[] >> ? ? ? ?devices=sane.get_devices() >> >> sane.init() >> GetDevicesThread().start() >> print "Detecting devices" >> while devices==None: >> ? ?time.sleep(1) >> ? ?print "." >> print devices >> >> The devices=sane.get_devices() call in run() for some reason pauses the main >> thread during it's execution - if I switch the statement with the two >> commented lines above, all works as expected. Is there any particular reason >> for this behaviour? >> Thanks >> Sandro Mani >> _______________________________________________ >> Image-SIG maillist ?- ?Image-SIG at python.org >> http://mail.python.org/mailman/listinfo/image-sig >> > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From fredrik at pythonware.com Fri Jan 7 17:01:43 2011 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 7 Jan 2011 17:01:43 +0100 Subject: [Image-SIG] [PATCH; python-imaging-sane] Py_*_ALLOW_THREADS for sane_get_devices and sane_open calls In-Reply-To: <4D193F62.1040901@gmail.com> References: <4D193F62.1040901@gmail.com> Message-ID: Added to trunk. Thanks! /F 2010/12/28 Sandro Mani : > Hi, following patch also adds Py_*_ALLOW_THREADS macros around the > sane_get_devices and sane_open calls which can take a long time especially > if network-scanners are accessed. > > --- Imaging-1.1.7.orig/Sane/_sane.c ? ?2009-11-01 01:44:12.000000000 +0100 > +++ Imaging-1.1.7/Sane/_sane.c ? ?2010-12-28 02:17:38.626022947 +0100 > @@ -1162,8 +1162,9 @@ > ? ? { > ? ? ? return NULL; > ? ? } > - > + ?Py_BEGIN_ALLOW_THREADS > ? st=sane_get_devices(&devlist, local_only); > + ?Py_END_ALLOW_THREADS > ? if (st) return PySane_Error(st); > ? if (!(list = PyList_New(0))) > ? ? ? ? return NULL; > @@ -1191,7 +1192,9 @@ > ? ? rv = newSaneDevObject(); > ? ? if ( rv == NULL ) > ? ? ? ? return NULL; > + ? ?Py_BEGIN_ALLOW_THREADS > ? ? st = sane_open(name, &(rv->h)); > + ? ?Py_END_ALLOW_THREADS > ? ? if (st) > ? ? ? { > ? ? ? ? Py_DECREF(rv); > > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From fredrik at pythonware.com Fri Jan 7 17:32:02 2011 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 7 Jan 2011 17:32:02 +0100 Subject: [Image-SIG] PIL on Python 3? In-Reply-To: References: Message-ID: 2010/12/18 Rohan Pai : > The current version of PIL I installed is version?1.1.7 for Python 2.6, and > when I try to run it on Python 3, it doesn't work. I know the syntaxes like > print "Hello World"?and raw_input() are actually print ("Hello World") and > input(). I don't know?the other syntaxes that have changed, but if you can't > figure them out either, then you should try using?lib2to3 to convert PIL's > Python 2 code?to Python 3 code. Well, it's a bit harder than that: PIL depends heavily on binary string processing, which is one of the things that has undergone big changes in Python 3. There are a few manual ports out there, and I just submitted a bunch of changes to trunk that make PIL's Python code build and install cleanly under 2.3-3.2 (even if the functionality under 3.X is rather limited at this point...). From fredrik at pythonware.com Fri Jan 7 17:51:03 2011 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 7 Jan 2011 17:51:03 +0100 Subject: [Image-SIG] PIL In-Reply-To: References: Message-ID: 2010/12/1 Rajajothini Sureshkumar : > Hello, > > I would like to down load pill version 1.1.7 for Python2.6 . > But I have Python 2.7 on my pc. > I wonder this is not a problem If you're using PIL on Windows, you need the version that matches your Python installation. I've added the missing 2.7 link to the pythonware.com page, and you can also find all current binary installers here: http://effbot.org/downloads/#pil From fahy at chapman.edu Sun Jan 2 20:41:08 2011 From: fahy at chapman.edu (Michael Fahy) Date: Sun, 2 Jan 2011 11:41:08 -0800 Subject: [Image-SIG] PIL for python 2.7? Message-ID: <000601cbaab5$00f379b0$02da6d10$@chapman.edu> Will there be a version of PIL for Python 2.7? -------------- next part -------------- An HTML attachment was scrubbed... URL: From narendra at narendrasisodiya.com Fri Jan 7 18:04:11 2011 From: narendra at narendrasisodiya.com (Narendra Sisodiya) Date: Fri, 7 Jan 2011 22:34:11 +0530 Subject: [Image-SIG] Convert to Black and White to an image In-Reply-To: References: Message-ID: Can somebody give an easy way to convert a image into black and white using a given threshold.. Currently I am doing like this image=ImageOps.grayscale(image) for i in range(0,width): for j in range(0,height): if image.getpixel((i,j)) <= 200: image.putpixel((i,j),0) -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Fri Jan 7 18:11:26 2011 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 7 Jan 2011 18:11:26 +0100 Subject: [Image-SIG] PIL for python 2.7? In-Reply-To: <000601cbaab5$00f379b0$02da6d10$@chapman.edu> References: <000601cbaab5$00f379b0$02da6d10$@chapman.edu> Message-ID: 2011/1/2 Michael Fahy : > Will there be a version of PIL for Python 2.7? PIL 1.1.7 works well with 2.7, out of the box. Binaries for Windows has been available under the "additional downloads" link on http://pythonware.com/products/pil/ for some time, and I just added the missing link to the page itself. From fredrik at pythonware.com Fri Jan 7 18:21:23 2011 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 7 Jan 2011 18:21:23 +0100 Subject: [Image-SIG] Convert to Black and White to an image In-Reply-To: References: Message-ID: 2011/1/7 Narendra Sisodiya : > Can somebody give an easy way to convert a image into black and white using > a given threshold.. > > Currently I am doing like this > > ??? image=ImageOps.grayscale(image) > ??? for i in range(0,width): > ??? ??? for j in range(0,height): > ??? ??? ??? if image.getpixel((i,j)) <= 200: > ??? ??? ??? ??? image.putpixel((i,j),0) The Image class provides a bunch of primitives that can be used for pixel- and region-wise operations. To threshold, use the "point" method which maps an image through a lookup table. First, load the image and convert to grayscale: >>> from PIL import Image >>> im = Image.open("Images/lena.ppm") >>> im = im.convert("L") # make it grayscale >>> im Then, create a 256-entry lookup table and use it with the point method: >>> lut = [255 if v > 128 else 0 for v in range(256)] >>> out = im.point(lut) >>> out >>> out.getcolors() [(6261, 0), (10123, 255)] By default, point preserves the pixel mode, but you can map and convert in one step when going from L to 1: >>> out = im.point(lut, "1") >>> out From narendra at narendrasisodiya.com Fri Jan 7 19:00:50 2011 From: narendra at narendrasisodiya.com (Narendra Sisodiya) Date: Fri, 7 Jan 2011 23:30:50 +0530 Subject: [Image-SIG] Convert to Black and White to an image In-Reply-To: References: Message-ID: On Fri, Jan 7, 2011 at 10:51 PM, Fredrik Lundh wrote: > 2011/1/7 Narendra Sisodiya : > > Can somebody give an easy way to convert a image into black and white > using > > a given threshold.. > > > > Currently I am doing like this > > > > image=ImageOps.grayscale(image) > > for i in range(0,width): > > for j in range(0,height): > > if image.getpixel((i,j)) <= 200: > > image.putpixel((i,j),0) > > The Image class provides a bunch of primitives that can be used for > pixel- and region-wise operations. To threshold, use the "point" > method which maps an image through a lookup table. > > First, load the image and convert to grayscale: > > >>> from PIL import Image > >>> im = Image.open("Images/lena.ppm") > >>> im = im.convert("L") # make it grayscale > >>> im > > > Then, create a 256-entry lookup table and use it with the point method: > > >>> lut = [255 if v > 128 else 0 for v in range(256)] > >>> out = im.point(lut) > >>> out > > >>> out.getcolors() > [(6261, 0), (10123, 255)] > > By default, point preserves the pixel mode, but you can map and > convert in one step when going from L to 1: > > >>> out = im.point(lut, "1") > >>> out > > > > Thanks a lot, This is what i wanted to have. I was expecting some predefined method. In Octave I was using image to balckNwhite conversion method which was having threshold as parameter. Thanks, I will use it., I was not aware of point translation method. -- ??????????????????????????? ? Narendra Sisodiya ? http://narendrasisodiya.com ??????????????????????????? -------------- next part -------------- An HTML attachment was scrubbed... URL: From narendra at narendrasisodiya.com Fri Jan 7 19:14:31 2011 From: narendra at narendrasisodiya.com (Narendra Sisodiya) Date: Fri, 7 Jan 2011 23:44:31 +0530 Subject: [Image-SIG] Locate The Center of WhiteDot from a Image Message-ID: Dear All, the given image has only two level. Pixel are either black or white. See this image - http://www.flickr.com/photos/nsisodiya/5333747510/ Now, I want to locate the center of whitedot. This can be done by locating the bounding box of white dot. I have used following algorithm https://gist.github.com/769847 This Code Look for bounding box which I am calculating by scanning each row and column one by one. If I am finding any white pixel, I am including it into my bounding box. After this, I can calculating mid of box. Now, Here is the problem with the code. 1) there may a change that 2 or more WhiteDOT may present. One is Big whiedot and other are very smaller whitedot(just 2-3 pixel) near to this Big whitedot. So, I am getting bigger bounding box. I want to get center based on density of whitepixel. basically center where white pixel density is very high. Also, I am applying this algorithm on every frame taken from camera at 2fps. So I want a high speed algorithm. PIL must be having some function or trick to do it. -- ??????????????????????????? ? Narendra Sisodiya ? http://narendrasisodiya.com ??????????????????????????? -------------- next part -------------- An HTML attachment was scrubbed... URL: From Chris.Barker at noaa.gov Fri Jan 7 21:14:17 2011 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Fri, 07 Jan 2011 12:14:17 -0800 Subject: [Image-SIG] Locate The Center of WhiteDot from a Image In-Reply-To: References: Message-ID: <4D277419.1010908@noaa.gov> On 1/7/11 10:14 AM, Narendra Sisodiya wrote: > This Code Look for bounding box which I am calculating by scanning each > row and column one by one. If I am finding any white pixel, I am > including it into my bounding box. > 1) there may a change that 2 or more WhiteDOT may present. One is Big > whiedot and other are very smaller whitedot(just 2-3 pixel) near to this > Big whitedot. Not sure about this one off the top of myhead, but I"d suspect some smoothing may take care of it. > I am applying this > algorithm on every frame taken from camera at 2fps. So I want a high > speed algorithm. PIL must be having some function or trick to do it. The Image..getbbox() method should do it. If you need more math, numpy can help. Somethign like: a = np.asarray(PIL_image) background_color = 0 rows, cols = np.where(a <> background_color) # background color a uint32 BB = (rows.min(), rows.max(), cols.min(), cols.max()) -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 adamj at captainweirdbeard.com Fri Jan 7 21:19:13 2011 From: adamj at captainweirdbeard.com (Johnson, Adam) Date: Fri, 7 Jan 2011 15:19:13 -0500 Subject: [Image-SIG] IOError: decoder zip not available Message-ID: Hello! I am trying to run an image processing script on a new server under CentOS 5.4. I have compiled and installed PIL 1.1.7 to run with Python 2.7.1. The compile went fine. All libraries (except TKInter) were found. All 57 tests were passed by the test script. When I try to run my script, however, I get the following error: IOError: decoder zip not available I presume that this either has to do with zlib or libjpeg but, as I said, these libraries are installed and have been successfully used by other apps on the server such as php 5.3.3 and ImageMagick. Can someone help me find out what is not working and how to fix it? I have confirmed that sys.path is looking in the right directories for the libraries. I have also confirmed, by enabling verbose mode and importing the Image module in IDLE. Everything seems to look right but, still, it cannot find decoder zip. Here is the output from the script I am using: The python sys path is: ['/usr/local/mcutil/haven/minecraft-overviewer', '/usr/local/lib/python2.7', '/usr/local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/encodings', '/usr/local/mcutil/haven/minecraft-overviewer', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7/plat-linux2', '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', '/usr/local/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/site-packages/PIL', '/usr/local/lib/python2.7/site-packages/numpy'] Traceback (most recent call last): File "/usr/local/mcutil/haven/minecraft-overviewer/gmap.py", line 40, in import world File "/usr/local/mcutil/haven/minecraft-overviewer/world.py", line 28, in import chunk File "/usr/local/mcutil/haven/minecraft-overviewer/chunk.py", line 25, in import textures File "/usr/local/mcutil/haven/minecraft-overviewer/textures.py", line 116, in terrain_images = _split_terrain(_get_terrain_image()) File "/usr/local/mcutil/haven/minecraft-overviewer/textures.py", line 110, in _split_terrain Image.BICUBIC) File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 1615, in transform im.__transformer((0, 0)+size, self, method, data, resample, fill) File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 1658, in __transformer image.load() File "/usr/local/lib/python2.7/site-packages/PIL/ImageFile.py", line 189, in load d = Image._getdecoder(self.mode, d, a, self.decoderconfig) File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 385, in _getdecoder raise IOError("decoder %s not available" % decoder_name) IOError: decoder zip not available I have re-installed the zlib and zlib-devel packages via yum with no effect. I have rebuilt PIL several times and received positive results from the build process but no change in behavior. (Here is a copy of the output of setup.py: [root at mc2 Imaging-1.1.7]# python setup.py install running install running build running build_py running build_ext -------------------------------------------------------------------- PIL 1.1.7 SETUP SUMMARY -------------------------------------------------------------------- version 1.1.7 platform linux2 2.7.1 (r271:86832, Dec 9 2010, 10:13:10) [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] -------------------------------------------------------------------- *** TKINTER support not available --- JPEG support available --- ZLIB (PNG/ZIP) support available --- FREETYPE2 support available --- LITTLECMS support available -------------------------------------------------------------------- To add a missing option, make sure you have the required library, and set the corresponding ROOT variable in the setup.py script. To check the build, run the selftest.py script. running build_scripts running install_lib running install_scripts changing mode of /usr/local/bin/pildriver.py to 755 changing mode of /usr/local/bin/pilfile.py to 755 changing mode of /usr/local/bin/pilconvert.py to 755 changing mode of /usr/local/bin/pilfont.py to 755 changing mode of /usr/local/bin/pilprint.py to 755 running install_egg_info Removing /usr/local/lib/python2.7/site-packages/PIL/PIL-1.1.7-py2.7.egg-info Writing /usr/local/lib/python2.7/site-packages/PIL/PIL-1.1.7-py2.7.egg-info creating /usr/local/lib/python2.7/site-packages/PIL.pth I have scoured dozens of threads relating to the same problem. Most of them yeilded terse, dummy answers like not having the devel packages installed for the dependencies. This is obviously not the case here. [root at mc2 Imaging-1.1.7]# yum list installed |grep zlib zlib.x86_64 1.2.3-3 installed zlib-devel.x86_64 1.2.3-3 installed [root at mc2 Imaging-1.1.7]# yum list installed |grep jpeg libjpeg.x86_64 6b-37 installed libjpeg-devel.x86_64 6b-37 installed [root at mc2 Imaging-1.1.7]# yum list installed |grep png libpng.x86_64 2:1.2.10-7.1.el5_5.3 installed libpng-devel.x86_64 2:1.2.10-7.1.el5_5.3 installed [root at mc2 Imaging-1.1.7]# yum list installed |grep tiff libtiff.x86_64 3.8.2-7.el5_5.5 installed libtiff-devel.x86_64 3.8.2-7.el5_5.5 installed [root at mc2 Imaging-1.1.7]# yum list installed |grep freetype freetype.x86_64 2.2.1-28.el5_5.1 installed freetype-devel.x86_64 2.2.1-28.el5_5.1 installed [root at mc2 Imaging-1.1.7]# yum list installed |grep lcms lcms.x86_64 1.18-0.1.beta1.el5_3.2 installed lcms-devel.x86_64 1.18-0.1.beta1.el5_3.2 installed I also tried digging through the archives of this mailing list but I cannot find a search tool. I went back several weeks, chronologically and did not find any mention of this error message. My apologies if it is here somewhere and I did not know how to find it. Any help with where to look, how to troubleshoot, or even an answer would be greatly appreciated. Thanks in advance! Hitting his head against the wall, Adam :) -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Fri Jan 7 21:33:40 2011 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 7 Jan 2011 21:33:40 +0100 Subject: [Image-SIG] IOError: decoder zip not available In-Reply-To: References: Message-ID: The setup output looks fine, so my guess is that your script isn't picking up the same build as the one you get when you run the test script. Running the following command in your PIL build directory and your script directory will tell you what files Python are using: python -c "import _imaging; print _imaging.__file__" 2011/1/7 Johnson, Adam : > Hello! > > I am trying to run an image processing script on a new server under CentOS > 5.4. I have compiled and installed PIL 1.1.7 to run with Python 2.7.1. The > compile went fine. All libraries (except TKInter) were found. All 57 tests > were passed by the test script. > > When I try to run my script, however, I get the following error: > > IOError: decoder zip not available > > I presume that this either has to do with zlib or libjpeg but, as I said, > these libraries are installed and have been successfully used by other apps > on the server such as php 5.3.3 and ImageMagick. > > Can someone help me find out what is not working and how to fix it? > > I have confirmed that sys.path is looking in the right directories for the > libraries. I have also confirmed, by enabling verbose mode and importing the > Image module in IDLE. > > Everything seems to look right but, still, it cannot find decoder zip. Here > is the output from the script I am using: > > > The python sys path is: > ['/usr/local/mcutil/haven/minecraft-overviewer', '/usr/local/lib/python2.7', > '/usr/local/lib/python2.7/site-packages', > '/usr/local/lib/python2.7/encodings', > '/usr/local/mcutil/haven/minecraft-overviewer', > '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7/plat-linux2', > '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', > '/usr/local/lib/python2.7/lib-dynload', > '/usr/local/lib/python2.7/site-packages/PIL', > '/usr/local/lib/python2.7/site-packages/numpy'] > Traceback (most recent call last): > ? File "/usr/local/mcutil/haven/minecraft-overviewer/gmap.py", line 40, in > > ??? import world > ? File "/usr/local/mcutil/haven/minecraft-overviewer/world.py", line 28, in > > ??? import chunk > ? File "/usr/local/mcutil/haven/minecraft-overviewer/chunk.py", line 25, in > > ??? import textures > ? File "/usr/local/mcutil/haven/minecraft-overviewer/textures.py", line 116, > in > ??? terrain_images = _split_terrain(_get_terrain_image()) > ? File "/usr/local/mcutil/haven/minecraft-overviewer/textures.py", line 110, > in _split_terrain > ??? Image.BICUBIC) > ? File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 1615, in > transform > ??? im.__transformer((0, 0)+size, self, method, data, resample, fill) > ? File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 1658, in > __transformer > ??? image.load() > ? File "/usr/local/lib/python2.7/site-packages/PIL/ImageFile.py", line 189, > in load > ??? d = Image._getdecoder(self.mode, d, a, self.decoderconfig) > ? File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 385, in > _getdecoder > ??? raise IOError("decoder %s not available" % decoder_name) > IOError: decoder zip not available > > > I have re-installed the zlib and zlib-devel packages via yum with no effect. > I have rebuilt PIL several times and received positive results from the > build process but no change in behavior. (Here is a copy of the output of > setup.py: > > > [root at mc2 Imaging-1.1.7]# python setup.py install > running install > running build > running build_py > running build_ext > -------------------------------------------------------------------- > PIL 1.1.7 SETUP SUMMARY > -------------------------------------------------------------------- > version?????? 1.1.7 > platform????? linux2 2.7.1 (r271:86832, Dec? 9 2010, 10:13:10) > ????????????? [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] > -------------------------------------------------------------------- > *** TKINTER support not available > --- JPEG support available > --- ZLIB (PNG/ZIP) support available > --- FREETYPE2 support available > --- LITTLECMS support available > -------------------------------------------------------------------- > To add a missing option, make sure you have the required > library, and set the corresponding ROOT variable in the > setup.py script. > > To check the build, run the selftest.py script. > running build_scripts > running install_lib > running install_scripts > changing mode of /usr/local/bin/pildriver.py to 755 > changing mode of /usr/local/bin/pilfile.py to 755 > changing mode of /usr/local/bin/pilconvert.py to 755 > changing mode of /usr/local/bin/pilfont.py to 755 > changing mode of /usr/local/bin/pilprint.py to 755 > running install_egg_info > Removing /usr/local/lib/python2.7/site-packages/PIL/PIL-1.1.7-py2.7.egg-info > Writing /usr/local/lib/python2.7/site-packages/PIL/PIL-1.1.7-py2.7.egg-info > creating /usr/local/lib/python2.7/site-packages/PIL.pth > > > I have scoured dozens of threads relating to the same problem. Most of them > yeilded terse, dummy answers like not having the devel packages installed > for the dependencies. This is obviously not the case here. > > > [root at mc2 Imaging-1.1.7]# yum list installed |grep zlib > zlib.x86_64?????????????????????????????? 1.2.3-3 > installed > zlib-devel.x86_64???????????????????????? 1.2.3-3 > installed > [root at mc2 Imaging-1.1.7]# yum list installed |grep jpeg > libjpeg.x86_64??????????????????????????? 6b-37 > installed > libjpeg-devel.x86_64????????????????????? 6b-37 > installed > [root at mc2 Imaging-1.1.7]# yum list installed |grep png > libpng.x86_64???????????????????????????? 2:1.2.10-7.1.el5_5.3 > installed > libpng-devel.x86_64?????????????????????? 2:1.2.10-7.1.el5_5.3 > installed > [root at mc2 Imaging-1.1.7]# yum list installed |grep tiff > libtiff.x86_64??????????????????????????? 3.8.2-7.el5_5.5 > installed > libtiff-devel.x86_64????????????????????? 3.8.2-7.el5_5.5 > installed > [root at mc2 Imaging-1.1.7]# yum list installed |grep freetype > freetype.x86_64?????????????????????????? 2.2.1-28.el5_5.1 > installed > freetype-devel.x86_64???????????????????? 2.2.1-28.el5_5.1 > installed > [root at mc2 Imaging-1.1.7]# yum list installed |grep lcms > lcms.x86_64?????????????????????????????? 1.18-0.1.beta1.el5_3.2 > installed > lcms-devel.x86_64???????????????????????? 1.18-0.1.beta1.el5_3.2 > installed > > > I also tried digging through the archives of this mailing list but I cannot > find a search tool. I went back several weeks, chronologically and did not > find any mention of this error message. My apologies if it is here somewhere > and I did not know how to find it. > > Any help with where to look, how to troubleshoot, or even an answer would be > greatly appreciated. > > Thanks in advance! > Hitting his head against the wall, > Adam? :) > > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > From garrettdaviscpa at gmail.com Sat Jan 8 00:41:26 2011 From: garrettdaviscpa at gmail.com (Garrett Davis) Date: Fri, 07 Jan 2011 15:41:26 -0800 Subject: [Image-SIG] Locate The Center of WhiteDot from a Image In-Reply-To: References: Message-ID: Narendra Sisodiya wrote: > Now, I want to locate the center of whitedot. > I want to get center based on density of whitepixel. basically center where white pixel density is very high. > Also, I am applying this algorithm on every frame taken from camera at 2fps. So I want a high speed algorithm. I would recommend using the getbbox() method, as Christopher Barker has already pointed out, along with one of these two techniques: a) shrinking the size of the image to, say, 16x16, so that the smaller 'noise' dots disappear or turn into small grey dots, and then apply, or re-apply, the 'point' method discussed in an earlier thread to erase them; b) using a 'centroid' algorithm to determine a 'center of mass' which would not be affected much by small amounts of 'noise'. Fred Lundh had kindly provided this list with such an algorithm, here: http://mail.python.org/pipermail/image-sig/2008-August/005149.html I use both methods in my application - detection of cars on a racetrack for timing and scoring purposes - with good results, and with no performance problems when processing larger images at 10 frames/second. Garrett Davis From adamj at captainweirdbeard.com Sat Jan 8 02:10:17 2011 From: adamj at captainweirdbeard.com (Adam M. Johnson) Date: Fri, 07 Jan 2011 20:10:17 -0500 Subject: [Image-SIG] IOError: decoder zip not available In-Reply-To: References: Message-ID: <4D27B979.9070404@captainweirdbeard.com> Thank you for the troubleshooting technique! I am still getting oriented with Python. Sadly, this did not reveal anything telling. I ran this command as root and as the user who will be running it. I ran from the Imaging build directory, from the directory in which the script is located and from the user's home directory. All came back with the same path to the library file: /usr/local/lib/python2.7/site-packages/PIL/_imaging.so This is what I would expect when things are working correctly. Is there anything else I can check? Thanks for your help. Adam On 1/7/2011 3:33 PM, Fredrik Lundh wrote: > python -c "import _imaging; print _imaging.__file__" From chris.mit7 at gmail.com Sat Jan 8 02:24:34 2011 From: chris.mit7 at gmail.com (Chris Mitchell) Date: Fri, 7 Jan 2011 20:24:34 -0500 Subject: [Image-SIG] Locate The Center of WhiteDot from a Image In-Reply-To: References: Message-ID: use numpy. This is taken from a data analysis program I wrote for analyzing single molecule fluorescent events. So should be similar to what you want, a white spot of a given intensity surrounded by noise. array being your image stored as a numpy array, threshhold is your value to be greater then self.thresharray = np.where(array>threshhold,array, 0) for i,v in np.ndenumerate(self.thresharray): # print i,v if v > 0: #find the outside to draw our box around, look around and color the outside of it green for k in xrange(-2,2): for j in xrange(-2,2): try: if self.thresharray[i[0]-k,i[1]-j] == 0: picture.SetRGB(i[1]-j,i[0]-k,0,255,0) except wx._core.PyAssertionError: pass except IndexError: pass On Fri, Jan 7, 2011 at 6:41 PM, Garrett Davis wrote: > ?Narendra Sisodiya wrote: > >> Now, I want to locate the center of whitedot. >> I want to get center based on density of whitepixel. basically center >> where white pixel density is very high. >> Also, I am applying this algorithm on every frame taken from camera at >> 2fps. So I want a high speed algorithm. > > I would recommend using the getbbox() method, as Christopher Barker has > already pointed out, along with one of these two techniques: > > a) shrinking the size of the image to, say, 16x16, so that the smaller > 'noise' dots disappear or turn into small grey dots, and then apply, or > re-apply, the 'point' method discussed in an earlier thread to erase them; > > b) using a 'centroid' algorithm to determine a 'center of mass' which would > not be affected much by small amounts of 'noise'. > > Fred Lundh had kindly provided this list with such an algorithm, here: > http://mail.python.org/pipermail/image-sig/2008-August/005149.html > > I use both methods in my application - detection of cars on a racetrack for > timing and scoring purposes - with good results, and with no performance > problems when processing larger images at 10 frames/second. > > Garrett Davis > > > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From fredrik at pythonware.com Sat Jan 8 02:41:39 2011 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 8 Jan 2011 02:41:39 +0100 Subject: [Image-SIG] ANN: PIL 1.2 pre-alpha (January 8, 2011) Message-ID: A pre-alpha snapshot of the upcoming PIL 1.2 release is now available from: http://hg.effbot.org/pil-2009-raclette/downloads/PIL-1.2a0-20110108.tar.gz or via Mercurial, from https://bitbucket.org/effbot/pil-2009-raclette I've decided to abandon the planned 1.1.8 release, including the rough and still unreleased 3.X port of 1.1.7+. Instead, the new plan is to provide a single code base for both Python 2.X and 3.X, and most of the changes in 1.2 will affect internal architecture and packaging only (I do have some very interesting contributions that are pending integration, though). Support for very old versions have been dropped, and so has the support for importing from the standard namespace; PIL now lives in the PIL namespace only. Some long-deprecated methods have also been removed, but everything else should work as usual. The source kit has been built and tested with Python 2.3, 2.4, 2.5, 2.6, and 2.7. It also builds under Python 3.1 and 3.2 beta, even if the functionality is currently *very* limited under Python 3.X. $ tar xvfz PIL-1.2a0-20110108.tar.gz ... $ cd PIL-1.2a0/ $ python3 setup.py install --prefix . ... $ cd lib/python3.1/site-packages/ $ python3 Python 3.1.2 (r312:79147, Apr 15 2010, 15:35:48) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from PIL import Image >>> im = Image.open("../../../Images/lena.png") >>> im >>> im.load() # only works under 2.X in this release From fredrik at pythonware.com Sat Jan 8 02:54:19 2011 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 8 Jan 2011 02:54:19 +0100 Subject: [Image-SIG] IOError: decoder zip not available In-Reply-To: <4D27B979.9070404@captainweirdbeard.com> References: <4D27B979.9070404@captainweirdbeard.com> Message-ID: Oh, I just noticed that your mail included the "SETUP SUMMARY" but not the selftest summary. Did you install the missing libraries after an initial failed build? It could be that distutils didn't rebuild the necessary files for you... For a quick sanity check, in your build directory, do: $ ls -l build/*/libImaging/*.o and check that the ZipEncode and ZipDecode object files aren't suspiciously tiny compared to the rest of the modules (they're still built if zip support is disabled, but are mostly empty in that case). If this seems to be the case, or if you just want to be sure, nuke the build directory and run setup again. You can use build_ext -i to build just the extensions in the current directory: $ rm -rf build $ python2.7 setup.py build_ext -i $ python2.7 >>> import _imaging >>> dir(_imaging) ... look for zip functions ... or do: >>> [(k, v) for k, v in vars(_imaging).items() if k[0] == 'z'] [('zip_decoder', ), ('zlib_version', '1.2.3.3'), ('zip_encoder', )] If your result matches the sample output above, run setup.py install and make sure that the _imaging.so module installed under site-packages matches the one that was built locally. 2011/1/8 Adam M. Johnson : > ?Thank you for the troubleshooting technique! I am still getting oriented > with Python. Sadly, this did not reveal anything telling. I ran this command > as root and as the user who will be running it. I ran from the Imaging build > directory, from the directory in which the script is located and from the > user's home directory. All came back with the same path to the library file: > > /usr/local/lib/python2.7/site-packages/PIL/_imaging.so > > This is what I would expect when things are working correctly. > > Is there anything else I can check? > > Thanks for your help. > Adam > > > > On 1/7/2011 3:33 PM, Fredrik Lundh wrote: >> >> python -c "import _imaging; print _imaging.__file__" > From adamj at captainweirdbeard.com Sat Jan 8 04:07:16 2011 From: adamj at captainweirdbeard.com (Adam M. Johnson) Date: Fri, 07 Jan 2011 22:07:16 -0500 Subject: [Image-SIG] IOError: decoder zip not available In-Reply-To: References: <4D27B979.9070404@captainweirdbeard.com> Message-ID: <4D27D4E4.4090604@captainweirdbeard.com> Ah- I think we are getting somewhere... The ZipEncode and ZipDecode files were not in the build branch at all. I rmvd the build directory and rebuilt again according to your instructions. I got the all-is-well summary but still no ZipEncode/ZipDecode files created in the build directory. In fact, the build directory did not return. I then ran selftest.py and all 57 tests passed! The build and the selftest ran suspiciously quick, though: [root at mc2 Imaging-1.1.7]# ls -al build ls: build: No such file or directory [root at mc2 Imaging-1.1.7]# python2.7 setup.py build_ext -i running build_ext -------------------------------------------------------------------- PIL 1.1.7 SETUP SUMMARY -------------------------------------------------------------------- version 1.1.7 platform linux2 2.7.1 (r271:86832, Dec 9 2010, 10:13:10) [GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] -------------------------------------------------------------------- *** TKINTER support not available --- JPEG support available --- ZLIB (PNG/ZIP) support available --- FREETYPE2 support available --- LITTLECMS support available -------------------------------------------------------------------- To add a missing option, make sure you have the required library, and set the corresponding ROOT variable in the setup.py script. To check the build, run the selftest.py script. [root at mc2 Imaging-1.1.7]# python2.7 selftest.py -------------------------------------------------------------------- PIL 1.1.7 TEST SUMMARY -------------------------------------------------------------------- Python modules loaded from ./PIL Binary modules loaded from ./PIL -------------------------------------------------------------------- --- PIL CORE support ok *** TKINTER support not installed --- JPEG support ok --- ZLIB (PNG/ZIP) support ok --- FREETYPE2 support ok --- LITTLECMS support ok -------------------------------------------------------------------- Running selftest: --- 57 tests passed. Also, it does look like the built imaging library is not the same as the one installed in the PIL branch under ...python2.7/site-packages. Do you think if I: rm -rf /usr/local/lib/python2.7/site-packages/PIL* ..and then restore the original source package and start the build from scratch, it will clear things up? (Actually, I am pretty sure I have already done this but who knows what might have transpired in-between last time.) Thanks! Adam On 1/7/2011 8:54 PM, Fredrik Lundh wrote: > Oh, I just noticed that your mail included the "SETUP SUMMARY" but not > the selftest summary. Did you install the missing libraries after an > initial failed build? It could be that distutils didn't rebuild the > necessary files for you... > > For a quick sanity check, in your build directory, do: > > $ ls -l build/*/libImaging/*.o > > and check that the ZipEncode and ZipDecode object files aren't > suspiciously tiny compared to the rest of the modules (they're still > built if zip support is disabled, but are mostly empty in that case). > > If this seems to be the case, or if you just want to be sure, nuke the > build directory and run setup again. You can use build_ext -i to > build just the extensions in the current directory: > > $ rm -rf build > $ python2.7 setup.py build_ext -i > $ python2.7 >>>> import _imaging >>>> dir(_imaging) > ... look for zip functions ... or do: >>>> [(k, v) for k, v in vars(_imaging).items() if k[0] == 'z'] > [('zip_decoder',), ('zlib_version', > '1.2.3.3'), ('zip_encoder',)] > > If your result matches the sample output above, run setup.py install > and make sure that the _imaging.so module installed under > site-packages matches the one that was built locally. > > > > 2011/1/8 Adam M. Johnson: >> Thank you for the troubleshooting technique! I am still getting oriented >> with Python. Sadly, this did not reveal anything telling. I ran this command >> as root and as the user who will be running it. I ran from the Imaging build >> directory, from the directory in which the script is located and from the >> user's home directory. All came back with the same path to the library file: >> >> /usr/local/lib/python2.7/site-packages/PIL/_imaging.so >> >> This is what I would expect when things are working correctly. >> >> Is there anything else I can check? >> >> Thanks for your help. >> Adam >> >> >> >> On 1/7/2011 3:33 PM, Fredrik Lundh wrote: >>> python -c "import _imaging; print _imaging.__file__" From narendra at narendrasisodiya.com Sat Jan 8 05:26:04 2011 From: narendra at narendrasisodiya.com (Narendra Sisodiya) Date: Sat, 8 Jan 2011 09:56:04 +0530 Subject: [Image-SIG] Locate The Center of WhiteDot from a Image In-Reply-To: <4D277419.1010908@noaa.gov> References: <4D277419.1010908@noaa.gov> Message-ID: On Sat, Jan 8, 2011 at 1:44 AM, Christopher Barker wrote: > On 1/7/11 10:14 AM, Narendra Sisodiya wrote: > >> This Code Look for bounding box which I am calculating by scanning each >> row and column one by one. If I am finding any white pixel, I am >> including it into my bounding box. >> > > 1) there may a change that 2 or more WhiteDOT may present. One is Big >> whiedot and other are very smaller whitedot(just 2-3 pixel) near to this >> Big whitedot. >> > > Not sure about this one off the top of myhead, but I"d suspect some > smoothing may take care of it. > > > I am applying this >> algorithm on every frame taken from camera at 2fps. So I want a high >> speed algorithm. PIL must be having some function or trick to do it. >> > > The Image..getbbox() method should do it. > > Thanks, I tried getbbox on wrong image. Now I am using getbbox and I am getting proper result that too very fast. > If you need more math, numpy can help. Somethign like: > > a = np.asarray(PIL_image) > background_color = 0 > rows, cols = np.where(a <> background_color) # background color a uint32 > BB = (rows.min(), rows.max(), cols.min(), cols.max()) > I am unable to get what that code means ? May you explain how I can use above code with getbbox ? Or the above code using NumPy is alternate of getbbox method ? IF yes, then which will be the faster ? PS: I have looked at centroid algorithm, It is again going at pixel level and that will be slow. My application will become better with faster centroid algorithm. Also I have another question ! I am grabbing image from camera using opencv-python. How we can compare python PIL with OpenCV ? My guess that PIL will is faster then opencv library ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From narendra at narendrasisodiya.com Sat Jan 8 06:44:39 2011 From: narendra at narendrasisodiya.com (Narendra Sisodiya) Date: Sat, 8 Jan 2011 11:14:39 +0530 Subject: [Image-SIG] ImageCapture from WebCam Message-ID: I am using following code. I am using opencv, It is Okey or is there any scope for improvement ! Anything faster ? I am processing images using PIL import Image import sys import opencv import time #this is important for capturing/displaying images from opencv import highgui camera = highgui.cvCreateCameraCapture(3) def get_image(): im = highgui.cvQueryFrame(camera) # Add the line below if you need it (Ubuntu 8.04+) #im = opencv.cvGetMat(im) #convert Ipl image to PIL image return opencv.adaptors.Ipl2PIL(im) -- ??????????????????????????? ? Narendra Sisodiya ? http://narendrasisodiya.com ??????????????????????????? -------------- next part -------------- An HTML attachment was scrubbed... URL: From narendra at narendrasisodiya.com Sat Jan 8 07:54:14 2011 From: narendra at narendrasisodiya.com (Narendra Sisodiya) Date: Sat, 8 Jan 2011 12:24:14 +0530 Subject: [Image-SIG] Help needed in Image Rectification. Message-ID: I want your guidance in following problem. I have a Rectangle with a known height and width. (aspect ration is fixed) It has a plane surface. Something like cardboard. Or Rectangle Drawn on wall. I am now taking image of this rectangle from webcam. After taking image of this rectangle from webcam, rectangle occupy small area on image and that is in a form of quadrilateral inside image. I can calculate the XY location of Rectangle from image , So I have Following Matrix Co-ordinate on image -> Actual real world co-ordinate _______________________________________ X1 Y1 -> 0 , 0 X2 Y2 -> width, 0 X3 Y3 -> 0, height X4 Y4 -> width, height ________________________________________ width and height of rectangle is known because I can measure this real object X1 Y1 to X4 Y4 are 4 co-ordinate of this object in image. Because it is a projective transformation, this will be in a shaped of quadrilateral. Now I want to know a matrix operation or any formula, by which I can convert a given X Y of image into corresponding co-ordinate on rectangle. I think, this is known as homography. seeing on web, i can find complex description and formulas which i am unable to understand. May you give me exact formula for how to do it. Thanks ! -- ??????????????????????????? ? Narendra Sisodiya ? http://narendrasisodiya.com ??????????????????????????? -------------- next part -------------- An HTML attachment was scrubbed... URL: From narendra at narendrasisodiya.com Sat Jan 8 08:02:48 2011 From: narendra at narendrasisodiya.com (Narendra Sisodiya) Date: Sat, 8 Jan 2011 12:32:48 +0530 Subject: [Image-SIG] Help needed in Image Rectification. In-Reply-To: References: Message-ID: On Sat, Jan 8, 2011 at 12:24 PM, Narendra Sisodiya < narendra at narendrasisodiya.com> wrote: > I want your guidance in following problem. > > I have a Rectangle with a known height and width. (aspect ration is fixed) > It has a plane surface. Something like cardboard. Or Rectangle Drawn on > wall. > I am now taking image of this rectangle from webcam. > After taking image of this rectangle from webcam, rectangle occupy small > area on image and that is in a form of quadrilateral inside image. I can > calculate the XY location of Rectangle from image , So I have Following > Matrix > > Co-ordinate on image -> Actual real world co-ordinate > _______________________________________ > X1 Y1 -> 0 , 0 > X2 Y2 -> width, 0 > X3 Y3 -> 0, height > X4 Y4 -> width, height > ________________________________________ > > width and height of rectangle is known because I can measure this real > object > X1 Y1 to X4 Y4 are 4 co-ordinate of this object in image. Because it is a > projective transformation, this will be in a shaped of quadrilateral. > > > Now I want to know a matrix operation or any formula, by which I can > convert a given X Y of image into corresponding co-ordinate on rectangle. > I think, this is known as homography. seeing on web, i can find complex > description and formulas which i am unable to understand. > > May you give me exact formula for how to do it. > > Thanks ! > > Also - This code will be useful - I am unable to understand it fully - But i guess , this is doing exactly what i want. http://wiiwhiteboard.cvs.sourceforge.net/viewvc/wiiwhiteboard/source/linux/perspective.py?view=markup -------------- next part -------------- An HTML attachment was scrubbed... URL: From adamj at captainweirdbeard.com Sat Jan 8 14:42:20 2011 From: adamj at captainweirdbeard.com (Adam M. Johnson) Date: Sat, 08 Jan 2011 08:42:20 -0500 Subject: [Image-SIG] IOError: decoder zip not available In-Reply-To: References: <4D27B979.9070404@captainweirdbeard.com> Message-ID: <4D2869BC.9000403@captainweirdbeard.com> Alright, it looks like it is working now. Here is what I did to rebuild and re-install PIL from scratch: # rm -rf /usr/local/lib/python2.7/site-packages/PIL* # rm -rf /src/Imaging-1.1.7 # cd /src # tar -xvzf Imaging-1.1.7.tar.gz # cd Imaging-1.1.7 # python2.7 setup.py build_ext -i # python2.7 selftest.py # python2.7 >>> import _imaging >>> [(k, v) for k, v in vars(_imaging).items() if k[0] == 'z'] #Confirmed that the zip decoder libs were there # python2.7 setup.py install In trying to retrace my steps to figure out where I went wrong, I think I used the "simple" install method listed at the top of the README (0. If you're in a hurry...) first. All the supporting libraries were in place in their standard locations so I figured I was safe for the simple install. Note to self...) ;) Anyway, i remember that this failed to find 3/5 libraries. It appears that the build process does not check /usr/lib64 by default (which is one of the default locations for libraries on a Linux x64 system. So, I updated setup.py with the necessary paths to the libs. I believe I then tried a "setup.py clean" command to reset the build directories... Something along those lines. In any case, it appears I did not get the original failed install out of the system when I thought I had and that is what was tripping me up all along. Thank you very much for your help! My script is chugging away now. :) Enjoy the weekend! -Adam On 1/7/2011 8:54 PM, Fredrik Lundh wrote: > Oh, I just noticed that your mail included the "SETUP SUMMARY" but not > the selftest summary. Did you install the missing libraries after an > initial failed build? It could be that distutils didn't rebuild the > necessary files for you... > > For a quick sanity check, in your build directory, do: > > $ ls -l build/*/libImaging/*.o > > and check that the ZipEncode and ZipDecode object files aren't > suspiciously tiny compared to the rest of the modules (they're still > built if zip support is disabled, but are mostly empty in that case). > > If this seems to be the case, or if you just want to be sure, nuke the > build directory and run setup again. You can use build_ext -i to > build just the extensions in the current directory: > > $ rm -rf build > $ python2.7 setup.py build_ext -i > $ python2.7 >>>> import _imaging >>>> dir(_imaging) > ... look for zip functions ... or do: >>>> [(k, v) for k, v in vars(_imaging).items() if k[0] == 'z'] > [('zip_decoder',), ('zlib_version', > '1.2.3.3'), ('zip_encoder',)] > > If your result matches the sample output above, run setup.py install > and make sure that the _imaging.so module installed under > site-packages matches the one that was built locally. > > > > 2011/1/8 Adam M. Johnson: >> Thank you for the troubleshooting technique! I am still getting oriented >> with Python. Sadly, this did not reveal anything telling. I ran this command >> as root and as the user who will be running it. I ran from the Imaging build >> directory, from the directory in which the script is located and from the >> user's home directory. All came back with the same path to the library file: >> >> /usr/local/lib/python2.7/site-packages/PIL/_imaging.so >> >> This is what I would expect when things are working correctly. >> >> Is there anything else I can check? >> >> Thanks for your help. >> Adam >> >> >> >> On 1/7/2011 3:33 PM, Fredrik Lundh wrote: >>> python -c "import _imaging; print _imaging.__file__" From chris.mit7 at gmail.com Sat Jan 8 20:41:01 2011 From: chris.mit7 at gmail.com (Chris Mitchell) Date: Sat, 8 Jan 2011 14:41:01 -0500 Subject: [Image-SIG] Locate The Center of WhiteDot from a Image In-Reply-To: References: <4D277419.1010908@noaa.gov> Message-ID: This uses numpy, for a centroid algorithm you can do this: data is your array of values within the box ul means upper left of your box xind = ul[1]+np.indices(np.shape(data))[1] yind = ul[0]+np.indices(np.shape(data))[0] x = (xind*data).sum()/float(data.sum()) y = (yind*data).sum()/float(data.sum()) On Fri, Jan 7, 2011 at 11:26 PM, Narendra Sisodiya wrote: > > > On Sat, Jan 8, 2011 at 1:44 AM, Christopher Barker > wrote: >> >> On 1/7/11 10:14 AM, Narendra Sisodiya wrote: >>> >>> This Code Look for bounding box which I am calculating by scanning each >>> row and column one by one. If I am finding any white pixel, I am >>> including it into my bounding box. >> >>> 1) there may a change that 2 or more WhiteDOT may present. One is Big >>> whiedot and other are very smaller whitedot(just 2-3 pixel) near to this >>> Big whitedot. >> >> Not sure about this one off the top of myhead, but I"d suspect some >> smoothing may take care of it. >> >>> I am applying this >>> algorithm on every frame taken from camera at 2fps. So I want a high >>> speed algorithm. PIL must be having some function or trick to do it. >> >> The Image..getbbox() method should do it. >> > > Thanks, I tried getbbox on wrong image. Now I am using getbbox and I am > getting proper result that too very fast. > >> >> If you need more math, numpy can help. Somethign like: >> >> a = np.asarray(PIL_image) >> background_color = 0 >> rows, cols = np.where(a <> background_color) # background color a uint32 >> BB = (rows.min(), rows.max(), cols.min(), cols.max()) > > > I am unable to get what that code means ? > May you explain how I can use above code with getbbox ? Or the above code > using NumPy is alternate of getbbox method ? > IF yes, then which will be the faster ? > > PS: I have looked at centroid algorithm, It is again going at pixel level > and that will be slow. My application will become better with faster > centroid algorithm. > > > Also I have another question ! > I am grabbing image from camera using opencv-python. How we can compare > python PIL with OpenCV ? My guess that PIL will is faster then opencv > library ? > > > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > From nicolas at famillepinault.fr Sat Jan 8 20:55:18 2011 From: nicolas at famillepinault.fr (Nicolas Pinault) Date: Sat, 08 Jan 2011 20:55:18 +0100 Subject: [Image-SIG] ANN: PIL 1.2 pre-alpha (January 8, 2011) In-Reply-To: References: Message-ID: <4D28C126.7090405@famillepinault.fr> Hello, That's good news. In CHANGES.txt file, one can read : + Added support for reading 16-bit RGB TIFF files. Does PIL 1.2 internally manages 16bit per pixel or does it still uses 8bit per pixel ? Best regards Nicolas Le 08/01/2011 02:41, Fredrik Lundh a ?crit : > A pre-alpha snapshot of the upcoming PIL 1.2 release is now available from: > > http://hg.effbot.org/pil-2009-raclette/downloads/PIL-1.2a0-20110108.tar.gz > > or via Mercurial, from https://bitbucket.org/effbot/pil-2009-raclette > > I've decided to abandon the planned 1.1.8 release, including the rough > and still unreleased 3.X port of 1.1.7+. Instead, the new plan is to > provide a single code base for both Python 2.X and 3.X, and most of > the changes in 1.2 will affect internal architecture and packaging > only (I do have some very interesting contributions that are pending > integration, though). Support for very old versions have been > dropped, and so has the support for importing from the standard > namespace; PIL now lives in the PIL namespace only. Some > long-deprecated methods have also been removed, but everything else > should work as usual. > > The source kit has been built and tested with Python 2.3, 2.4, 2.5, > 2.6, and 2.7. It also builds under Python 3.1 and 3.2 beta, even if > the functionality is currently *very* limited under Python 3.X. > > > > $ tar xvfz PIL-1.2a0-20110108.tar.gz > ... > $ cd PIL-1.2a0/ > $ python3 setup.py install --prefix . > ... > $ cd lib/python3.1/site-packages/ > $ python3 > Python 3.1.2 (r312:79147, Apr 15 2010, 15:35:48) > [GCC 4.4.3] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> from PIL import Image >>>> im = Image.open("../../../Images/lena.png") >>>> im > >>>> im.load() # only works under 2.X in this release > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > From v+python at g.nevcal.com Sun Jan 9 02:20:20 2011 From: v+python at g.nevcal.com (Glenn Linderman) Date: Sat, 08 Jan 2011 17:20:20 -0800 Subject: [Image-SIG] ANN: PIL 1.2 pre-alpha (January 8, 2011) In-Reply-To: References: Message-ID: <4D290D54.7070104@g.nevcal.com> On 1/7/2011 5:41 PM, Fredrik Lundh wrote: > It also builds under Python 3.1 and 3.2 beta, even if > the functionality is currently*very* limited under Python 3.X. Is there any doc that describes what does or doesn't work under 3.X? -------------- next part -------------- An HTML attachment was scrubbed... URL: From w3cing at gmail.com Sun Jan 9 11:37:25 2011 From: w3cing at gmail.com (wecing) Date: Sun, 9 Jan 2011 18:37:25 +0800 Subject: [Image-SIG] unable to make PIL work with cairo Message-ID: I wrote my code like this: > def video_observer(self, f): > > img = Image.frombuffer('RGB', (self._width, self._height), f.data, >> \ > > 'raw', 'RGB', 0, 1) > > >> img = img.resize((self.nwidth, self.nheight)) > > img.save('%d.jpg' % self.cnt, 'JPEG') # debug! :-P > > > > imgd = img.tostring('raw', 'RGBA', 0, 1) > > a = array.array('B', imgd) > > >> surface = cairo.ImageSurface.create_for_data(a, >> cairo.FORMAT_ARGB32, \ > > self.nwidth, self.nheight, self.nwidth * 4) # self.nwidth * 4 > > >> surface.write_to_png('%d.png' % self.cnt) > > >> self.context.set_source_surface(surface, 0, 0) > > self.context.paint() > > Output of img.save() is perfectly correct, but... > File "main.py", line 98, in video_observer imgd = img.tostring('raw', 'RGBA', 0, 1) File "/usr/lib/python2.6/dist-packages/PIL/Image.py", line 535, in > tostring e = _getencoder(self.mode, encoder_name, args) File "/usr/lib/python2.6/dist-packages/PIL/Image.py", line 399, in > _getencoder return apply(encoder, (mode,) + args + extra) SystemError: unknown raw mode Why? -------------- next part -------------- An HTML attachment was scrubbed... URL: From gwidion at mpc.com.br Sun Jan 9 16:35:50 2011 From: gwidion at mpc.com.br (Joao S. O. Bueno) Date: Sun, 9 Jan 2011 13:35:50 -0200 Subject: [Image-SIG] unable to make PIL work with cairo In-Reply-To: References: Message-ID: Hi Wecing -- I tried part of yoru code around and nailed the problem down: Although the "tostring" parameter accepts a "mode" argument, as it is documented, this mode cannot be different from teh actual current image mode. (Or at least, it can' t be RGBA if the current image is in RGB mode - I haven't actually tried with other combinations). The solution for your code is therefore to convert the image to RGBA in PIL before exporting it to a string: >>> img.save('%d.jpg' % self.cnt, 'JPEG') # debug! :-P >>> >>> +++ int_img = img.convert("RGBA") >>> >>> imgd = int_img.tostring('raw', 'RGBA', 0, 1) Regards, js -><- On Sun, Jan 9, 2011 at 8:37 AM, wecing wrote: > I wrote my code like this: >>> >>> ?? ?def video_observer(self, f): >>> >>> ?? ? ? ?img = Image.frombuffer('RGB', (self._width, self._height), >>> f.data, \ >>> >>> ?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'raw', 'RGB', 0, 1) >>> >>> ?? ? ? ?img = img.resize((self.nwidth, self.nheight)) >>> >>> ?? ? ? ?img.save('%d.jpg' % self.cnt, 'JPEG') # debug! :-P >>> >>> >>> >>> ?? ? ? ?imgd = img.tostring('raw', 'RGBA', 0, 1) >>> >>> ?? ? ? ?a = array.array('B', imgd) >>> >>> ?? ? ? ?surface = cairo.ImageSurface.create_for_data(a, >>> cairo.FORMAT_ARGB32, \ >>> >>> ?? ? ? ? ? ?self.nwidth, self.nheight, self.nwidth * 4) # self.nwidth * 4 >>> >>> ?? ? ? ?surface.write_to_png('%d.png' % self.cnt) >>> >>> ?? ? ? ?self.context.set_source_surface(surface, 0, 0) >>> >>> ?? ? ? ?self.context.paint() > > > Output of img.save() is perfectly correct, but... >> >> ??File "main.py", line 98, in video_observer >> >> ?? ?imgd = img.tostring('raw', 'RGBA', 0, 1) >> >> ??File "/usr/lib/python2.6/dist-packages/PIL/Image.py", line 535, in >> tostring >> >> ?? ?e = _getencoder(self.mode, encoder_name, args) >> >> ??File "/usr/lib/python2.6/dist-packages/PIL/Image.py", line 399, in >> _getencoder >> >> ?? ?return apply(encoder, (mode,) + args + extra) >> >> SystemError: unknown raw mode > > Why? > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > From fredrik at pythonware.com Mon Jan 10 11:43:57 2011 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 10 Jan 2011 11:43:57 +0100 Subject: [Image-SIG] ANN: PIL 1.2 pre-alpha (January 8, 2011) In-Reply-To: <4D290D54.7070104@g.nevcal.com> References: <4D290D54.7070104@g.nevcal.com> Message-ID: 2011/1/9 Glenn Linderman : > On 1/7/2011 5:41 PM, Fredrik Lundh wrote: > > It also builds under Python 3.1 and 3.2 beta, even if > the functionality is currently *very* limited under Python 3.X. > > Is there any doc that describes what does or doesn't work under 3.X? Beyond that transcript, not much works. Not enough to motivate putting together a document about it, at least :) But we're working on it. From mrvelle at gmail.com Mon Jan 10 14:06:01 2011 From: mrvelle at gmail.com (Thomas Larsen Wessel) Date: Mon, 10 Jan 2011 14:06:01 +0100 Subject: [Image-SIG] Putting a unicode string on an ImageDraw canvas Message-ID: People are telling me that PIL supports unicode strings, does it? And if yes, why does the following not work: import ImageFont, Image, ImageDraw s = u'\u0623\u0636\u0641' im = Image.new('RGB', (200,200)) draw = ImageDraw.Draw(im) draw.text((40,40), s) #fails It results in the following exception: Traceback (most recent call last): File "buffer.py", line 9, in draw.text((40,40), s) #fails File "/usr/lib/python2.6/dist-packages/PIL/ImageDraw.py", line 267, in text mask = font.getmask(text, self.fontmode) UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128) So how, do I put this unicode string on the canvas? Thanks in advance, Thomas -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Mon Jan 10 14:27:34 2011 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 10 Jan 2011 14:27:34 +0100 Subject: [Image-SIG] Putting a unicode string on an ImageDraw canvas In-Reply-To: References: Message-ID: 2011/1/10 Thomas Larsen Wessel : > People are telling me that PIL supports unicode strings, does it? And if > yes, why does the following not work: > > import ImageFont, Image, ImageDraw > s = u'\u0623\u0636\u0641' > im = Image.new('RGB', (200,200)) > draw = ImageDraw.Draw(im) > draw.text((40,40), s) #fails > > It results in the following exception: > > Traceback (most recent call last): > ? File "buffer.py", line 9, in > ??? draw.text((40,40), s) #fails > ? File "/usr/lib/python2.6/dist-packages/PIL/ImageDraw.py", line 267, in > text > ??? mask = font.getmask(text, self.fontmode) > UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: > ordinal not in range(128) > > So how, do I put this unicode string on the canvas? You'll need a font that supports Unicode, which the crappy default bitmap font doesn't. Use the ImageFont module to load a suitable TrueType font. From mrvelle at gmail.com Mon Jan 10 15:34:54 2011 From: mrvelle at gmail.com (Thomas Larsen Wessel) Date: Mon, 10 Jan 2011 15:34:54 +0100 Subject: [Image-SIG] Putting a unicode string on an ImageDraw canvas In-Reply-To: References: Message-ID: Thanks :) Here is an example that shows how both draw.text and draw.textsize works, as long as a unicode-supported font is supplied. It also shows how to get the text size directly from the font object. import ImageFont, Image, ImageDraw s = u'\u0623\u0636\u0641' font = ImageFont.truetype('/host/WINDOWS/Fonts/tahoma.ttf', 12, encoding='unic') print font.getsize(s) # no problem, works fine im = Image.new('RGB', (200,200)) draw = ImageDraw.Draw(im) print draw.textsize(s, font=font) #fails Thomas On Mon, Jan 10, 2011 at 2:27 PM, Fredrik Lundh wrote: > 2011/1/10 Thomas Larsen Wessel : > > People are telling me that PIL supports unicode strings, does it? And if > > yes, why does the following not work: > > > > import ImageFont, Image, ImageDraw > > s = u'\u0623\u0636\u0641' > > im = Image.new('RGB', (200,200)) > > draw = ImageDraw.Draw(im) > > draw.text((40,40), s) #fails > > > > It results in the following exception: > > > > Traceback (most recent call last): > > File "buffer.py", line 9, in > > draw.text((40,40), s) #fails > > File "/usr/lib/python2.6/dist-packages/PIL/ImageDraw.py", line 267, in > > text > > mask = font.getmask(text, self.fontmode) > > UnicodeEncodeError: 'ascii' codec can't encode characters in position > 0-2: > > ordinal not in range(128) > > > > So how, do I put this unicode string on the canvas? > > You'll need a font that supports Unicode, which the crappy default > bitmap font doesn't. Use the ImageFont module to load a suitable > TrueType font. > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Mon Jan 10 22:37:03 2011 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 10 Jan 2011 22:37:03 +0100 Subject: [Image-SIG] Putting a unicode string on an ImageDraw canvas In-Reply-To: References: Message-ID: 2011/1/10 Thomas Larsen Wessel : > Thanks :) > > Here is an example that shows how both draw.text and draw.textsize works, as > long as a unicode-supported font is supplied. It also shows how to get the > text size directly from the font object. > > import ImageFont, Image, ImageDraw > > s = u'\u0623\u0636\u0641' > > font = ImageFont.truetype('/host/WINDOWS/Fonts/tahoma.ttf', 12, > encoding='unic') > print font.getsize(s) # no problem, works fine > > im = Image.new('RGB', (200,200)) > draw = ImageDraw.Draw(im) > print draw.textsize(s, font=font) #fails Hmm. That works for me in both 1.1.7 and trunk, and I don't really see how it can fail for you given that it ends up calling the same method in both cases: def textsize(self, text, font=None): if font is None: font = self.getfont() return font.getsize(text) What's the exact error? From Chris.Barker at noaa.gov Tue Jan 11 05:20:13 2011 From: Chris.Barker at noaa.gov (Chris Barker) Date: Mon, 10 Jan 2011 20:20:13 -0800 Subject: [Image-SIG] Locate The Center of WhiteDot from a Image In-Reply-To: References: <4D277419.1010908@noaa.gov> Message-ID: <4D2BDA7D.6030309@noaa.gov> On 1/7/2011 8:26 PM, Narendra Sisodiya wrote: > If you need more math, numpy can help. Somethign like: > > a = np.asarray(PIL_image) > background_color = 0 > rows, cols = np.where(a <> background_color) # background color a uint32 > BB = (rows.min(), rows.max(), cols.min(), cols.max()) > > I am unable to get what that code means ? > May you explain how I can use above code with getbbox ? Or the above > code using NumPy is alternate of getbbox method ? It's an alternative. > IF yes, then which will be the faster ? The only way to know is to try it, but I suspect the PIL getbox() is a bit faster, as I image it does it all in one C loop. numpy is doing it in a couple loops. The reason to use numpy is if you want to do something more complex that is not directly supported by PIL. you might want to look at the scip ndimage toolbox it has some useful stuff: http://www.scipy.org/SciPyPackages/Ndimage though perhaps you've solved you problem. -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 wrybread at gmail.com Tue Jan 11 08:17:44 2011 From: wrybread at gmail.com (Alec Bennett) Date: Mon, 10 Jan 2011 23:17:44 -0800 Subject: [Image-SIG] Locate The Center of WhiteDot from a Image In-Reply-To: References: <4D277419.1010908@noaa.gov> Message-ID: I need to do this too. Could you possibly keep the list updated with your findings? On Fri, Jan 7, 2011 at 8:26 PM, Narendra Sisodiya < narendra at narendrasisodiya.com> wrote: > > > On Sat, Jan 8, 2011 at 1:44 AM, Christopher Barker wrote: > >> On 1/7/11 10:14 AM, Narendra Sisodiya wrote: >> >>> This Code Look for bounding box which I am calculating by scanning each >>> row and column one by one. If I am finding any white pixel, I am >>> including it into my bounding box. >>> >> >> 1) there may a change that 2 or more WhiteDOT may present. One is Big >>> whiedot and other are very smaller whitedot(just 2-3 pixel) near to this >>> Big whitedot. >>> >> >> Not sure about this one off the top of myhead, but I"d suspect some >> smoothing may take care of it. >> >> >> I am applying this >>> algorithm on every frame taken from camera at 2fps. So I want a high >>> speed algorithm. PIL must be having some function or trick to do it. >>> >> >> The Image..getbbox() method should do it. >> >> > Thanks, I tried getbbox on wrong image. Now I am using getbbox and I am > getting proper result that too very fast. > > >> If you need more math, numpy can help. Somethign like: >> >> a = np.asarray(PIL_image) >> background_color = 0 >> rows, cols = np.where(a <> background_color) # background color a uint32 >> BB = (rows.min(), rows.max(), cols.min(), cols.max()) >> > > > I am unable to get what that code means ? > May you explain how I can use above code with getbbox ? Or the above code > using NumPy is alternate of getbbox method ? > IF yes, then which will be the faster ? > > PS: I have looked at centroid algorithm, It is again going at pixel level > and that will be slow. My application will become better with faster > centroid algorithm. > > > Also I have another question ! > I am grabbing image from camera using opencv-python. How we can compare > python PIL with OpenCV ? My guess that PIL will is faster then opencv > library ? > > > _______________________________________________ > 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 Tue Jan 11 11:10:06 2011 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 11 Jan 2011 11:10:06 +0100 Subject: [Image-SIG] Locate The Center of WhiteDot from a Image In-Reply-To: References: <4D277419.1010908@noaa.gov> Message-ID: 2011/1/8 Narendra Sisodiya : > PS: I have looked at centroid algorithm, It is again going at pixel level > and that will be slow. My application will become better with faster > centroid algorithm. Well, you only have to process the part of the image that contains your dot. If it occupies 10% of the image, it'll run 100 times faster than an algorithm that processes the entire image. > Also I have another question ! > I am grabbing image from camera using opencv-python. How we can compare > python PIL with OpenCV ? My guess that PIL will is faster then opencv > library ? OpenCV is a machine vision library, so I assume that you'll find a lot of useful vision algorithms in there. PIL is more of a general purpose library; lots of people use it in conjunction with more specialized libraries. From mhenson at livemosaic.com Thu Jan 13 17:04:35 2011 From: mhenson at livemosaic.com (Matt Henson) Date: Thu, 13 Jan 2011 10:04:35 -0600 Subject: [Image-SIG] libjpeg-turbo? Message-ID: I'm using PIL in livemosaic.com, a medium volume web application based on Turbogears 1.1. We use PIL to process customer's images (scaling to multiple sizes as well as basic image manipulation). We're running FC8 Linux boxes on Amazon's EC2 cloud. I'd like to improve JPEG encoding performance. It looks like PIL (at least on our FC8 servers) is using an older version of libjpeg. I understand that libjpeg-turbo is much faster. Does PIL work with libjpeg-turbo? If so then how would I go about the upgrade? Is it as simple as upgrading a library in my servers, or do I need to re-compile PIL or something else? I know that FC14 was just released with libjpeg-turbo. If I upgrade to FC14, will PIL automatically start using libjpeg-turbo? If libjpeg-turbo isn't supported now, is it on the roadmap? Altermatively, is there a simple way to use some other tool for JPEG encode and decode (while still using PIL and the other great Python libs for manipulation)? Thanks for any help that you can provide. Matt Henson Founder, LiveMosaic -------------- next part -------------- An HTML attachment was scrubbed... URL: From erwan.loaec at cgin.fr Fri Jan 14 16:21:50 2011 From: erwan.loaec at cgin.fr (=?ISO-8859-1?Q?Erwan_Loa=EBc?=) Date: Fri, 14 Jan 2011 16:21:50 +0100 Subject: [Image-SIG] Patch for freetype issue Message-ID: <4D306A0E.8040400@cgin.fr> Hello, I've found a bug in the function font_render() of _imagingft.c. The "x" value is adapted according to the horiBearingX value of the first glyph but the concerned glyph is loaded after. I suggest the patch in attachment. Is anyone can take a look and confirm this is really a bug ? Regards, -- Erwan Loaec -------------- next part -------------- A non-text attachment was scrubbed... Name: _imagingft.c.patch Type: text/x-patch Size: 1101 bytes Desc: not available URL: From norbidur at gmail.com Fri Jan 21 00:27:38 2011 From: norbidur at gmail.com (Norbert Cauderan) Date: Fri, 21 Jan 2011 00:27:38 +0100 Subject: [Image-SIG] Patch for freetype issue In-Reply-To: <4D306A0E.8040400@cgin.fr> References: <4D306A0E.8040400@cgin.fr> Message-ID: On Fri, Jan 14, 2011 at 4:21 PM, Erwan Loa?c wrote: > Is anyone can take a look and confirm this is really a bug ? > Without the patch, following code gives 2 truncated "j". With the patch, everything looks OK. The problem does not appear with every font but at least with "arial" on windows and DejaVuSerif on linux. import Image import ImageDraw import ImageFont font = ImageFont.truetype('/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf', 150,encoding="unic") im = Image.new("RGBA",(500,800),(0,255,0,127)) draw = ImageDraw.Draw(im) draw.text((100,10),"jj ",font=font,fill=(255,0,0,255)) draw.text((100,180),"ji",font=font,fill=(255,0,0,255)) draw.text((100,370),"jj",font=font,fill=(255,0,0,255)) im.save("test.png") -------------- next part -------------- An HTML attachment was scrubbed... URL: From viktor.shulika at gmail.com Tue Jan 25 21:09:26 2011 From: viktor.shulika at gmail.com (Viktor Shulika) Date: Tue, 25 Jan 2011 21:09:26 +0100 Subject: [Image-SIG] IOError: encoder error -2 when writing image file Message-ID: Hello, I've the error when try to save jpeg image with PIL When I use ImageMagic on PHP save without problems. Image in attachment. The same error I've got on Mac and Linux Environment: Request Method: POST Request URL: http://next.aquavita-travel.ru/adminka/cure/sanatorium/3/ Django Version: 1.2.3 Python Version: 2.5.2 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'django.contrib.admindocs', 'django.contrib.markup', 'django_extensions', 'imagekit', 'compressor', 'robots', 'cure', 'imageofmodel', 'medicine', 'mkb10', 'services', 'map', 'accommodation', 'qa', 'currencies', 'prices', 'phrasebook'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'slimmer.middleware.CompressHtmlMiddleware') Traceback: Traceback (most recent call last): File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/contrib/staticfiles/handlers.py", line 74, in __call__ return self.application(environ, start_response) File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/core/handlers/wsgi.py", line 265, in __call__ response = self.get_response(request) File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/core/handlers/base.py", line 162, in get_response response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/core/handlers/base.py", line 203, in handle_uncaught_exception return debug.technical_500_response(request, *exc_info) File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/core/handlers/base.py", line 111, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/contrib/admin/options.py", line 298, in wrapper return self.admin_site.admin_view(view)(*args, **kwargs) File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/utils/decorators.py", line 93, in _wrapped_view response = view_func(request, *args, **kwargs) File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/views/decorators/cache.py", line 79, in _wrapped_view_func response = view_func(request, *args, **kwargs) File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/contrib/admin/sites.py", line 190, in inner return view(request, *args, **kwargs) File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/utils/decorators.py", line 28, in _wrapper return bound_func(*args, **kwargs) File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/utils/decorators.py", line 93, in _wrapped_view response = view_func(request, *args, **kwargs) File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/utils/decorators.py", line 24, in bound_func return func(self, *args2, **kwargs2) File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/db/transaction.py", line 291, in inner res = func(*args, **kwargs) File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/contrib/admin/options.py", line 953, in change_view self.save_formset(request, form, formset, change=True) File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/contrib/admin/options.py", line 658, in save_formset formset.save() File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/forms/models.py", line 501, in save return self.save_existing_objects(commit) + self.save_new_objects(commit) File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/forms/models.py", line 638, in save_new_objects self.new_objects.append(self.save_new(form, commit=commit)) File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/contrib/contenttypes/generic.py", line 354, in save_new return save_instance(form, new_obj, commit=commit) File "/Users/user/virtualenvs/podivm.ru/lib/python2.5/site-packages/django/forms/models.py", line 87, in save_instance instance.save() File "/opt/local/lib/python2.5/site-packages/django_imageofmodel-0.0.5-py2.5.egg/imageofmodel/models.py", line 79, in save super(self.__class__, self).save(*args, **kwargs) File "/opt/local/lib/python2.5/site-packages/django_imagekit-0.3.3-py2.5.egg/imagekit/models.py", line 145, in save self._pre_cache() File "/opt/local/lib/python2.5/site-packages/django_imagekit-0.3.3-py2.5.egg/imagekit/models.py", line 110, in _pre_cache prop._create() File "/opt/local/lib/python2.5/site-packages/django_imagekit-0.3.3-py2.5.egg/imagekit/specs.py", line 65, in _create content = ContentFile(self._get_imgfile().read()) File "/opt/local/lib/python2.5/site-packages/django_imagekit-0.3.3-py2.5.egg/imagekit/specs.py", line 50, in _get_imgfile optimize=True) File "/opt/local/lib/python2.5/site-packages/django_imagekit-0.3.3-py2.5.egg/imagekit/utils.py", line 7, in img_to_fobj img.save(tmp, format, **kwargs) File "/opt/local/lib/python2.5/site-packages/PIL/Image.py", line 1405, in save save_handler(self, fp, filename) File "/opt/local/lib/python2.5/site-packages/PIL/JpegImagePlugin.py", line 409, in _save ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)]) File "/opt/local/lib/python2.5/site-packages/PIL/ImageFile.py", line 493, in _save raise IOError("encoder error %d when writing image file" % s) IOError: encoder error -2 when writing image file -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ????.jpg Type: image/jpeg Size: 172868 bytes Desc: not available URL: